Repository: godotengine/godot
File: servers/rendering/rendering_light_culler.cpp (C++)

Code before:
#ifdef LIGHT_CULLER_DEBUG_LOGGING
			if (is_logging()) {
				for (int p = 0; p < 6; p++) {
					print_line("cascade " + itos(i) + " plane " + itos(p) + " : " + String(cull_planes[p]));
				}
			}
#endif

			//Frustum point calculation
			Vector3 frustum_points[8];
			bool success = create_frustum_points(cull_planes, frustum_points);
			ERR_FAIL_COND_V(!success, false);

			//Replace frustum arguments with cascade's.
			LightCullPlanes &destination = data.directional_cull_planes[p_directional_light_id].planes[i];
			visible = _add_light_camera_planes(destination, lsource, { cull_planes, frustum_points });
		}
	}

	if (data.light_culling_active) {
		return visible;
	}
	return true;
}

bool RenderingLightCuller::cull_directional_light(const RendererSceneCull::InstanceBounds &p_bound, int32_t p_directional_light_id, int32_t cascade) {
	if (!data.is_active() || !is_caster_culling_active()) {
		return true;
	}

	ERR_FAIL_INDEX_V(p_directional_light_id, (int32_t)data.directional_cull_planes.size(), true);

	LightCullPlanes &cull_planes = data.directional_cull_planes[p_directional_light_id].planes[cascade];

	Vector3 mins = Vector3(p_bound.bounds[0], p_bound.bounds[1], p_bound.bounds[2]);
	Vector3 maxs = Vector3(p_bound.bounds[3], p_bound.bounds[4], p_bound.bounds[5]);
	AABB bb(mins, maxs - mins);

	real_t r_min, r_max;
	for (int p = 0; p < cull_planes.num_cull_planes; p++) {
		bb.project_range_in_plane(cull_planes.cull_planes[p], r_min, r_max);
		if (r_min > 0.0f) {
#ifdef LIGHT_CULLER_DEBUG_DIRECTIONAL_LIGHT
			cull_planes.rejected_count++;
#endif

			return false;
		}
	}

	return true;

Review comment (suggestion):
```suggestion
bool RenderingLightCuller::cull_directional_light(const RendererSceneCull::InstanceBounds &p_bound, int32_t p_directional_light_id, int32_t p_cascade) {
```

Code after:
				data.frustum_planes[4],
				data.frustum_planes[5],
			};

#ifdef LIGHT_CULLER_DEBUG_LOGGING
			if (is_logging()) {
				for (int p = 0; p < 6; p++) {
					print_line("cascade " + itos(i) + " plane " + itos(p) + " : " + String(cull_planes[p]));
				}
			}
#endif

			// Frustum point calculation
			Vector3 frustum_points[8];
			bool success = create_frustum_points(cull_planes, frustum_points);
			ERR_FAIL_COND_V(!success, false);

			// Replace frustum arguments with cascade's.
			LightCullPlanes &destination = data.directional_cull_planes[p_directional_light_id].planes[i];
			visible = _add_light_camera_planes(destination, lsource, { cull_planes, frustum_points });
		}
	}

	if (data.light_culling_active) {
		return visible;
	}
	return true;
}

bool RenderingLightCuller::cull_directional_light(const RendererSceneCull::InstanceBounds &p_bound, int32_t p_directional_light_id, int32_t p_cascade) {
	if (!data.is_active() || !is_caster_culling_active()) {
		return true;
	}

	ERR_FAIL_INDEX_V(p_directional_light_id, (int32_t)data.directional_cull_planes.size(), true);

	LightCullPlanes &cull_planes = data.directional_cull_planes[p_directional_light_id].planes[p_cascade];

	Vector3 mins = Vector3(p_bound.bounds[0], p_bound.bounds[1], p_bound.bounds[2]);
	Vector3 maxs = Vector3(p_bound.bounds[3], p_bound.bounds[4], p_bound.bounds[5]);
	AABB bb(mins, maxs - mins);

	real_t r_min, r_max;
	for (int p = 0; p < cull_planes.num_cull_planes; p++) {
		bb.project_range_in_plane(cull_planes.cull_planes[p], r_min, r_max);
		if (r_min > 0.0f) {
#ifdef LIGHT_CULLER_DEBUG_DIRECTIONAL_LIGHT
			cull_planes.rejected_count++;
#endif

			return false;