Check skeleton RID when using cached AABB

This commit is contained in:
Erik Johnson 2023-12-16 17:36:03 -05:00
parent 2d0ee20ff3
commit d874ead58d
2 changed files with 4 additions and 1 deletions

View File

@ -657,7 +657,8 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
if (!skeleton || skeleton->size == 0 || mesh->skeleton_aabb_version == skeleton->version) {
// A mesh can be shared by multiple skeletons and we need to avoid using the AABB from a different skeleton.
if (!skeleton || skeleton->size == 0 || (mesh->skeleton_aabb_version == skeleton->version && mesh->skeleton_aabb_rid == p_skeleton)) {
return mesh->aabb;
}
@ -763,6 +764,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
mesh->aabb = aabb;
mesh->skeleton_aabb_version = skeleton->version;
mesh->skeleton_aabb_rid = p_skeleton;
return aabb;
}

View File

@ -153,6 +153,7 @@ private:
AABB aabb;
AABB custom_aabb;
uint64_t skeleton_aabb_version = 0;
RID skeleton_aabb_rid;
Vector<RID> material_cache;