Cloth works with Actors in Atom. Cloth system uses MeshAssetHelper to read model mesh information for actors too.

This commit is contained in:
moraaar
2021-04-16 18:24:29 +01:00
parent 41eadd60e4
commit 808fd1d3ba
6 changed files with 41 additions and 67 deletions
@@ -448,9 +448,18 @@ namespace NvCloth
const auto& renderTangents = renderData.m_tangents;
const auto& renderBitangents = renderData.m_bitangents;
AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset;
AZ::Render::MeshComponentRequestBus::EventResult(
modelAsset, m_entityId, &AZ::Render::MeshComponentRequestBus::Events::GetModelAsset);
// Since Atom has a 1:1 relation with between ModelAsset buffers and Model buffers,
// internally it created a new asset for the model instance. So it's important to
// get the asset from the model when we want to write to them, instead of getting the
// ModelAsset directly from the bus (which returns the original asset shared by all entities).
AZ::Data::Instance<AZ::RPI::Model> model;
AZ::Render::MeshComponentRequestBus::EventResult(model, m_entityId, &AZ::Render::MeshComponentRequestBus::Events::GetModel);
if (!model)
{
return;
}
AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset = model->GetModelAsset();
if (!modelAsset.IsReady())
{
return;