diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp index c55f565615..d71358088e 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp @@ -986,6 +986,26 @@ namespace AZ handler.Connect(m_entityRemovedEvent); } + void ComponentApplication::RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler& handler) + { + handler.Connect(m_entityActivatedEvent); + } + + void ComponentApplication::RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler& handler) + { + handler.Connect(m_entityDeactivatedEvent); + } + + void ComponentApplication::SignalEntityActivated(AZ::Entity* entity) + { + m_entityActivatedEvent.Signal(entity); + } + + void ComponentApplication::SignalEntityDeactivated(AZ::Entity* entity) + { + m_entityDeactivatedEvent.Signal(entity); + } + //========================================================================= // AddEntity // [5/30/2012] diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h index 3ebcf39d95..0d9aad0f0f 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h @@ -204,6 +204,10 @@ namespace AZ void UnregisterComponentDescriptor(const ComponentDescriptor* descriptor) override final; void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler& handler) override final; void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler& handler) override final; + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler& handler) override final; + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler& handler) override final; + void SignalEntityActivated(AZ::Entity* entity) override final; + void SignalEntityDeactivated(AZ::Entity* entity) override final; bool AddEntity(Entity* entity) override; bool RemoveEntity(Entity* entity) override; bool DeleteEntity(const EntityId& id) override; @@ -385,6 +389,8 @@ namespace AZ AZStd::unique_ptr m_settingsRegistry; EntityAddedEvent m_entityAddedEvent; EntityRemovedEvent m_entityRemovedEvent; + EntityAddedEvent m_entityActivatedEvent; + EntityRemovedEvent m_entityDeactivatedEvent; AZ::IConsole* m_console{}; Descriptor m_descriptor; bool m_isStarted{ false }; diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h b/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h index 3582e6ebb8..c93f07f347 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h @@ -72,6 +72,8 @@ namespace AZ using EntityAddedEvent = AZ::Event; using EntityRemovedEvent = AZ::Event; + using EntityActivatedEvent = AZ::Event; + using EntityDeactivatedEvent = AZ::Event; //! Interface that components can use to make requests of the main application. class ComponentApplicationRequests @@ -102,6 +104,22 @@ namespace AZ //! @param handler the event handler to signal. virtual void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler& handler) = 0; + //! Registers an event handler that will be signalled whenever an entity is added. + //! @param handler the event handler to signal. + virtual void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler& handler) = 0; + + //! Registers an event handler that will be signalled whenever an entity is removed. + //! @param handler the event handler to signal. + virtual void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler& handler) = 0; + + //! Signals that the provided entity has been activated. + //! @param entity the entity being activated. + virtual void SignalEntityActivated(AZ::Entity* entity) = 0; + + //! Signals that the provided entity has been deactivated. + //! @param entity the entity being deactivated. + virtual void SignalEntityDeactivated(AZ::Entity* entity) = 0; + //! Adds an entity to the application's registry. //! Calling Init() on an entity automatically performs this operation. //! @param entity A pointer to the entity to add to the application's registry. diff --git a/Code/Framework/AzCore/AzCore/Component/Entity.cpp b/Code/Framework/AzCore/AzCore/Component/Entity.cpp index b18474e428..656fc5938f 100644 --- a/Code/Framework/AzCore/AzCore/Component/Entity.cpp +++ b/Code/Framework/AzCore/AzCore/Component/Entity.cpp @@ -216,12 +216,14 @@ namespace AZ EBUS_EVENT_ID(m_id, EntityBus, OnEntityActivated, m_id); EBUS_EVENT(EntitySystemBus, OnEntityActivated, m_id); + AZ::Interface::Get()->SignalEntityActivated(this); } void Entity::Deactivate() { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore); + AZ::Interface::Get()->SignalEntityDeactivated(this); EBUS_EVENT_ID(m_id, EntityBus, OnEntityDeactivated, m_id); EBUS_EVENT(EntitySystemBus, OnEntityDeactivated, m_id); diff --git a/Code/Framework/AzCore/AzCore/Console/LoggerSystemComponent.cpp b/Code/Framework/AzCore/AzCore/Console/LoggerSystemComponent.cpp index 6c142975e0..b19d4c7071 100644 --- a/Code/Framework/AzCore/AzCore/Console/LoggerSystemComponent.cpp +++ b/Code/Framework/AzCore/AzCore/Console/LoggerSystemComponent.cpp @@ -126,7 +126,7 @@ namespace AZ char buffer[MaxLogBufferSize]; const AZStd::size_t length = azvsnprintf(buffer, MaxLogBufferSize, format, args); - buffer[AZStd::min(length, MaxLogBufferSize - 2)] = '\n'; + //buffer[AZStd::min(length, MaxLogBufferSize - 2)] = '\n'; buffer[AZStd::min(length + 1, MaxLogBufferSize - 1)] = '\0'; switch (level) diff --git a/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h b/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h index e15071f56c..873bb5ad22 100644 --- a/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h +++ b/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h @@ -33,6 +33,10 @@ namespace UnitTest MOCK_METHOD1(UnregisterComponentDescriptor, void (const AZ::ComponentDescriptor*)); MOCK_METHOD1(RegisterEntityAddedEventHandler, void(AZ::EntityAddedEvent::Handler&)); MOCK_METHOD1(RegisterEntityRemovedEventHandler, void(AZ::EntityRemovedEvent::Handler&)); + MOCK_METHOD1(RegisterEntityActivatedEventHandler, void(AZ::EntityActivatedEvent::Handler&)); + MOCK_METHOD1(RegisterEntityDeactivatedEventHandler, void(AZ::EntityDeactivatedEvent::Handler&)); + MOCK_METHOD1(SignalEntityActivated, void(AZ::Entity*)); + MOCK_METHOD1(SignalEntityDeactivated, void(AZ::Entity*)); MOCK_METHOD1(RemoveEntity, bool (AZ::Entity*)); MOCK_METHOD1(DeleteEntity, bool (const AZ::EntityId&)); MOCK_METHOD1(GetEntityName, AZStd::string (const AZ::EntityId&)); diff --git a/Code/Framework/AzCore/Tests/BehaviorContextFixture.h b/Code/Framework/AzCore/Tests/BehaviorContextFixture.h index 687aee8aa4..0e2b67addd 100644 --- a/Code/Framework/AzCore/Tests/BehaviorContextFixture.h +++ b/Code/Framework/AzCore/Tests/BehaviorContextFixture.h @@ -49,9 +49,13 @@ namespace UnitTest // ComponentApplicationBus AZ::ComponentApplication* GetApplication() override { return nullptr; } void RegisterComponentDescriptor(const AZ::ComponentDescriptor*) override {} + void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override {} void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override {} void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override {} - void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override {} + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override {} + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override {} + void SignalEntityActivated(AZ::Entity* entity) override {} + void SignalEntityDeactivated(AZ::Entity* entity) override {} bool AddEntity(AZ::Entity*) override { return true; } bool RemoveEntity(AZ::Entity*) override { return true; } bool DeleteEntity(const AZ::EntityId&) override { return true; } diff --git a/Code/Framework/AzCore/Tests/Serialization.cpp b/Code/Framework/AzCore/Tests/Serialization.cpp index 35cf17c2e0..c1ce9f3d03 100644 --- a/Code/Framework/AzCore/Tests/Serialization.cpp +++ b/Code/Framework/AzCore/Tests/Serialization.cpp @@ -1232,6 +1232,10 @@ namespace UnitTest void UnregisterComponentDescriptor(const ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(Entity*) override { return false; } bool RemoveEntity(Entity*) override { return false; } bool DeleteEntity(const EntityId&) override { return false; } @@ -1252,6 +1256,7 @@ namespace UnitTest m_serializeContext.reset(aznew AZ::SerializeContext()); ComponentApplicationBus::Handler::BusConnect(); + AZ::Interface::Register(this); AZ::AllocatorInstance::Create(); AZ::AllocatorInstance::Create(); @@ -1270,6 +1275,7 @@ namespace UnitTest AZ::AllocatorInstance::Destroy(); AZ::AllocatorInstance::Destroy(); + AZ::Interface::Unregister(this); ComponentApplicationBus::Handler::BusDisconnect(); } diff --git a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp index 999013fdf8..461d578e28 100644 --- a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.cpp @@ -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(); diff --git a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h index 3f15027ac7..7e75ffffa6 100644 --- a/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h +++ b/Code/Framework/AzFramework/AzFramework/Entity/GameEntityContextComponent.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "EntityContext.h" @@ -90,6 +91,9 @@ namespace AzFramework { required.push_back(AZ_CRC("SliceSystemService", 0x1a5b7aad)); } + + private: + AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem; }; } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Render/Intersector.cpp b/Code/Framework/AzFramework/AzFramework/Render/Intersector.cpp index 1d55ec9711..c9d43b5446 100644 --- a/Code/Framework/AzFramework/AzFramework/Render/Intersector.cpp +++ b/Code/Framework/AzFramework/AzFramework/Render/Intersector.cpp @@ -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::Get()->FindEntity(entityId); + m_registeredEntities.Update({ entityId, CalculateEntityWorldBoundsUnion(entity) }); } m_dirtyEntities.clear(); diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/BoundsBus.h b/Code/Framework/AzFramework/AzFramework/Visibility/BoundsBus.h index 65c62c7e64..3ffe9990df 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/BoundsBus.h +++ b/Code/Framework/AzFramework/AzFramework/Visibility/BoundsBus.h @@ -12,6 +12,7 @@ #pragma once +#include #include #include #include @@ -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; //! 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 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 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 diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/EntityBoundsUnionBus.h b/Code/Framework/AzFramework/AzFramework/Visibility/EntityBoundsUnionBus.h index 4424cbcf60..99c575e3c9 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/EntityBoundsUnionBus.h +++ b/Code/Framework/AzFramework/AzFramework/Visibility/EntityBoundsUnionBus.h @@ -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; + // 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; } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp index e9b0d4609e..c03ab8b78d 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp +++ b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp @@ -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::Register(this); + IEntityBoundsUnionRequestBus::Handler::BusConnect(); AZ::TransformNotificationBus::Router::BusRouterConnect(); - AZ::EntitySystemBus::Handler::BusConnect(); AZ::TickBus::Handler::BusConnect(); + + AZ::Interface::Get()->RegisterEntityActivatedEventHandler(m_entityActivatedEventHandler); + AZ::Interface::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(); - } - - 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)); + AZ::Interface::Unregister(this); } - 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(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::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::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::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::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) - { - if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entityId); - 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) + for (const auto& entity : m_entityBoundsDirty) { - if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(dirtyEntityId); + if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity); 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::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); } } diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h index 56d6ba9670..27304a57b1 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h +++ b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h @@ -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; + using UniqueEntities = AZStd::set; using EntityVisibilityBoundsUnionInstanceMapping = - AZStd::unordered_map; + AZStd::unordered_map; + + 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 diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityQuery.cpp b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityQuery.cpp index fd119c8199..3d3d4bc65b 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityQuery.cpp +++ b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityQuery.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -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(visibilityEntry->m_userData)->GetId(); visibleEntityIdsOut.push_back(entityId); } }); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.cpp index 44c8487272..5237e7adf6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.cpp @@ -190,7 +190,7 @@ namespace AzToolsFramework EditorLegacyGameModeNotificationBus::Handler::BusConnect(); - m_entityVisibilityBoundsUnionSystem.Connect(); + //m_entityVisibilityBoundsUnionSystem.Connect(); } @@ -199,7 +199,7 @@ namespace AzToolsFramework //========================================================================= void EditorEntityContextComponent::Deactivate() { - m_entityVisibilityBoundsUnionSystem.Disconnect(); + //m_entityVisibilityBoundsUnionSystem.Disconnect(); EditorLegacyGameModeNotificationBus::Handler::BusDisconnect(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.h index 9a9a2dcff0..fb3276b5ac 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.h @@ -189,7 +189,7 @@ namespace AzToolsFramework AZ::ComponentTypeList m_requiredEditorComponentTypes; //! Edit time visibility management integrating entities with the IVisibilitySystem. - AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem; + //AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem; bool m_isLegacySliceService; UndoSystem::UndoCacheInterface* m_undoCacheInterface = nullptr; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index 7ce11e5957..459d3022ad 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -9,7 +9,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ - +#pragma optimize ("", off) #include "AzToolsFramework_precompiled.h" #include "TransformComponent.h" @@ -261,6 +261,7 @@ namespace AzToolsFramework AZ::TransformNotificationBus::Event( GetEntityId(), &TransformNotification::OnTransformChanged, localTM, worldTM); + m_transformChangedEvent.Signal(localTM, worldTM); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index f3abc70fba..5fd814367c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -68,6 +68,7 @@ namespace AzToolsFramework { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); + const AZ::Entity* entity = AZ::Interface::Get()->FindEntity(entityId); AzFramework::EntityDebugDisplayEventBus::Event( entityId, &AzFramework::EntityDebugDisplayEvents::DisplayEntityViewport, viewportInfo, debugDisplay); @@ -84,10 +85,9 @@ namespace AzToolsFramework if (ed_visibility_showAggregateEntityTransformedLocalBounds) { - AZ::Transform worldFromLocal = AZ::Transform::CreateIdentity(); - AZ::TransformBus::EventResult(worldFromLocal, entityId, &AZ::TransformBus::Events::GetWorldTM); + AZ::Transform worldFromLocal = entity->GetTransform()->GetWorldTM(); - if (const AZ::Aabb localAabb = AzFramework::CalculateEntityLocalBoundsUnion(entityId); localAabb.IsValid()) + if (const AZ::Aabb localAabb = AzFramework::CalculateEntityLocalBoundsUnion(entity); localAabb.IsValid()) { const AZ::Aabb worldAabb = localAabb.GetTransformedAabb(worldFromLocal); debugDisplay.SetColor(AZ::Colors::Turquoise); @@ -97,7 +97,7 @@ namespace AzToolsFramework if (ed_visibility_showAggregateEntityWorldBounds) { - if (const AZ::Aabb worldAabb = AzFramework::CalculateEntityWorldBoundsUnion(entityId); worldAabb.IsValid()) + if (const AZ::Aabb worldAabb = AzFramework::CalculateEntityWorldBoundsUnion(entity); worldAabb.IsValid()) { debugDisplay.SetColor(AZ::Colors::Magenta); debugDisplay.DrawWireBox(worldAabb.GetMin(), worldAabb.GetMax()); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp index 95095bd3c8..f3eac5ad18 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp @@ -13,7 +13,9 @@ #include "EditorSelectionUtil.h" #include +#include #include +#include #include #include #include @@ -28,7 +30,8 @@ namespace AzToolsFramework { if (Centered(pivot)) { - if (const AZ::Aabb localBound = AzFramework::CalculateEntityLocalBoundsUnion(entityId); + const AZ::Entity* entity = AZ::Interface::Get()->FindEntity(entityId); + if (const AZ::Aabb localBound = AzFramework::CalculateEntityLocalBoundsUnion(entity); localBound.IsValid()) { return localBound.GetCenter(); diff --git a/Code/Framework/AzToolsFramework/Tests/Visibility/EditorVisibilityTests.cpp b/Code/Framework/AzToolsFramework/Tests/Visibility/EditorVisibilityTests.cpp index 0b059594be..39b2d069e6 100644 --- a/Code/Framework/AzToolsFramework/Tests/Visibility/EditorVisibilityTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Visibility/EditorVisibilityTests.cpp @@ -9,7 +9,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ - +#pragma optimize("", off) #include #include #include @@ -62,8 +62,8 @@ namespace UnitTest SetupRowOfEntities(AZ::Vector3::CreateAxisX(-20.0f), AZ::Vector3::CreateAxisX(2.0f)); // request the entity union bounds system to update - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); // create default camera looking down the negative y-axis moved just back from the origin AzFramework::CameraState cameraState = AzFramework::CreateDefaultCamera( @@ -101,8 +101,8 @@ namespace UnitTest SetupRowOfEntities(AZ::Vector3::CreateAxisX(-20.0f), AZ::Vector3::CreateAxisX(2.0f)); // request the entity union bounds system to update - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); // create default camera looking down the negative x-axis moved along the x-axis and tilted slightly down AzFramework::CameraState cameraState = AzFramework::CreateDefaultCamera( @@ -143,15 +143,15 @@ namespace UnitTest SetupRowOfEntities(AZ::Vector3::CreateAxisX(-20.0f), AZ::Vector3::CreateAxisX(2.0f)); // request the entity union bounds system to update - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); const AZ::EntityId entityIdToMove = m_editorEntityIds[10]; AZ::TransformBus::Event( entityIdToMove, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3::CreateAxisZ(100.0f)); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); // create default camera looking down the negative y-axis moved just back from the origin AzFramework::CameraState cameraState = AzFramework::CreateDefaultCamera( @@ -241,8 +241,8 @@ namespace UnitTest { m_localAabb = localAabb; - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); } TEST_F(EditorVisibilityFixture, UpdatedBoundsIntersectingFrustumAddsVisibleEntity) @@ -264,8 +264,8 @@ namespace UnitTest entityId, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3(40.0f, -3.0f, 20.0f)); // request the entity union bounds system to update - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); // create default camera looking down the positive x-axis moved to position offset from world origin AzFramework::CameraState cameraState = AzFramework::CreateDefaultCamera( @@ -288,8 +288,8 @@ namespace UnitTest testBoundComponent->ChangeBounds(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-2.5f), AZ::Vector3(2.5f))); // perform an 'update' of the visibility system - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); + AzFramework::IEntityBoundsUnionRequestBus::Broadcast( + &AzFramework::IEntityBoundsUnionRequestBus::Events::ProcessEntityBoundsUnionRequests); entityVisibilityQuery.UpdateVisibility(cameraState); diff --git a/Code/Framework/Tests/ComponentAddRemove.cpp b/Code/Framework/Tests/ComponentAddRemove.cpp index e47b69c977..3815188269 100644 --- a/Code/Framework/Tests/ComponentAddRemove.cpp +++ b/Code/Framework/Tests/ComponentAddRemove.cpp @@ -1100,6 +1100,10 @@ namespace UnitTest void UnregisterComponentDescriptor(const ComponentDescriptor*) override {} void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler&) override {} void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler&) override {} + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override {} + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override {} + void SignalEntityActivated(AZ::Entity* entity) override {} + void SignalEntityDeactivated(AZ::Entity* entity) override {} bool AddEntity(Entity*) override { return true; } bool RemoveEntity(Entity*) override { return true; } bool DeleteEntity(const EntityId&) override { return true; } @@ -1125,6 +1129,7 @@ namespace UnitTest AllocatorsFixture::SetUp(); ComponentApplicationBus::Handler::BusConnect(); + AZ::Interface::Register(this); m_serializeContext.reset(aznew AZ::SerializeContext(true, true)); Entity::Reflect(m_serializeContext.get()); @@ -1139,6 +1144,7 @@ namespace UnitTest m_descriptors.set_capacity(0); m_serializeContext.reset(); + AZ::Interface::Unregister(this); ComponentApplicationBus::Handler::BusDisconnect(); AllocatorsFixture::TearDown(); diff --git a/Code/Framework/Tests/NetBindingMocks.h b/Code/Framework/Tests/NetBindingMocks.h index 3f280383f5..2af748e29c 100644 --- a/Code/Framework/Tests/NetBindingMocks.h +++ b/Code/Framework/Tests/NetBindingMocks.h @@ -278,6 +278,10 @@ namespace UnitTest MOCK_METHOD1(UnregisterComponentDescriptor, void (const AZ::ComponentDescriptor*)); MOCK_METHOD1(RegisterEntityAddedEventHandler, void(AZ::EntityAddedEvent::Handler&)); MOCK_METHOD1(RegisterEntityRemovedEventHandler, void(AZ::EntityRemovedEvent::Handler&)); + MOCK_METHOD1(RegisterEntityActivatedEventHandler, void(AZ::EntityActivatedEvent::Handler&)); + MOCK_METHOD1(RegisterEntityDeactivatedEventHandler, void(AZ::EntityDeactivatedEvent::Handler&)); + MOCK_METHOD1(SignalEntityActivated, void(AZ::Entity*)); + MOCK_METHOD1(SignalEntityDeactivated, void(AZ::Entity*)); MOCK_METHOD1(RemoveEntity, bool (AZ::Entity*)); MOCK_METHOD1(DeleteEntity, bool (const AZ::EntityId&)); MOCK_METHOD1(GetEntityName, AZStd::string (const AZ::EntityId&)); diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp index cb23e73b0e..b658df7ffa 100644 --- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp @@ -363,6 +363,10 @@ namespace AZ MOCK_METHOD1(UnregisterComponentDescriptor, void(const AZ::ComponentDescriptor*)); MOCK_METHOD1(RegisterEntityAddedEventHandler, void(AZ::EntityAddedEvent::Handler&)); MOCK_METHOD1(RegisterEntityRemovedEventHandler, void(AZ::EntityRemovedEvent::Handler&)); + MOCK_METHOD1(RegisterEntityActivatedEventHandler, void(AZ::EntityActivatedEvent::Handler&)); + MOCK_METHOD1(RegisterEntityDeactivatedEventHandler, void(AZ::EntityDeactivatedEvent::Handler&)); + MOCK_METHOD1(SignalEntityActivated, void(AZ::Entity*)); + MOCK_METHOD1(SignalEntityDeactivated, void(AZ::Entity*)); MOCK_METHOD1(RemoveEntity, bool(AZ::Entity*)); MOCK_METHOD1(DeleteEntity, bool(const AZ::EntityId&)); MOCK_METHOD1(GetEntityName, AZStd::string(const AZ::EntityId&)); diff --git a/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h b/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h index 51fe236171..dc746bae23 100644 --- a/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h +++ b/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h @@ -577,6 +577,10 @@ namespace AWSClientAuthUnitTest void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(AZ::Entity*) override { return true; } bool RemoveEntity(AZ::Entity*) override { return true; } bool DeleteEntity(const AZ::EntityId&) override { return true; } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp index c1795f7217..2a26c2a0ae 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp @@ -105,6 +105,10 @@ namespace UnitTest void UnregisterComponentDescriptor(const ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(Entity*) override { return false; } bool RemoveEntity(Entity*) override { return false; } bool DeleteEntity(const EntityId&) override { return false; } @@ -134,6 +138,7 @@ namespace UnitTest // Adding this handler to allow utility functions access the serialize context ComponentApplicationBus::Handler::BusConnect(); + AZ::Interface::Register(this); AZ::AllocatorInstance::Create(); AZ::AllocatorInstance::Create(); @@ -212,6 +217,7 @@ namespace UnitTest AZ::AllocatorInstance::Destroy(); AZ::AllocatorInstance::Destroy(); + AZ::Interface::Unregister(this); ComponentApplicationBus::Handler::BusDisconnect(); AllocatorsBase::TeardownAllocator(); } diff --git a/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.cpp b/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.cpp index 657657d07d..36598fb29f 100644 --- a/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.cpp +++ b/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.cpp @@ -75,6 +75,7 @@ namespace UnitTest // Adding this handler to allow utility functions access the serialize context ComponentApplicationBus::Handler::BusConnect(); + AZ::Interface::Register(this); // Startup default local FileIO (hits OSAllocator) if not already setup. if (IO::FileIOBase::GetInstance() == nullptr) @@ -113,6 +114,7 @@ namespace UnitTest delete IO::FileIOBase::GetInstance(); IO::FileIOBase::SetInstance(nullptr); + AZ::Interface::Unregister(this); ComponentApplicationBus::Handler::BusDisconnect(); m_jsonRegistrationContext->EnableRemoveReflection(); diff --git a/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h b/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h index 51282642aa..fbc39f6a40 100644 --- a/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h +++ b/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h @@ -41,6 +41,10 @@ namespace UnitTest void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(AZ::Entity*) override { return false; } bool RemoveEntity(AZ::Entity*) override { return false; } bool DeleteEntity(const AZ::EntityId&) override { return false; } diff --git a/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h b/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h index f400a171c5..55a226956a 100644 --- a/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h +++ b/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h @@ -38,6 +38,10 @@ namespace UnitTest void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(AZ::Entity*) override { return false; } bool RemoveEntity(AZ::Entity*) override { return false; } bool DeleteEntity(const AZ::EntityId&) override { return false; } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 9d2196de2b..ecd60be009 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -295,8 +295,7 @@ namespace AZ m_configuration.m_modelAsset = modelAsset; MeshComponentNotificationBus::Event(m_entityId, &MeshComponentNotificationBus::Events::OnModelReady, m_configuration.m_modelAsset, model); MaterialReceiverNotificationBus::Event(m_entityId, &MaterialReceiverNotificationBus::Events::OnMaterialAssignmentsChanged); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, m_entityId); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(m_entityId); } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp index 005e9a6ff5..8edac1f109 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp @@ -231,8 +231,7 @@ namespace AZ m_configuration.m_outerLength = dimensions.GetY(); m_configuration.m_outerHeight = dimensions.GetZ(); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, m_entityId); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(m_entityId); // clamp the inner extents to the outer extents m_configuration.m_innerWidth = AZStd::min(m_configuration.m_innerWidth, m_configuration.m_outerWidth); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index f8b638efaf..d0116452b7 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -82,8 +82,7 @@ namespace AZ // Update RenderActorInstance local bounding box m_localAABB = AZ::Aabb::CreateFromMinMax(m_actorInstance->GetStaticBasedAABB().GetMin(), m_actorInstance->GetStaticBasedAABB().GetMax()); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, m_entityId); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(m_entityId); } AZ::Aabb AtomActorInstance:: GetWorldBounds() diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp index e3de713b3c..94feb36e80 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp @@ -513,8 +513,7 @@ namespace EMotionFX { m_renderActorInstance->OnTick(deltaTime); m_renderActorInstance->UpdateBounds(); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); // Optimization: Set the actor instance invisible when character is out of camera view. This will stop the joint transforms update, except the root joint. // Calling it after the bounds on the render actor updated. diff --git a/Gems/ImGui/External/ImGui/v1.82/imgui/imgui.cpp b/Gems/ImGui/External/ImGui/v1.82/imgui/imgui.cpp index 2555d1a6af..c386766eef 100644 --- a/Gems/ImGui/External/ImGui/v1.82/imgui/imgui.cpp +++ b/Gems/ImGui/External/ImGui/v1.82/imgui/imgui.cpp @@ -759,7 +759,7 @@ CODE //------------------------------------------------------------------------- // [SECTION] INCLUDES //------------------------------------------------------------------------- - +#pragma optimize("", off) #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif @@ -7117,9 +7117,9 @@ static void ImGui::ErrorCheckEndFrameSanityChecks() // send key release events mid-frame. This would normally trigger this assertion and lead to sheared inputs. // We silently accommodate for this case by ignoring/ the case where all io.KeyXXX modifiers were released (aka key_mod_flags == 0), // while still correctly asserting on mid-frame key press events. - const ImGuiKeyModFlags key_mod_flags = GetMergedKeyModFlags(); - IM_ASSERT((key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); - IM_UNUSED(key_mod_flags); + //const ImGuiKeyModFlags key_mod_flags = GetMergedKeyModFlags(); + //IM_ASSERT((key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); + //IM_UNUSED(key_mod_flags); // Recover from errors //ErrorCheckEndFrameRecover(); diff --git a/Gems/ImageProcessing/Code/Tests/ImageProcessing_Test.cpp b/Gems/ImageProcessing/Code/Tests/ImageProcessing_Test.cpp index 1bef8e2fa3..d60dc20ef9 100644 --- a/Gems/ImageProcessing/Code/Tests/ImageProcessing_Test.cpp +++ b/Gems/ImageProcessing/Code/Tests/ImageProcessing_Test.cpp @@ -125,6 +125,10 @@ protected: void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(AZ::Entity*) override { return false; } bool RemoveEntity(AZ::Entity*) override { return false; } bool DeleteEntity(const AZ::EntityId&) override { return false; } diff --git a/Gems/LmbrCentral/Code/Source/Rendering/MeshComponent.cpp b/Gems/LmbrCentral/Code/Source/Rendering/MeshComponent.cpp index 0ee72b62cf..4bef29fb52 100644 --- a/Gems/LmbrCentral/Code/Source/Rendering/MeshComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Rendering/MeshComponent.cpp @@ -319,8 +319,7 @@ namespace LmbrCentral UpdateWorldTransform(transformHandler->GetWorldTM()); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); m_modificationHelper.Connect(id); } @@ -536,8 +535,7 @@ namespace LmbrCentral m_localBoundingBox.Add(m_statObj->GetAABB()); } - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); UpdateWorldBoundingBox(); } diff --git a/Gems/LmbrCentral/Code/Source/Shape/EditorBaseShapeComponent.cpp b/Gems/LmbrCentral/Code/Source/Shape/EditorBaseShapeComponent.cpp index df5c65e07c..cd21b1e855 100644 --- a/Gems/LmbrCentral/Code/Source/Shape/EditorBaseShapeComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Shape/EditorBaseShapeComponent.cpp @@ -12,7 +12,7 @@ #include "LmbrCentral_precompiled.h" #include "EditorBaseShapeComponent.h" - +#include #include #include @@ -214,8 +214,7 @@ namespace LmbrCentral { if (changeReason == ShapeChangeReasons::ShapeChanged) { - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); } } } // namespace LmbrCentral diff --git a/Gems/LmbrCentral/Code/Source/Shape/EditorSplineComponent.cpp b/Gems/LmbrCentral/Code/Source/Shape/EditorSplineComponent.cpp index 42c35b8cd9..71ed89a180 100644 --- a/Gems/LmbrCentral/Code/Source/Shape/EditorSplineComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Shape/EditorSplineComponent.cpp @@ -378,9 +378,7 @@ namespace LmbrCentral { SplineComponentNotificationBus::Event( GetEntityId(), &SplineComponentNotificationBus::Events::OnSplineChanged); - - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); } AZ::SplinePtr EditorSplineComponent::GetSpline() diff --git a/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp index 925f7512da..27cc326ff9 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp @@ -304,6 +304,10 @@ public: void UnregisterComponentDescriptor(const ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(Entity*) override { return true; } bool RemoveEntity(Entity*) override { return true; } bool DeleteEntity(const AZ::EntityId&) override { return true; } @@ -329,6 +333,7 @@ public: m_serializeContext = aznew SerializeContext(true, true); ComponentApplicationBus::Handler::BusConnect(); + AZ::Interface::Register(this); m_sliceDescriptor = SliceComponent::CreateDescriptor(); m_mockAssetDescriptor = MockAssetRefComponent::CreateDescriptor(); @@ -358,6 +363,7 @@ public: void TearDown() override { m_catalog->DisableCatalog(); + AZ::Interface::Unregister(this); ComponentApplicationBus::Handler::BusDisconnect(); Data::AssetManager::Destroy(); diff --git a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp index f6aa6b2de9..22f777a149 100644 --- a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp +++ b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp @@ -146,11 +146,11 @@ namespace Multiplayer } ); + NetworkEntityTracker* networkEntityTracker = GetNetworkEntityTracker(); + // Add all the neighbors for (AzFramework::VisibilityEntry* visEntry : gatheredEntries) { - // TODO: Discard entities that don't have a NetBindComponent - //if (mp_ControlledFilteredEntityComponent && mp_ControlledFilteredEntityComponent->IsEntityFiltered(iterator.Get())) //{ // continue; @@ -162,8 +162,12 @@ namespace Multiplayer const float gatherDistanceSquared = controlledEntityPosition.GetDistanceSq(closestPosition); const float priority = (gatherDistanceSquared > 0.0f) ? 1.0f / gatherDistanceSquared : 0.0f; AZ::Entity* entity = static_cast(visEntry->m_userData); - NetworkEntityHandle entityHandle(entity, GetNetworkEntityTracker()); - AddEntityToReplicationSet(entityHandle, priority, gatherDistanceSquared); + NetBindComponent* entryNetBindComponent = entity->template FindComponent(); + if (entryNetBindComponent != nullptr) + { + NetworkEntityHandle entityHandle(entryNetBindComponent, networkEntityTracker); + AddEntityToReplicationSet(entityHandle, priority, gatherDistanceSquared); + } } // Add in Autonomous Entities diff --git a/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp b/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp index ca7e2a3583..8545424ca7 100644 --- a/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp +++ b/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp @@ -82,6 +82,10 @@ protected: void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { } void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity* entity) override { } + void SignalEntityDeactivated(AZ::Entity* entity) override { } bool AddEntity(AZ::Entity*) override { return true; } bool RemoveEntity(AZ::Entity*) override { return true; } bool DeleteEntity(const AZ::EntityId&) override { return true; } diff --git a/Gems/Visibility/Code/Source/EditorOccluderAreaComponent.cpp b/Gems/Visibility/Code/Source/EditorOccluderAreaComponent.cpp index 9a88799a31..0521836e48 100644 --- a/Gems/Visibility/Code/Source/EditorOccluderAreaComponent.cpp +++ b/Gems/Visibility/Code/Source/EditorOccluderAreaComponent.cpp @@ -245,8 +245,7 @@ namespace Visibility const AZStd::string name = AZStd::string("OcclArea_") + GetEntity()->GetName(); GetIEditor()->Get3DEngine()->UpdateVisArea(m_area, &verts[0], verts.size(), name.c_str(), info, false); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); } } diff --git a/Gems/Visibility/Code/Source/EditorPortalComponent.cpp b/Gems/Visibility/Code/Source/EditorPortalComponent.cpp index 4e1b07991a..18f3f2fdb0 100644 --- a/Gems/Visibility/Code/Source/EditorPortalComponent.cpp +++ b/Gems/Visibility/Code/Source/EditorPortalComponent.cpp @@ -455,8 +455,7 @@ namespace Visibility GetIEditor()->Get3DEngine()->UpdateVisArea(m_area, &verts[0], verts.size(), name.c_str(), info, true); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); } } diff --git a/Gems/Visibility/Code/Source/EditorVisAreaComponent.cpp b/Gems/Visibility/Code/Source/EditorVisAreaComponent.cpp index 48045d9023..ddd18e2da8 100644 --- a/Gems/Visibility/Code/Source/EditorVisAreaComponent.cpp +++ b/Gems/Visibility/Code/Source/EditorVisAreaComponent.cpp @@ -349,8 +349,7 @@ namespace Visibility GetIEditor()->Get3DEngine()->UpdateVisArea(m_area, &points[0], points.size(), name.c_str(), info, true); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); } } } diff --git a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp index e88b4ce686..d4ab543404 100644 --- a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp +++ b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp @@ -414,8 +414,7 @@ namespace WhiteBox m_localAabb.reset(); m_faces.reset(); - AzFramework::EntityBoundsUnionRequestBus::Broadcast( - &AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId()); + AZ::Interface::Get()->RefreshEntityLocalBoundsUnion(GetEntityId()); // must have been created in Activate or have had the Entity made visible again if (m_renderMesh.has_value())