1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Portals - Allow user to set roaming expansion margin

Previously a crude metric was used to decide on the roaming expansion margin, but it created unexpected results in some scenarios. Instead this setting is exposed to the user via the RoomManager, allowing them to tailor it to the world size, room sizes, roaming objects sizes and the speeds of movement.
This commit is contained in:
lawnjelly
2021-11-12 15:32:23 +00:00
parent 0529813cf2
commit 788f075b44
10 changed files with 29 additions and 22 deletions

View File

@@ -822,20 +822,6 @@ void PortalRenderer::rooms_finalize(bool p_generate_pvs, bool p_cull_using_pvs,
// from position
_rooms_lookup_bsp.create(*this);
// calculate the roaming expansion margin based on the average room size
Vector3 total_size = Vector3(0, 0, 0);
for (int n = 0; n < get_num_rooms(); n++) {
total_size += get_room(n)._aabb.size;
}
if (get_num_rooms()) {
total_size /= get_num_rooms();
AABB temp;
temp.size = total_size;
// longest axis of average room * fudge factor
_roaming_expansion_margin = temp.get_longest_axis_size() * 0.08;
}
// calculate PVS
if (p_generate_pvs) {
PVSBuilder pvs;