From 236ce550c0a8c036510a9615d9c6ddffc530f614 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Tue, 1 Oct 2019 19:09:03 +0100 Subject: [PATCH] Showing and hiding geometry updates shadows Showing and hiding geometry nodes was not showing or hiding their respective shadows. This fixes this by marking any affected lights as dirty. Fixes #29856 --- servers/visual/visual_server_scene.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 7c100be0f28..65b0e625321 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -660,6 +660,18 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) { instance->visible = p_visible; + // when showing or hiding geometry, lights must be kept up to date to show / hide shadows + if ((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) { + InstanceGeometryData *geom = static_cast(instance->base_data); + + if (geom->can_cast_shadows) { + for (List::Element *E = geom->lighting.front(); E; E = E->next()) { + InstanceLightData *light = static_cast(E->get()->base_data); + light->shadow_dirty = true; + } + } + } + switch (instance->base_type) { case VS::INSTANCE_LIGHT: { if (VSG::storage->light_get_type(instance->base) != VS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) {