You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Portals - fix recursive loop looking out from internal rooms
In some situations looking out from an internal room it was possible to look back into the portal into the internal room. This PR fixes this by keeping a single item 'stack' record of the last external room, and preventing recursing into this room. This also makes tracing significantly more efficient out of internal rooms, as there is no need to trace the external room multiple times.
This commit is contained in:
@@ -233,9 +233,10 @@ void PVSBuilder::save_pvs(String p_filename) {
|
||||
|
||||
#endif
|
||||
|
||||
void PVSBuilder::calculate_pvs(PortalRenderer &p_portal_renderer, String p_filename) {
|
||||
void PVSBuilder::calculate_pvs(PortalRenderer &p_portal_renderer, String p_filename, int p_depth_limit) {
|
||||
_portal_renderer = &p_portal_renderer;
|
||||
_pvs = &p_portal_renderer.get_pvs();
|
||||
_depth_limit = p_depth_limit;
|
||||
|
||||
// attempt to load from file rather than create each time
|
||||
#ifdef GODOT_PVS_SUPPORT_SAVE_FILE
|
||||
@@ -330,6 +331,12 @@ void PVSBuilder::trace_rooms_recursive(int p_depth, int p_source_room_id, int p_
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent too much depth
|
||||
if (p_depth > _depth_limit) {
|
||||
WARN_PRINT_ONCE("Portal Depth Limit reached (seeing through too many portals)");
|
||||
return;
|
||||
}
|
||||
|
||||
logd(p_depth, "trace_rooms_recursive room " + itos(p_room_id));
|
||||
|
||||
// get the room
|
||||
|
||||
Reference in New Issue
Block a user