From 6d0dca76c08114b6b2cb69430f102cb85aa9d60a Mon Sep 17 00:00:00 2001 From: cosparks Date: Thu, 18 Apr 2024 20:10:55 -0700 Subject: [PATCH] Fixes SDF Collision Enable/Disable - sets LightOccluderInstance field when sdf collision is updated - adds check for light occluder sdf_collision field in 2d renderers --- drivers/gles3/rasterizer_canvas_gles3.cpp | 2 +- servers/rendering/renderer_canvas_cull.cpp | 2 ++ servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 9fa95a93f83..5fabeb94f5b 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1922,7 +1922,7 @@ void RasterizerCanvasGLES3::render_sdf(RID p_render_target, LightOccluderInstanc while (instance) { OccluderPolygon *oc = occluder_polygon_owner.get_or_null(instance->occluder); - if (!oc || oc->sdf_vertex_array == 0) { + if (!oc || oc->sdf_vertex_array == 0 || !instance->sdf_collision) { instance = instance->next; continue; } diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index 46c84fd2306..34f9069649c 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -1970,6 +1970,8 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p void RendererCanvasCull::canvas_light_occluder_set_as_sdf_collision(RID p_occluder, bool p_enable) { RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder); ERR_FAIL_NULL(occluder); + + occluder->sdf_collision = p_enable; } void RendererCanvasCull::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) { diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 6f567111516..fa8cf9c0288 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -1931,7 +1931,7 @@ void RendererCanvasRenderRD::render_sdf(RID p_render_target, LightOccluderInstan while (instance) { OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder); - if (!co || co->sdf_index_array.is_null()) { + if (!co || co->sdf_index_array.is_null() || !instance->sdf_collision) { instance = instance->next; continue; }