Merge remote-tracking branch 'upstream/development' into Atom/santorac/RemixableMaterialTypes2_FIX2

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2022-01-24 10:54:03 -08:00
408 changed files with 7668 additions and 3376 deletions
@@ -82,7 +82,6 @@ namespace AZ
->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage)
->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate);
}
}
bool MeshComponentConfig::IsAssetSet()
@@ -225,33 +224,42 @@ namespace AZ
{
}
static AzFramework::EntityContextId FindOwningContextId(const AZ::EntityId entityId)
{
AzFramework::EntityContextId contextId = AzFramework::EntityContextId::CreateNull();
AzFramework::EntityIdContextQueryBus::EventResult(
contextId, entityId, &AzFramework::EntityIdContextQueries::GetOwningContextId);
return contextId;
}
void MeshComponentController::Activate(const AZ::EntityComponentIdPair& entityComponentIdPair)
{
const AZ::EntityId entityId = entityComponentIdPair.GetEntityId();
m_entityComponentIdPair = entityComponentIdPair;
m_transformInterface = TransformBus::FindFirstHandler(entityId);
AZ_Warning("MeshComponentController", m_transformInterface, "Unable to attach to a TransformBus handler. This mesh will always be rendered at the origin.");
AZ_Warning(
"MeshComponentController", m_transformInterface,
"Unable to attach to a TransformBus handler. This mesh will always be rendered at the origin.");
m_meshFeatureProcessor = RPI::Scene::GetFeatureProcessorForEntity<MeshFeatureProcessorInterface>(entityId);
AZ_Error("MeshComponentController", m_meshFeatureProcessor, "Unable to find a MeshFeatureProcessorInterface on the entityId.");
m_cachedNonUniformScale = AZ::Vector3::CreateOne();
AZ::NonUniformScaleRequestBus::EventResult(m_cachedNonUniformScale, entityId, &AZ::NonUniformScaleRequests::GetScale);
AZ::NonUniformScaleRequestBus::Event(entityId, &AZ::NonUniformScaleRequests::RegisterScaleChangedEvent,
m_nonUniformScaleChangedHandler);
AZ::NonUniformScaleRequestBus::Event(
entityId, &AZ::NonUniformScaleRequests::RegisterScaleChangedEvent, m_nonUniformScaleChangedHandler);
const auto entityContextId = FindOwningContextId(entityId);
MeshComponentRequestBus::Handler::BusConnect(entityId);
TransformNotificationBus::Handler::BusConnect(entityId);
MaterialReceiverRequestBus::Handler::BusConnect(entityId);
MaterialComponentNotificationBus::Handler::BusConnect(entityId);
AzFramework::BoundsRequestBus::Handler::BusConnect(entityId);
AzFramework::EntityContextId contextId;
AzFramework::EntityIdContextQueryBus::EventResult(
contextId, entityId, &AzFramework::EntityIdContextQueries::GetOwningContextId);
AzFramework::RenderGeometry::IntersectionRequestBus::Handler::BusConnect({entityId, contextId});
AzFramework::RenderGeometry::IntersectionRequestBus::Handler::BusConnect({ entityId, entityContextId });
AzFramework::RenderGeometry::IntersectionNotificationBus::Bind(m_intersectionNotificationBus, entityContextId);
//Buses must be connected before RegisterModel in case requests are made as a result of HandleModelChange
// Buses must be connected before RegisterModel in case requests are made as a result of HandleModelChange
RegisterModel();
}
@@ -291,6 +299,11 @@ namespace AZ
{
m_meshFeatureProcessor->SetTransform(m_meshHandle, world, m_cachedNonUniformScale);
}
// ensure the render geometry is kept in sync with any changes to the entity the mesh is on
AzFramework::RenderGeometry::IntersectionNotificationBus::Event(
m_intersectionNotificationBus, &AzFramework::RenderGeometry::IntersectionNotificationBus::Events::OnGeometryChanged,
m_entityComponentIdPair.GetEntityId());
}
void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale)
@@ -301,7 +314,7 @@ namespace AZ
m_meshFeatureProcessor->SetTransform(m_meshHandle, m_transformInterface->GetWorldTM(), m_cachedNonUniformScale);
}
}
RPI::ModelMaterialSlotMap MeshComponentController::GetModelMaterialSlots() const
{
Data::Asset<const RPI::ModelAsset> modelAsset = GetModelAsset();
@@ -369,6 +382,9 @@ namespace AZ
MeshComponentNotificationBus::Event(entityId, &MeshComponentNotificationBus::Events::OnModelReady, m_configuration.m_modelAsset, model);
MaterialReceiverNotificationBus::Event(entityId, &MaterialReceiverNotificationBus::Events::OnMaterialAssignmentsChanged);
AZ::Interface<AzFramework::IEntityBoundsUnion>::Get()->RefreshEntityLocalBoundsUnion(entityId);
AzFramework::RenderGeometry::IntersectionNotificationBus::Event(
m_intersectionNotificationBus, &AzFramework::RenderGeometry::IntersectionNotificationBus::Events::OnGeometryChanged,
m_entityComponentIdPair.GetEntityId());
}
}
@@ -162,6 +162,8 @@ namespace AZ
bool m_isVisible = true;
MeshComponentConfig m_configuration;
AZ::Vector3 m_cachedNonUniformScale = AZ::Vector3::CreateOne();
//! Cached bus to use to notify RenderGeometry::Intersector the entity/component has changed.
AzFramework::RenderGeometry::IntersectionNotificationBus::BusPtr m_intersectionNotificationBus;
MeshFeatureProcessorInterface::ModelChangedEvent::Handler m_changeEventHandler
{
@@ -173,6 +175,5 @@ namespace AZ
[&](const AZ::Vector3& nonUniformScale) { HandleNonUniformScaleChange(nonUniformScale); }
};
};
} // namespace Render
} // namespace AZ