From c2dd51a85e952491ea02f5f3e44de0422fab9a23 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Thu, 22 Jul 2021 20:23:57 +0100 Subject: [PATCH] Portals - fix adding statics twice Due to an oversight in the autoplace recursive search for static objects, static objects were getting added twice to the portal renderer, which meant they were being rendered twice, lowering performance. This PR corrects this horrendous error. --- scene/3d/room_manager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scene/3d/room_manager.cpp b/scene/3d/room_manager.cpp index 910d6890f42..e1a67448113 100644 --- a/scene/3d/room_manager.cpp +++ b/scene/3d/room_manager.cpp @@ -1141,6 +1141,12 @@ void RoomManager::_autoplace_recursive(Spatial *p_node) { return; } + // as soon as we hit a room, quit the recursion as the objects + // will already have been added inside rooms + if (Object::cast_to(p_node)) { + return; + } + VisualInstance *vi = Object::cast_to(p_node); // we are only interested in VIs with static or dynamic mode