Portals - Fix CSG updates on room conversion

Due to a quirk in CSG Shapes, updating is usually deferred to the next frame. This is problematic as we need to read back the geometry on the first frame when converting levels.

This PR adds a function to CSGShape to force immediate updating (if dirty), and calls it during room conversion.
This commit is contained in:
lawnjelly
2021-07-29 12:41:23 +01:00
parent 5d4352fad4
commit e06cd3042f
3 changed files with 18 additions and 0 deletions

View File

@@ -1596,6 +1596,11 @@ bool RoomManager::_bound_findpoints_geom_instance(GeometryInstance *p_gi, Vector
#ifdef MODULE_CSG_ENABLED
CSGShape *shape = Object::cast_to<CSGShape>(p_gi);
if (shape) {
// Shapes will not be up to date on the first frame due to a quirk
// of CSG - it defers updates to the next frame. So we need to explicitly
// force an update to make sure the CSG is correct on level load.
shape->force_update_shape();
Array arr = shape->get_meshes();
if (!arr.size()) {
return false;