Merge pull request #70087 from clayjohn/mesh-aabb
Cache mesh AABB when modified by skeleton and update instance AABB when skeleton changes
This commit is contained in:
commit
13593d8644
4 changed files with 8 additions and 3 deletions
|
@ -528,7 +528,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
|
||||||
|
|
||||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||||
|
|
||||||
if (!skeleton || skeleton->size == 0) {
|
if (!skeleton || skeleton->size == 0 || mesh->skeleton_aabb_version == skeleton->version) {
|
||||||
return mesh->aabb;
|
return mesh->aabb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,6 +622,8 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mesh->aabb = aabb;
|
||||||
|
mesh->skeleton_aabb_version = skeleton->version;
|
||||||
return aabb;
|
return aabb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ struct Mesh {
|
||||||
|
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
AABB custom_aabb;
|
AABB custom_aabb;
|
||||||
|
uint64_t skeleton_aabb_version = 0;
|
||||||
|
|
||||||
Vector<RID> material_cache;
|
Vector<RID> material_cache;
|
||||||
|
|
||||||
|
|
|
@ -715,6 +715,8 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mesh->aabb = aabb;
|
||||||
|
|
||||||
mesh->skeleton_aabb_version = skeleton->version;
|
mesh->skeleton_aabb_version = skeleton->version;
|
||||||
return aabb;
|
return aabb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,6 +476,7 @@ public:
|
||||||
Instance *instance = (Instance *)tracker->userdata;
|
Instance *instance = (Instance *)tracker->userdata;
|
||||||
switch (p_notification) {
|
switch (p_notification) {
|
||||||
case Dependency::DEPENDENCY_CHANGED_SKELETON_DATA:
|
case Dependency::DEPENDENCY_CHANGED_SKELETON_DATA:
|
||||||
|
case Dependency::DEPENDENCY_CHANGED_SKELETON_BONES:
|
||||||
case Dependency::DEPENDENCY_CHANGED_AABB: {
|
case Dependency::DEPENDENCY_CHANGED_AABB: {
|
||||||
singleton->_instance_queue_update(instance, true, false);
|
singleton->_instance_queue_update(instance, true, false);
|
||||||
|
|
||||||
|
@ -491,8 +492,7 @@ public:
|
||||||
case Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE: {
|
case Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE: {
|
||||||
singleton->_instance_queue_update(instance, true, true);
|
singleton->_instance_queue_update(instance, true, true);
|
||||||
} break;
|
} break;
|
||||||
case Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES:
|
case Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES: {
|
||||||
case Dependency::DEPENDENCY_CHANGED_SKELETON_BONES: {
|
|
||||||
//ignored
|
//ignored
|
||||||
} break;
|
} break;
|
||||||
case Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR: {
|
case Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR: {
|
||||||
|
|
Loading…
Reference in a new issue