diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index 37380fd2b46..8f21260d573 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -1491,11 +1491,17 @@ void LightmapGI::_notification(int p_what) { "%s (%s): The directional lightmap textures are stored in a format that isn't supported anymore. Please bake lightmaps again to make lightmaps display from this node again.", get_light_data()->get_path(), get_name())); + if (last_owner && last_owner != get_owner()) { + light_data->clear_users(); + } + _assign_lightmaps(); } } break; case NOTIFICATION_EXIT_TREE: { + last_owner = get_owner(); + if (light_data.is_valid()) { _clear_lightmaps(); } diff --git a/scene/3d/lightmap_gi.h b/scene/3d/lightmap_gi.h index a48e599d681..0848239fee0 100644 --- a/scene/3d/lightmap_gi.h +++ b/scene/3d/lightmap_gi.h @@ -206,6 +206,7 @@ private: Ref camera_attributes; Ref light_data; + Node *last_owner = nullptr; struct LightsFound { Transform3D xform;