merging from main
This commit is contained in:
@@ -87,6 +87,12 @@ namespace AZ
|
||||
return values;
|
||||
}
|
||||
|
||||
MeshComponentController::~MeshComponentController()
|
||||
{
|
||||
// Release memory, disconnect from buses in the right order and broadcast events so that other components are aware.
|
||||
Deactivate();
|
||||
}
|
||||
|
||||
void MeshComponentController::Reflect(ReflectContext* context)
|
||||
{
|
||||
MeshComponentConfig::Reflect(context);
|
||||
@@ -130,11 +136,13 @@ namespace AZ
|
||||
void MeshComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC("MaterialReceiverService", 0x0d1a6a74));
|
||||
provided.push_back(AZ_CRC("MeshService", 0x71d8a455));
|
||||
}
|
||||
|
||||
void MeshComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC("MaterialReceiverService", 0x0d1a6a74));
|
||||
incompatible.push_back(AZ_CRC("MeshService", 0x71d8a455));
|
||||
}
|
||||
|
||||
// [GFX TODO] [ATOM-13339] Remove the ModelAsset id fix up function in MeshComponentController
|
||||
@@ -157,7 +165,7 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Failed to find asset id for [%s] ", modelAsset.GetHint().c_str());
|
||||
AZ_Error("MeshComponentController", false, "Failed to find asset id for [%s] ", modelAsset.GetHint().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,14 +205,15 @@ namespace AZ
|
||||
|
||||
void MeshComponentController::Deactivate()
|
||||
{
|
||||
// Buses must be disconnected after unregistering the model, otherwise they can't deliver the events during the process.
|
||||
UnregisterModel();
|
||||
|
||||
AzFramework::BoundsRequestBus::Handler::BusDisconnect();
|
||||
MeshComponentRequestBus::Handler::BusDisconnect();
|
||||
TransformNotificationBus::Handler::BusDisconnect();
|
||||
MaterialReceiverRequestBus::Handler::BusDisconnect();
|
||||
MaterialComponentNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
UnregisterModel();
|
||||
|
||||
m_meshFeatureProcessor = nullptr;
|
||||
m_transformInterface = nullptr;
|
||||
m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId);
|
||||
@@ -299,8 +308,9 @@ namespace AZ
|
||||
|
||||
void MeshComponentController::UnregisterModel()
|
||||
{
|
||||
if (m_meshFeatureProcessor)
|
||||
if (m_meshFeatureProcessor && m_meshHandle.IsValid())
|
||||
{
|
||||
MeshComponentNotificationBus::Event(m_entityId, &MeshComponentNotificationBus::Events::OnModelPreDestroy);
|
||||
m_meshFeatureProcessor->ReleaseMesh(m_meshHandle);
|
||||
}
|
||||
}
|
||||
@@ -338,7 +348,7 @@ namespace AZ
|
||||
|
||||
const Data::Asset<RPI::ModelAsset>& MeshComponentController::GetModelAsset() const
|
||||
{
|
||||
return m_configuration.m_modelAsset;
|
||||
return GetModel() ? GetModel()->GetModelAsset() : m_configuration.m_modelAsset;
|
||||
}
|
||||
|
||||
Data::AssetId MeshComponentController::GetModelAssetId() const
|
||||
|
||||
Reference in New Issue
Block a user