Changes to get visibility system working again in-game
This commit is contained in:
@@ -93,6 +93,8 @@ namespace AzFramework
|
||||
InitContext();
|
||||
|
||||
GameEntityContextRequestBus::Handler::BusConnect();
|
||||
|
||||
m_entityVisibilityBoundsUnionSystem.Connect();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -100,6 +102,8 @@ namespace AzFramework
|
||||
//=========================================================================
|
||||
void GameEntityContextComponent::Deactivate()
|
||||
{
|
||||
m_entityVisibilityBoundsUnionSystem.Disconnect();
|
||||
|
||||
GameEntityContextRequestBus::Handler::BusDisconnect();
|
||||
|
||||
DestroyContext();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzFramework/Entity/GameEntityContextBus.h>
|
||||
#include <AzFramework/Entity/SliceGameEntityOwnershipService.h>
|
||||
#include <AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h>
|
||||
|
||||
#include "EntityContext.h"
|
||||
|
||||
@@ -90,6 +91,9 @@ namespace AzFramework
|
||||
{
|
||||
required.push_back(AZ_CRC("SliceSystemService", 0x1a5b7aad));
|
||||
}
|
||||
|
||||
private:
|
||||
AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem;
|
||||
};
|
||||
} // namespace AzFramework
|
||||
|
||||
|
||||
@@ -138,7 +138,8 @@ namespace AzFramework
|
||||
"Implementers of IntersectionRequestBus must also implement BoundsRequestBus to ensure valid "
|
||||
"bounds are returned");
|
||||
|
||||
m_registeredEntities.Update({ entityId, CalculateEntityWorldBoundsUnion(entityId) });
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
m_registeredEntities.Update({ entityId, CalculateEntityWorldBoundsUnion(entity) });
|
||||
}
|
||||
|
||||
m_dirtyEntities.clear();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Render/GeometryIntersectionStructures.h>
|
||||
@@ -27,7 +28,8 @@ namespace AZ
|
||||
namespace AzFramework
|
||||
{
|
||||
//! Implemented by components that provide bounds for use with various systems.
|
||||
class BoundsRequests : public AZ::ComponentBus
|
||||
class BoundsRequests
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
@@ -37,6 +39,7 @@ namespace AzFramework
|
||||
//! more than one component may be providing a bound. It isn't guaranteed which bound
|
||||
//! will be returned by a single call to GetWorldBounds.
|
||||
virtual AZ::Aabb GetWorldBounds() = 0;
|
||||
|
||||
//! Returns an axis aligned bounding box in local space.
|
||||
//! @note It is preferred to use CalculateEntityLocalBoundsUnion in the general case as
|
||||
//! more than one component may be providing a bound. It isn't guaranteed which bound
|
||||
@@ -46,17 +49,15 @@ namespace AzFramework
|
||||
protected:
|
||||
~BoundsRequests() = default;
|
||||
};
|
||||
|
||||
using BoundsRequestBus = AZ::EBus<BoundsRequests>;
|
||||
|
||||
//! Returns a union of all local Aabbs provided by components implementing the BoundsRequestBus.
|
||||
//! @note It is preferred to call this function as opposed to GetLocalBounds directly as more than one
|
||||
//! component may be implementing this bus on an Entity and so only the first result (Aabb) will be returned.
|
||||
inline AZ::Aabb CalculateEntityLocalBoundsUnion(const AZ::EntityId entityId)
|
||||
inline AZ::Aabb CalculateEntityLocalBoundsUnion(const AZ::Entity* entity)
|
||||
{
|
||||
AZ::EBusReduceResult<AZ::Aabb, AabbUnionAggregator> aabbResult(AZ::Aabb::CreateNull());
|
||||
BoundsRequestBus::EventResult(
|
||||
aabbResult, entityId, &BoundsRequestBus::Events::GetLocalBounds);
|
||||
BoundsRequestBus::EventResult(aabbResult, entity->GetId(), &BoundsRequestBus::Events::GetLocalBounds);
|
||||
|
||||
if (aabbResult.value.IsValid())
|
||||
{
|
||||
@@ -69,18 +70,18 @@ namespace AzFramework
|
||||
//! Returns a union of all world Aabbs provided by components implementing the BoundsRequestBus.
|
||||
//! @note It is preferred to call this function as opposed to GetWorldBounds directly as more than one
|
||||
//! component may be implementing this bus on an Entity and so only the first result (Aabb) will be returned.
|
||||
inline AZ::Aabb CalculateEntityWorldBoundsUnion(const AZ::EntityId entityId)
|
||||
inline AZ::Aabb CalculateEntityWorldBoundsUnion(const AZ::Entity* entity)
|
||||
{
|
||||
AZ::EBusReduceResult<AZ::Aabb, AabbUnionAggregator> aabbResult(AZ::Aabb::CreateNull());
|
||||
BoundsRequestBus::EventResult(aabbResult, entityId, &BoundsRequestBus::Events::GetWorldBounds);
|
||||
BoundsRequestBus::EventResult(aabbResult, entity->GetId(), &BoundsRequestBus::Events::GetWorldBounds);
|
||||
|
||||
if (aabbResult.value.IsValid())
|
||||
{
|
||||
return aabbResult.value;
|
||||
}
|
||||
|
||||
AZ::Vector3 worldTranslation = AZ::Vector3::CreateZero();
|
||||
AZ::TransformBus::EventResult(worldTranslation, entityId, &AZ::TransformBus::Events::GetWorldTranslation);
|
||||
AZ::TransformInterface* transformInterface = entity->GetTransform();
|
||||
const AZ::Vector3 worldTranslation = transformInterface->GetWorldTranslation();
|
||||
return AZ::Aabb::CreateCenterHalfExtents(worldTranslation, AZ::Vector3(0.5f));
|
||||
}
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -23,9 +23,11 @@ namespace AzFramework
|
||||
{
|
||||
//! Provides an interface to retrieve and update the union of all Aabbs on a single Entity.
|
||||
//! @note This will be the combination/union of all individual Component Aabbs.
|
||||
class EntityBoundsUnionRequests : public AZ::EBusTraits
|
||||
class IEntityBoundsUnion
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(IEntityBoundsUnion, "{106968DD-43C0-478E-8045-523E0BF5D0F5}");
|
||||
|
||||
//! Requests the cached union of component Aabbs to be recalculated as one may have changed.
|
||||
//! @note This is used to drive event driven updates to the visibility system.
|
||||
virtual void RefreshEntityLocalBoundsUnion(AZ::EntityId entityId) = 0;
|
||||
@@ -39,8 +41,16 @@ namespace AzFramework
|
||||
virtual void ProcessEntityBoundsUnionRequests() = 0;
|
||||
|
||||
protected:
|
||||
~EntityBoundsUnionRequests() = default;
|
||||
virtual ~IEntityBoundsUnion() = default;
|
||||
};
|
||||
|
||||
using EntityBoundsUnionRequestBus = AZ::EBus<EntityBoundsUnionRequests>;
|
||||
// EBus wrapper for ScriptCanvas
|
||||
class IEntityBoundsUnionTraits
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
};
|
||||
using IEntityBoundsUnionRequestBus = AZ::EBus<IEntityBoundsUnion, IEntityBoundsUnionTraits>;
|
||||
} // namespace AzFramework
|
||||
|
||||
+56
-61
@@ -17,69 +17,69 @@
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
EntityVisibilityBoundsUnionSystem::EntityVisibilityBoundsUnionSystem()
|
||||
: m_entityActivatedEventHandler([this](AZ::Entity* entity) { OnEntityActivated(entity); })
|
||||
, m_entityDeactivatedEventHandler([this](AZ::Entity* entity) { OnEntityDeactivated(entity); })
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::Connect()
|
||||
{
|
||||
EntityBoundsUnionRequestBus::Handler::BusConnect();
|
||||
AZ::Interface<IEntityBoundsUnion>::Register(this);
|
||||
IEntityBoundsUnionRequestBus::Handler::BusConnect();
|
||||
AZ::TransformNotificationBus::Router::BusRouterConnect();
|
||||
AZ::EntitySystemBus::Handler::BusConnect();
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityActivatedEventHandler(m_entityActivatedEventHandler);
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityDeactivatedEventHandler(m_entityDeactivatedEventHandler);
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::Disconnect()
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
AZ::EntitySystemBus::Handler::BusDisconnect();
|
||||
IEntityBoundsUnionRequestBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Router::BusRouterDisconnect();
|
||||
EntityBoundsUnionRequestBus::Handler::BusDisconnect();
|
||||
AZ::Interface<IEntityBoundsUnion>::Unregister(this);
|
||||
}
|
||||
|
||||
static void SetUserDataEntityId(VisibilityEntry& visibilityEntry, const AZ::EntityId entityId)
|
||||
{
|
||||
static_assert(
|
||||
sizeof(AZ::EntityId) <= sizeof(visibilityEntry.m_userData), "Ensure EntityId fits into m_userData");
|
||||
|
||||
visibilityEntry.m_typeFlags = VisibilityEntry::TYPE_Entity;
|
||||
|
||||
std::memcpy(&visibilityEntry.m_userData, &entityId, sizeof(AZ::EntityId));
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::OnEntityActivated(const AZ::EntityId& entityId)
|
||||
void EntityVisibilityBoundsUnionSystem::OnEntityActivated(AZ::Entity* entity)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
// ignore any entity that might activate which does not have a TransformComponent
|
||||
if (!AZ::TransformBus::HasHandlers(entityId))
|
||||
if (entity->GetTransform() == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entityId);
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity);
|
||||
instance_it == m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
{
|
||||
AZ::Transform worldFromLocal = AZ::Transform::CreateIdentity();
|
||||
AZ::TransformBus::EventResult(worldFromLocal, entityId, &AZ::TransformBus::Events::GetWorldTM);
|
||||
AZ::TransformInterface* transformInterface = entity->GetTransform();
|
||||
const AZ::Vector3 entityPosition = transformInterface->GetWorldTranslation();
|
||||
|
||||
EntityVisibilityBoundsUnionInstance instance;
|
||||
instance.m_worldTransform = worldFromLocal;
|
||||
instance.m_localEntityBoundsUnion = CalculateEntityLocalBoundsUnion(entityId);
|
||||
SetUserDataEntityId(instance.m_visibilityEntry, entityId);
|
||||
instance.m_localEntityBoundsUnion = CalculateEntityLocalBoundsUnion(entity);
|
||||
instance.m_visibilityEntry.m_typeFlags = VisibilityEntry::TYPE_Entity;
|
||||
instance.m_visibilityEntry.m_userData = static_cast<void*>(entity);
|
||||
|
||||
auto next_it = m_entityVisibilityBoundsUnionInstanceMapping.insert({entityId, instance});
|
||||
UpdateVisibilitySystem(next_it.first->second);
|
||||
auto next_it = m_entityVisibilityBoundsUnionInstanceMapping.insert({ entity, instance });
|
||||
UpdateVisibilitySystem(entity, next_it.first->second);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::OnEntityDeactivated(const AZ::EntityId& entityId)
|
||||
void EntityVisibilityBoundsUnionSystem::OnEntityDeactivated(AZ::Entity* entity)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
// ignore any entity that might deactivate which does not have a TransformComponent
|
||||
if (!AZ::TransformBus::HasHandlers(entityId))
|
||||
// ignore any entity that might activate which does not have a TransformComponent
|
||||
if (entity->GetTransform() == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entityId);
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
{
|
||||
if (IVisibilitySystem* visibilitySystem = AZ::Interface<IVisibilitySystem>::Get())
|
||||
@@ -90,7 +90,7 @@ namespace AzFramework
|
||||
}
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::UpdateVisibilitySystem(EntityVisibilityBoundsUnionInstance& instance)
|
||||
void EntityVisibilityBoundsUnionSystem::UpdateVisibilitySystem(AZ::Entity* entity, EntityVisibilityBoundsUnionInstance& instance)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
@@ -98,8 +98,8 @@ namespace AzFramework
|
||||
{
|
||||
// note: worldEntityBounds will not be a 'tight-fit' Aabb but that of a transformed local aabb
|
||||
// there will be some wasted space but it should be sufficient for the visibility system
|
||||
const AZ::Aabb worldEntityBoundsUnion =
|
||||
localEntityBoundsUnions.GetTransformedAabb(instance.m_worldTransform);
|
||||
AZ::TransformInterface* transformInterface = entity->GetTransform();
|
||||
const AZ::Aabb worldEntityBoundsUnion = localEntityBoundsUnions.GetTransformedAabb(transformInterface->GetWorldTM());
|
||||
IVisibilitySystem* visibilitySystem = AZ::Interface<IVisibilitySystem>::Get();
|
||||
if (visibilitySystem && !worldEntityBoundsUnion.IsClose(instance.m_visibilityEntry.m_boundingVolume))
|
||||
{
|
||||
@@ -111,19 +111,27 @@ namespace AzFramework
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::RefreshEntityLocalBoundsUnion(const AZ::EntityId entityId)
|
||||
{
|
||||
// track entities that need their bounds union to be recalculated
|
||||
m_entityIdsBoundsDirty.insert(entityId);
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
if (entity != nullptr)
|
||||
{
|
||||
// track entities that need their bounds union to be recalculated
|
||||
m_entityBoundsDirty.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Aabb EntityVisibilityBoundsUnionSystem::GetEntityLocalBoundsUnion(const AZ::EntityId entityId) const
|
||||
{
|
||||
// if the EntityId 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(entityId);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
if (entity != nullptr)
|
||||
{
|
||||
return instance_it->second.m_localEntityBoundsUnion;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
return AZ::Aabb::CreateNull();
|
||||
@@ -134,45 +142,32 @@ namespace AzFramework
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
// iterate over all entities whose bounds changed and recalculate them
|
||||
for (const auto& entityId : m_entityIdsBoundsDirty)
|
||||
for (const auto& entity : m_entityBoundsDirty)
|
||||
{
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entityId);
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
{
|
||||
instance_it->second.m_localEntityBoundsUnion = CalculateEntityLocalBoundsUnion(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
auto allDirtyEntityIds = m_entityIdsTransformDirty;
|
||||
allDirtyEntityIds.insert(m_entityIdsBoundsDirty.begin(), m_entityIdsBoundsDirty.end());
|
||||
|
||||
for (const auto& dirtyEntityId : allDirtyEntityIds)
|
||||
{
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(dirtyEntityId);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
{
|
||||
UpdateVisibilitySystem(instance_it->second);
|
||||
instance_it->second.m_localEntityBoundsUnion = CalculateEntityLocalBoundsUnion(entity);
|
||||
UpdateVisibilitySystem(entity, instance_it->second);
|
||||
}
|
||||
}
|
||||
|
||||
// clear dirty entities once the visibility system has been updated
|
||||
m_entityIdsBoundsDirty.clear();
|
||||
m_entityIdsTransformDirty.clear();
|
||||
m_entityBoundsDirty.clear();
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::OnTransformChanged(
|
||||
[[maybe_unused]] const AZ::Transform& local, const AZ::Transform& world)
|
||||
void EntityVisibilityBoundsUnionSystem::OnTransformChanged(const AZ::Transform&, const AZ::Transform&)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
const AZ::EntityId entityId = *AZ::TransformNotificationBus::GetCurrentBusId();
|
||||
m_entityIdsTransformDirty.insert(entityId);
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
|
||||
// update the world transform of the visibility bounds union
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entityId);
|
||||
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
{
|
||||
instance_it->second.m_worldTransform = world;
|
||||
UpdateVisibilitySystem(entity, instance_it->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -23,12 +23,13 @@ namespace AzFramework
|
||||
{
|
||||
//! Provide a unified hook between entities and the visibility system.
|
||||
class EntityVisibilityBoundsUnionSystem
|
||||
: public EntityBoundsUnionRequestBus::Handler
|
||||
, private AZ::EntitySystemBus::Handler
|
||||
: public IEntityBoundsUnionRequestBus::Handler
|
||||
, private AZ::TransformNotificationBus::Router
|
||||
, private AZ::TickBus::Handler
|
||||
{
|
||||
public:
|
||||
EntityVisibilityBoundsUnionSystem();
|
||||
|
||||
void Connect();
|
||||
void Disconnect();
|
||||
|
||||
@@ -40,30 +41,29 @@ namespace AzFramework
|
||||
private:
|
||||
struct EntityVisibilityBoundsUnionInstance
|
||||
{
|
||||
AZ::Transform m_worldTransform = AZ::Transform::CreateIdentity(); //!< The world transform of the Entity.
|
||||
AZ::Aabb m_localEntityBoundsUnion =
|
||||
AZ::Aabb::CreateNull(); //!< Entity union bounding volume in local space.
|
||||
AZ::Aabb m_localEntityBoundsUnion = AZ::Aabb::CreateNull(); //!< Entity union bounding volume in local space.
|
||||
VisibilityEntry m_visibilityEntry; //!< Hook into the IVisibilitySystem interface.
|
||||
};
|
||||
|
||||
using UniqueEntityIds = AZStd::unordered_set<AZ::EntityId>;
|
||||
using UniqueEntities = AZStd::set<AZ::Entity*>;
|
||||
using EntityVisibilityBoundsUnionInstanceMapping =
|
||||
AZStd::unordered_map<AZ::EntityId, EntityVisibilityBoundsUnionInstance>;
|
||||
AZStd::unordered_map<AZ::Entity*, EntityVisibilityBoundsUnionInstance>;
|
||||
|
||||
void OnEntityActivated(AZ::Entity* entity);
|
||||
void OnEntityDeactivated(AZ::Entity* entity);
|
||||
|
||||
// TickBus overrides ...
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
|
||||
// EntitySystemBus overrides ...
|
||||
void OnEntityActivated(const AZ::EntityId& entityId) override;
|
||||
void OnEntityDeactivated(const AZ::EntityId& entityId) override;
|
||||
|
||||
// TransformNotificationBus overrides ...
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
void UpdateVisibilitySystem(EntityVisibilityBoundsUnionInstance& instance);
|
||||
void UpdateVisibilitySystem(AZ::Entity* entity, EntityVisibilityBoundsUnionInstance& instance);
|
||||
|
||||
EntityVisibilityBoundsUnionInstanceMapping m_entityVisibilityBoundsUnionInstanceMapping;
|
||||
UniqueEntityIds m_entityIdsBoundsDirty;
|
||||
UniqueEntityIds m_entityIdsTransformDirty;
|
||||
UniqueEntities m_entityBoundsDirty;
|
||||
|
||||
AZ::EntityActivatedEvent::Handler m_entityActivatedEventHandler;
|
||||
AZ::EntityDeactivatedEvent::Handler m_entityDeactivatedEventHandler;
|
||||
};
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <AzCore/Console/Console.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Math/ShapeIntersection.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <AzFramework/Visibility/IVisibilitySystem.h>
|
||||
@@ -66,6 +67,7 @@ namespace AzFramework
|
||||
octreeDebug.m_nodeBounds.push_back(nodeData.m_bounds);
|
||||
}
|
||||
|
||||
visibleEntityIdsOut.reserve(visibleEntityIdsOut.size() + nodeData.m_entries.size());
|
||||
for (const auto* visibilityEntry : nodeData.m_entries)
|
||||
{
|
||||
if (ed_visibility_showDebug)
|
||||
@@ -88,8 +90,7 @@ namespace AzFramework
|
||||
octreeDebug.m_entryAabbsInFrustum.push_back(visibilityEntry->m_boundingVolume);
|
||||
}
|
||||
|
||||
AZ::EntityId entityId;
|
||||
std::memcpy(&entityId, &visibilityEntry->m_userData, sizeof(AZ::EntityId));
|
||||
AZ::EntityId entityId = static_cast<AZ::Entity*>(visibilityEntry->m_userData)->GetId();
|
||||
visibleEntityIdsOut.push_back(entityId);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user