From cf9220b7d59d7dc67344b5678df3f2870e374be5 Mon Sep 17 00:00:00 2001 From: robfram Date: Sat, 30 Oct 2021 23:15:07 +0200 Subject: [PATCH] Only visible TileMaps should add light occluders --- scene/2d/tile_map.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index ac60ecc22f1..1d9cb1435a7 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -111,6 +111,15 @@ void TileMap::_notification(int p_what) { } } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { + for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { + for (Map::Element *F = E->get().occluder_instances.front(); F; F = F->next()) { + VS::get_singleton()->canvas_light_occluder_set_enabled(F->get().id, is_visible()); + } + } + + } break; } } @@ -675,6 +684,7 @@ void TileMap::update_dirty_quadrants() { VS::get_singleton()->canvas_light_occluder_set_polygon(orid, occluder->get_rid()); VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid, get_canvas()); VS::get_singleton()->canvas_light_occluder_set_light_mask(orid, occluder_light_mask); + VS::get_singleton()->canvas_light_occluder_set_enabled(orid, is_visible()); Quadrant::Occluder oc; oc.xform = xform; oc.id = orid;