Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Only update PhysX editor colliders if transform has actually changed #515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion dev/Gems/PhysX/Code/Source/EditorColliderComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ namespace PhysX
LmbrCentral::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
EditorColliderComponentRequestBus::Handler::BusConnect(AZ::EntityComponentIdPair(GetEntityId(), GetId()));

EBUS_EVENT_ID_RESULT(m_cachedWorldTm, GetEntityId(), AZ::TransformBus, GetWorldTM);

// Debug drawing
m_colliderDebugDraw.Connect(GetEntityId());
m_colliderDebugDraw.SetDisplayCallback(this);
Expand Down Expand Up @@ -819,8 +821,14 @@ namespace PhysX
return GetWorldTM().RetrieveScale();
}

void EditorColliderComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& /*world*/)
void EditorColliderComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
{
if (world.IsClose(m_cachedWorldTm))
{
return;
}
m_cachedWorldTm = world;

UpdateShapeConfigurationScale();
CreateStaticEditorCollider();
Physics::EditorWorldBus::Broadcast(&Physics::EditorWorldRequests::MarkEditorWorldDirty);
Expand Down
1 change: 1 addition & 0 deletions dev/Gems/PhysX/Code/Source/EditorColliderComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,6 @@ namespace PhysX
void ValidateMaterialSurfaces();

DebugDraw::Collider m_colliderDebugDraw;
AZ::Transform m_cachedWorldTm;
};
} // namespace PhysX
10 changes: 9 additions & 1 deletion dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ namespace PhysX
LmbrCentral::ShapeComponentNotificationsBus::Handler::BusConnect(GetEntityId());
PhysX::ColliderShapeRequestBus::Handler::BusConnect(GetEntityId());

EBUS_EVENT_ID_RESULT(m_cachedWorldTm, GetEntityId(), AZ::TransformBus, GetWorldTM);

bool refreshPropertyTree = true;
UpdateShapeConfigs(refreshPropertyTree);

Expand Down Expand Up @@ -642,8 +644,14 @@ namespace PhysX
}

// TransformBus
void EditorShapeColliderComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& /*world*/)
void EditorShapeColliderComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
{
if (world.IsClose(m_cachedWorldTm))
{
return;
}
m_cachedWorldTm = world;

bool refreshPropertyTree = false;
UpdateShapeConfigs(refreshPropertyTree);

Expand Down
1 change: 1 addition & 0 deletions dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,6 @@ namespace PhysX
//! @note 16 is the number of subdivisions in the debug cylinder that is loaded as a mesh (not generated procedurally)
AZ::u8 m_subdivisionCount = 16;
mutable GeometryCache m_geometryCache; //!< Cached data for generating sample points inside the attached shape.
AZ::Transform m_cachedWorldTm;
};
} // namespace PhysX