@@ -28,9 +28,12 @@ namespace AzFramework
|
||||
//! @note This is used to drive event driven updates to the visibility system.
|
||||
virtual void RefreshEntityLocalBoundsUnion(AZ::EntityId entityId) = 0;
|
||||
|
||||
//! Returns the cached union of all component Aabbs.
|
||||
//! Returns the cached union of all component Aabbs in local entity space.
|
||||
virtual AZ::Aabb GetEntityLocalBoundsUnion(AZ::EntityId entityId) const = 0;
|
||||
|
||||
//! Returns the cached union of all component Aabbs in world space.
|
||||
virtual AZ::Aabb GetEntityWorldBoundsUnion(AZ::EntityId entityId) const = 0;
|
||||
|
||||
//! Writes the current changes made to all entities (transforms and bounds) to the visibility system.
|
||||
//! @note During normal operation this is called every frame in OnTick but can
|
||||
//! also be called explicitly (e.g. For testing purposes).
|
||||
|
||||
+18
@@ -128,6 +128,24 @@ namespace AzFramework
|
||||
return AZ::Aabb::CreateNull();
|
||||
}
|
||||
|
||||
AZ::Aabb EntityVisibilityBoundsUnionSystem::GetEntityWorldBoundsUnion(const AZ::EntityId entityId) const
|
||||
{
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
if (entity != nullptr)
|
||||
{
|
||||
// if the entity is not found in the mapping then return a null Aabb, this is to mimic
|
||||
// as closely as possible the behavior of an individual GetLocalBounds call to an Entity that
|
||||
// had been deleted (there would be no response, leaving the default value assigned)
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
{
|
||||
return instance_it->second.m_localEntityBoundsUnion.GetTranslated(entity->GetTransform()->GetWorldTranslation());
|
||||
}
|
||||
}
|
||||
|
||||
return AZ::Aabb::CreateNull();
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::ProcessEntityBoundsUnionRequests()
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AzFramework);
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace AzFramework
|
||||
// EntityBoundsUnionRequestBus overrides ...
|
||||
void RefreshEntityLocalBoundsUnion(AZ::EntityId entityId) override;
|
||||
AZ::Aabb GetEntityLocalBoundsUnion(AZ::EntityId entityId) const override;
|
||||
AZ::Aabb GetEntityWorldBoundsUnion(AZ::EntityId entityId) const override;
|
||||
void ProcessEntityBoundsUnionRequests() override;
|
||||
void OnTransformUpdated(AZ::Entity* entity) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user