From b09bc22b749a60c149c894216da9f5e0da9441ad Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Fri, 10 May 2024 09:05:49 +0100 Subject: [PATCH] Tighter light culling - fix directional lights colinear case Exactly the same fix as done already for non-directional lights. --- servers/visual/visual_server_light_culler.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/servers/visual/visual_server_light_culler.cpp b/servers/visual/visual_server_light_culler.cpp index 83823ed73b2d..4f2ebdd6d121 100644 --- a/servers/visual/visual_server_light_culler.cpp +++ b/servers/visual/visual_server_light_culler.cpp @@ -227,9 +227,11 @@ bool VisualServerLightCuller::add_light_camera_planes_directional(const LightSou // Create a third point from the light direction. Vector3 pt2 = pt0 - p_light_source.dir; - // Create plane from 3 points. - Plane p(pt0, pt1, pt2); - add_cull_plane(p); + if (!_is_colinear_tri(pt0, pt1, pt2)) { + // Create plane from 3 points. + Plane p(pt0, pt1, pt2); + add_cull_plane(p); + } } // Last to 0 edge. @@ -243,9 +245,11 @@ bool VisualServerLightCuller::add_light_camera_planes_directional(const LightSou // Create a third point from the light direction. Vector3 pt2 = pt0 - p_light_source.dir; - // Create plane from 3 points. - Plane p(pt0, pt1, pt2); - add_cull_plane(p); + if (!_is_colinear_tri(pt0, pt1, pt2)) { + // Create plane from 3 points. + Plane p(pt0, pt1, pt2); + add_cull_plane(p); + } } #ifdef LIGHT_CULLER_DEBUG_LOGGING