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

fix aabb errors on meshes with bones on multiple surfaces

This commit is contained in:
Nathan Franke
2022-12-04 14:40:19 -06:00
parent 015dc492de
commit aef261aa2a
2 changed files with 16 additions and 2 deletions

View File

@@ -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);

View File

@@ -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);