Add MeshReference to ModelInstanceActor for easy mesh referencing and its data access interface

This commit is contained in:
Wojtek Figat
2023-06-29 16:50:00 +02:00
parent 656866c1d4
commit e3cbe1458d
6 changed files with 394 additions and 2 deletions

View File

@@ -945,6 +945,18 @@ bool AnimatedModel::IntersectsEntry(const Ray& ray, Real& distance, Vector3& nor
return result;
}
bool AnimatedModel::GetMeshData(const MeshReference& mesh, MeshBufferType type, BytesContainer& result, int32& count) const
{
count = 0;
if (mesh.LODIndex < 0 || mesh.MeshIndex < 0)
return true;
const auto model = SkinnedModel.Get();
if (!model || model->WaitForLoaded())
return true;
auto& lod = model->LODs[Math::Min(mesh.LODIndex, model->LODs.Count() - 1)];
return lod.Meshes[Math::Min(mesh.MeshIndex, lod.Meshes.Count() - 1)].DownloadDataCPU(type, result, count);
}
void AnimatedModel::OnDeleteObject()
{
// Ensure this object is no longer referenced for anim update