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
@@ -212,19 +212,26 @@ namespace AZ
void AtomActorInstance::SetModelAsset([[maybe_unused]] Data::Asset<RPI::ModelAsset> modelAsset)
{
// Atom Actor Instance is not based on an actual Model Asset yet,
// it's created at runtime from an Actor Asset.
// Changing model asset is not supported by Atom Actor Instance.
// The model asset is obtained from the Actor inside the ActorAsset,
// which is passed to the constructor. To set a different model asset
// this instance should use a different Actor.
AZ_Assert(false, "AtomActorInstance::SetModelAsset not supported");
}
const Data::Asset<RPI::ModelAsset>& AtomActorInstance::GetModelAsset() const
{
return m_skinnedMeshInstance->m_model->GetModelAsset();
AZ_Assert(GetActor(), "Expecting a Atom Actor Instance having a valid Actor.");
return GetActor()->GetMeshAsset();
}
void AtomActorInstance::SetModelAssetId([[maybe_unused]] Data::AssetId modelAssetId)
{
// Atom Actor Instance is not based on an actual Model Asset yet,
// it's created at runtime from an Actor Asset.
// Changing model asset is not supported by Atom Actor Instance.
// The model asset is obtained from the Actor inside the ActorAsset,
// which is passed to the constructor. To set a different model asset
// this instance should use a different Actor.
AZ_Assert(false, "AtomActorInstance::SetModelAssetId not supported");
}
Data::AssetId AtomActorInstance::GetModelAssetId() const
@@ -234,8 +241,11 @@ namespace AZ
void AtomActorInstance::SetModelAssetPath([[maybe_unused]] const AZStd::string& modelAssetPath)
{
// Atom Actor Instance is not based on an actual Model Asset yet,
// it's created at runtime from an Actor Asset.
// Changing model asset is not supported by Atom Actor Instance.
// The model asset is obtained from the Actor inside the ActorAsset,
// which is passed to the constructor. To set a different model asset
// this instance should use a different Actor.
AZ_Assert(false, "AtomActorInstance::SetModelAssetPath not supported");
}
AZStd::string AtomActorInstance::GetModelAssetPath() const
@@ -278,28 +288,6 @@ namespace AZ
return IsVisible();
}
void AtomActorInstance::SetMeshAsset(const AZ::Data::AssetId& id)
{
AZ::Data::Asset<EMotionFX::Integration::ActorAsset> asset =
AZ::Data::AssetManager::Instance().GetAsset<EMotionFX::Integration::ActorAsset>(
id, m_actorAsset.GetAutoLoadBehavior());
if (asset)
{
m_actorAsset = asset;
Create();
}
}
AZ::Data::Asset<AZ::Data::AssetData> AtomActorInstance::GetMeshAsset()
{
return m_actorAsset;
}
bool AtomActorInstance::GetVisibility()
{
return static_cast<const AtomActorInstance&>(*this).GetVisibility();
}
AZ::u32 AtomActorInstance::GetJointCount()
{
return m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes();
@@ -469,7 +457,6 @@ namespace AZ
TransformNotificationBus::Handler::BusConnect(m_entityId);
MaterialComponentNotificationBus::Handler::BusConnect(m_entityId);
MeshComponentRequestBus::Handler::BusConnect(m_entityId);
LmbrCentral::MeshComponentRequestBus::Handler::BusConnect(m_entityId);
const Data::Instance<RPI::Model> model = m_meshFeatureProcessor->GetModel(*m_meshHandle);
MeshComponentNotificationBus::Event(m_entityId, &MeshComponentNotificationBus::Events::OnModelReady, model->GetModelAsset(), model);
@@ -479,7 +466,6 @@ namespace AZ
{
MeshComponentNotificationBus::Event(m_entityId, &MeshComponentNotificationBus::Events::OnModelPreDestroy);
LmbrCentral::MeshComponentRequestBus::Handler::BusDisconnect();
MeshComponentRequestBus::Handler::BusDisconnect();
MaterialComponentNotificationBus::Handler::BusDisconnect();
TransformNotificationBus::Handler::BusDisconnect();