summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorNathan Franke <me@nathan.sh>2022-12-04 14:40:19 -0600
committerNathan Franke <me@nathan.sh>2022-12-04 14:40:19 -0600
commitaef261aa2a68bac65c2091d4459f45f37db5ef33 (patch)
tree75f1e690161541e08281707de4b8654ebf31593b /servers/rendering
parent015dc492de33a41eaeb14c0503a6be10466fe457 (diff)
fix aabb errors on meshes with bones on multiple surfaces
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index 71f4f3ad11..503a25184e 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -445,7 +445,14 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
for (int i = 0; i < p_surface.bone_aabbs.size(); i++) {
const AABB &bone = p_surface.bone_aabbs[i];
if (bone.has_volume()) {
- mesh->bone_aabbs.write[i].merge_with(bone);
+ AABB &mesh_bone = mesh->bone_aabbs.write[i];
+ if (mesh_bone != AABB()) {
+ // Already initialized, merge AABBs.
+ mesh_bone.merge_with(bone);
+ } else {
+ // Not yet initialized, copy the bone AABB.
+ mesh_bone = bone;
+ }
}
}
mesh->aabb.merge_with(p_surface.aabb);