Fixes SDF Collision Enable/Disable

- sets LightOccluderInstance field when sdf collision is updated
- adds check for light occluder sdf_collision field in 2d renderers
This commit is contained in:
cosparks 2024-04-18 20:10:55 -07:00
parent 7abe0c6014
commit 6d0dca76c0
3 changed files with 4 additions and 2 deletions

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}