diff --git a/dev/Gems/PhysX/Code/Source/EditorColliderComponent.cpp b/dev/Gems/PhysX/Code/Source/EditorColliderComponent.cpp index 23ccee06d1..2177598e20 100644 --- a/dev/Gems/PhysX/Code/Source/EditorColliderComponent.cpp +++ b/dev/Gems/PhysX/Code/Source/EditorColliderComponent.cpp @@ -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); @@ -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); diff --git a/dev/Gems/PhysX/Code/Source/EditorColliderComponent.h b/dev/Gems/PhysX/Code/Source/EditorColliderComponent.h index d59b213362..aa9c02e6bc 100644 --- a/dev/Gems/PhysX/Code/Source/EditorColliderComponent.h +++ b/dev/Gems/PhysX/Code/Source/EditorColliderComponent.h @@ -235,5 +235,6 @@ namespace PhysX void ValidateMaterialSurfaces(); DebugDraw::Collider m_colliderDebugDraw; + AZ::Transform m_cachedWorldTm; }; } // namespace PhysX diff --git a/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp b/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp index 9e050aaf28..b16722ee8a 100644 --- a/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp +++ b/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp @@ -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); @@ -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); diff --git a/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.h b/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.h index bd8f840594..e25c6a3cbc 100644 --- a/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.h +++ b/dev/Gems/PhysX/Code/Source/EditorShapeColliderComponent.h @@ -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