Update actor render bounding box (#991)

* Extend MeshFeatureProcessor to allow changing the mesh bbox, which requires re-compute the culling data for that mesh

* Update actor mesh bbox when EMFX actor instance bbox changes.

Also use the actor instance global bbox to compute the local bbox for the skinned render mesh, instead of the using the static bounds based bbox, as not every actor instance is going to be using the static bounds bbox.

* Store per-instance mesh AABB in the right place.

In the MeshInstanceData, which is unique per instance, instead of in the Model, which is shared between all instances.

For greater clarity, also remove Model::m_aabb and the corresponding getter and setter, as it isn't immediately obvious whether this gets the model asset bbox or the mesh instance bbox. Callers should instead be explicit about which bbox they want.

* Bug fix: model asset is not necessarily ready in AcquireMesh

* Remove now-unused forward declaration

* Update MockMeshFeatureProcessor with SetLocalAabb/GetLocalAabb
This commit is contained in:
yuriy0
2021-06-15 14:09:30 -04:00
committed by GitHub
parent aade48e751
commit a9c55c1070
9 changed files with 62 additions and 20 deletions
@@ -460,10 +460,10 @@ namespace AZ
Aabb MeshComponentController::GetLocalBounds()
{
const Data::Instance<RPI::Model> model = GetModel();
if (model)
if (m_meshHandle.IsValid() && m_meshFeatureProcessor)
{
Aabb aabb = model->GetAabb();
Aabb aabb = m_meshFeatureProcessor->GetLocalAabb(m_meshHandle);
aabb.MultiplyByScale(m_cachedNonUniformScale);
return aabb;
}