Removing some more ebus dependencies within the vis system
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Math/Sfmt.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
|
||||
@@ -173,7 +174,7 @@ namespace AZ
|
||||
//=========================================================================
|
||||
void ComponentDescriptor::ReleaseDescriptor()
|
||||
{
|
||||
EBUS_EVENT(ComponentApplicationBus, UnregisterComponentDescriptor, this);
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->UnregisterComponentDescriptor(this);
|
||||
delete this;
|
||||
}
|
||||
} // namespace AZ
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace AZ
|
||||
{
|
||||
EBUS_EVENT(EntitySystemBus, OnEntityDestruction, m_id);
|
||||
EBUS_EVENT_ID(m_id, EntityBus, OnEntityDestruction, m_id);
|
||||
EBUS_EVENT(ComponentApplicationBus, RemoveEntity, this);
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RemoveEntity(this);
|
||||
m_stateEvent.Signal(State::Init, State::Destroying);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
*/
|
||||
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <AzFramework/Visibility/EntityBoundsUnionBus.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
|
||||
@@ -694,8 +696,7 @@ namespace AzFramework
|
||||
}
|
||||
#endif
|
||||
|
||||
AZ::Entity* parentEntity = nullptr;
|
||||
EBUS_EVENT_RESULT(parentEntity, AZ::ComponentApplicationBus, FindEntity, parentEntityId);
|
||||
AZ::Entity* parentEntity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(parentEntityId);
|
||||
AZ_Assert(parentEntity, "We expect to have a parent entity associated with the provided parent's entity Id.");
|
||||
if (parentEntity)
|
||||
{
|
||||
@@ -744,8 +745,7 @@ namespace AzFramework
|
||||
m_parentId = parentId;
|
||||
if (m_parentId.IsValid())
|
||||
{
|
||||
AZ::Entity* parentEntity = nullptr;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(parentEntity, &AZ::ComponentApplicationBus::Events::FindEntity, m_parentId);
|
||||
AZ::Entity* parentEntity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(m_parentId);
|
||||
m_parentActive = parentEntity && (parentEntity->GetState() == AZ::Entity::State::Active);
|
||||
|
||||
m_onNewParentKeepWorldTM = isKeepWorldTM;
|
||||
@@ -832,6 +832,8 @@ namespace AzFramework
|
||||
|
||||
EBUS_EVENT_PTR(m_notificationBus, AZ::TransformNotificationBus, OnTransformChanged, m_localTM, m_worldTM);
|
||||
m_transformChangedEvent.Signal(m_localTM, m_worldTM);
|
||||
|
||||
AZ::Interface<AzFramework::IEntityBoundsUnion>::Get()->OnTransformUpdated(GetEntity());
|
||||
}
|
||||
|
||||
void TransformComponent::ComputeWorldTM()
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace AzFramework
|
||||
//! also be called explicitly (e.g. For testing purposes).
|
||||
virtual void ProcessEntityBoundsUnionRequests() = 0;
|
||||
|
||||
//! Notifies the EntityBoundsUnion system that an entities transform has been modified.
|
||||
//! @param entity the entity whose transform has been modified.
|
||||
virtual void OnTransformUpdated(AZ::Entity* entity) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~IEntityBoundsUnion() = default;
|
||||
};
|
||||
|
||||
+1
-6
@@ -28,7 +28,6 @@ namespace AzFramework
|
||||
{
|
||||
AZ::Interface<IEntityBoundsUnion>::Register(this);
|
||||
IEntityBoundsUnionRequestBus::Handler::BusConnect();
|
||||
AZ::TransformNotificationBus::Router::BusRouterConnect();
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityActivatedEventHandler(m_entityActivatedEventHandler);
|
||||
@@ -39,7 +38,6 @@ namespace AzFramework
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
IEntityBoundsUnionRequestBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Router::BusRouterDisconnect();
|
||||
AZ::Interface<IEntityBoundsUnion>::Unregister(this);
|
||||
}
|
||||
|
||||
@@ -156,13 +154,10 @@ namespace AzFramework
|
||||
m_entityBoundsDirty.clear();
|
||||
}
|
||||
|
||||
void EntityVisibilityBoundsUnionSystem::OnTransformChanged(const AZ::Transform&, const AZ::Transform&)
|
||||
void EntityVisibilityBoundsUnionSystem::OnTransformUpdated(AZ::Entity* entity)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
const AZ::EntityId entityId = *AZ::TransformNotificationBus::GetCurrentBusId();
|
||||
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(entity);
|
||||
instance_it != m_entityVisibilityBoundsUnionInstanceMapping.end())
|
||||
|
||||
+1
-4
@@ -24,7 +24,6 @@ namespace AzFramework
|
||||
//! Provide a unified hook between entities and the visibility system.
|
||||
class EntityVisibilityBoundsUnionSystem
|
||||
: public IEntityBoundsUnionRequestBus::Handler
|
||||
, private AZ::TransformNotificationBus::Router
|
||||
, private AZ::TickBus::Handler
|
||||
{
|
||||
public:
|
||||
@@ -37,6 +36,7 @@ namespace AzFramework
|
||||
void RefreshEntityLocalBoundsUnion(AZ::EntityId entityId) override;
|
||||
AZ::Aabb GetEntityLocalBoundsUnion(AZ::EntityId entityId) const override;
|
||||
void ProcessEntityBoundsUnionRequests() override;
|
||||
void OnTransformUpdated(AZ::Entity* entity) override;
|
||||
|
||||
private:
|
||||
struct EntityVisibilityBoundsUnionInstance
|
||||
@@ -55,9 +55,6 @@ namespace AzFramework
|
||||
// TickBus overrides ...
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
|
||||
// TransformNotificationBus overrides ...
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
void UpdateVisibilitySystem(AZ::Entity* entity, EntityVisibilityBoundsUnionInstance& instance);
|
||||
|
||||
EntityVisibilityBoundsUnionInstanceMapping m_entityVisibilityBoundsUnionInstanceMapping;
|
||||
|
||||
+8
-6
@@ -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"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <AzFramework/Visibility/EntityBoundsUnionBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
@@ -262,6 +263,8 @@ namespace AzToolsFramework
|
||||
AZ::TransformNotificationBus::Event(
|
||||
GetEntityId(), &TransformNotification::OnTransformChanged, localTM, worldTM);
|
||||
m_transformChangedEvent.Signal(localTM, worldTM);
|
||||
|
||||
AZ::Interface<AzFramework::IEntityBoundsUnion>::Get()->OnTransformUpdated(GetEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,15 +933,14 @@ namespace AzToolsFramework
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AZ::Entity* pEntity = nullptr;
|
||||
EBUS_EVENT_RESULT(pEntity, AZ::ComponentApplicationBus, FindEntity, otherEntityId);
|
||||
if (!pEntity)
|
||||
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(otherEntityId);
|
||||
if (!entity)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pEntity->FindComponent<TransformComponent>();
|
||||
return entity->FindComponent<TransformComponent>();
|
||||
}
|
||||
|
||||
AZ::TransformInterface* TransformComponent::GetParent()
|
||||
|
||||
Reference in New Issue
Block a user