summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-06 12:26:03 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-06 12:26:03 +0100
commit43e9ca40ff9a87655249e372654e2d30223363f7 (patch)
treee12f91d35b6073514e099babe6a8af2c061a7a30 /drivers
parent2b49ef12af6379b57d5fa490426903f9888a526a (diff)
parentaef261aa2a68bac65c2091d4459f45f37db5ef33 (diff)
Merge pull request #65035 from nathanfranke/fix-aabb-mesh
Fix AABB errors on meshes with bones on multiple surfaces
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/storage/mesh_storage.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp
index 285f32f1a5..5bbbc7b91b 100644
--- a/drivers/gles3/storage/mesh_storage.cpp
+++ b/drivers/gles3/storage/mesh_storage.cpp
@@ -334,7 +334,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);