Browse Source

combined the 2 physics shape collider config pair types into 1(#778)

amzn-sean 4 năm trước cách đây
mục cha
commit
672dad7fea
41 tập tin đã thay đổi với 225 bổ sung184 xóa
  1. 2 1
      Code/Framework/AzFramework/AzFramework/Physics/Character.h
  2. 6 4
      Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp
  3. 4 1
      Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h
  4. 0 3
      Code/Framework/AzFramework/AzFramework/Physics/Shape.h
  5. 1 1
      Gems/Blast/Code/Source/Actor/ShapesProvider.cpp
  6. 1 1
      Gems/Blast/Code/Source/Actor/ShapesProvider.h
  7. 7 7
      Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.cpp
  8. 1 1
      Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.h
  9. 8 6
      Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.cpp
  10. 3 3
      Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.h
  11. 2 2
      Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp
  12. 2 2
      Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h
  13. 7 7
      Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.cpp
  14. 4 4
      Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.h
  15. 2 2
      Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.cpp
  16. 1 1
      Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.h
  17. 1 1
      Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp
  18. 1 1
      Gems/EMotionFX/Code/Tests/ColliderCommandTests.cpp
  19. 1 1
      Gems/EMotionFX/Code/Tests/PhysicsSetupUtils.cpp
  20. 1 1
      Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp
  21. 1 1
      Gems/PhysX/Code/Include/PhysX/ColliderComponentBus.h
  22. 1 1
      Gems/PhysX/Code/Include/PhysX/MeshAsset.h
  23. 3 3
      Gems/PhysX/Code/Source/BaseColliderComponent.cpp
  24. 3 3
      Gems/PhysX/Code/Source/BaseColliderComponent.h
  25. 30 12
      Gems/PhysX/Code/Source/EditorColliderComponent.cpp
  26. 2 0
      Gems/PhysX/Code/Source/EditorColliderComponent.h
  27. 4 3
      Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp
  28. 4 4
      Gems/PhysX/Code/Source/Utils.cpp
  29. 1 1
      Gems/PhysX/Code/Source/Utils.h
  30. 10 6
      Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarkWashingMachine.cpp
  31. 6 5
      Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.cpp
  32. 1 1
      Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.h
  33. 6 7
      Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp
  34. 9 9
      Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp
  35. 1 1
      Gems/PhysX/Code/Tests/ColliderScalingTests.cpp
  36. 4 3
      Gems/PhysX/Code/Tests/PhysXGenericTest.cpp
  37. 2 2
      Gems/PhysX/Code/Tests/PhysXGenericTestFixture.cpp
  38. 29 23
      Gems/PhysX/Code/Tests/PhysXSceneTests.cpp
  39. 13 13
      Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp
  40. 36 35
      Gems/PhysX/Code/Tests/PhysXTestCommon.cpp
  41. 4 1
      Gems/WhiteBox/Code/Source/Components/EditorWhiteBoxColliderComponent.cpp

+ 2 - 1
Code/Framework/AzFramework/AzFramework/Physics/Character.h

@@ -18,6 +18,7 @@
 
 #include <AzFramework/Physics/Collision/CollisionGroups.h>
 #include <AzFramework/Physics/Collision/CollisionLayers.h>
+#include <AzFramework/Physics/Common/PhysicsTypes.h>
 #include <AzFramework/Physics/Common/PhysicsSimulatedBody.h>
 #include <AzFramework/Physics/Configuration/SimulatedBodyConfiguration.h>
 
@@ -36,7 +37,7 @@ namespace Physics
         static void Reflect(AZ::ReflectContext* context);
 
         AZStd::string m_name;
-        ShapeConfigurationList m_shapes;
+        AzPhysics::ShapeColliderPairList m_shapes;
     };
 
     class CharacterColliderConfiguration

+ 6 - 4
Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp

@@ -57,7 +57,7 @@ namespace Physics
                     classElement.RemoveElement(shapesIndex);
 
                     // add a new vector in the new format
-                    const int newShapesIndex = classElement.AddElement<ShapeConfigurationList>(context, "shapes");
+                    const int newShapesIndex = classElement.AddElement<AzPhysics::ShapeColliderPairList>(context, "shapes");
                     if (newShapesIndex != -1)
                     {
                         AZ::SerializeContext::DataElementNode& newShapesElement = classElement.GetSubElement(newShapesIndex);
@@ -65,7 +65,9 @@ namespace Physics
                         // convert the old shapes into the new format and add to the vector
                         for (AZ::SerializeContext::DataElementNode shape : shapesCopy)
                         {
-                            const int pairIndex = newShapesElement.AddElementWithData<ShapeConfigurationPair>(context, "element", ShapeConfigurationPair());
+                            const int pairIndex = newShapesElement.AddElementWithData<AzPhysics::ShapeColliderPair>(
+                                context, "element", AzPhysics::ShapeColliderPair());
+
                             AZ::SerializeContext::DataElementNode& pairElement = newShapesElement.GetSubElement(pairIndex);
 
                             ColliderConfiguration colliderConfig;
@@ -131,8 +133,8 @@ namespace Physics
                             AZ::SerializeContext::DataElementNode* baseBaseClass1 = baseClass1->FindSubElement(AZ_CRC("BaseClass1", 0xd4925735));
                             if (baseBaseClass1 && baseBaseClass1->FindSubElementAndGetData<AZStd::string>(AZ_CRC("name", 0x5e237e06), name))
                             {
-                                ShapeConfigurationList shapes;
-                                if (nodeElement.FindSubElementAndGetData<ShapeConfigurationList>(AZ_CRC("shapes", 0x93dba512), shapes))
+                                AzPhysics::ShapeColliderPairList shapes;
+                                if (nodeElement.FindSubElementAndGetData<AzPhysics::ShapeColliderPairList>(AZ_CRC("shapes", 0x93dba512), shapes))
                                 {
                                     CharacterColliderNodeConfiguration newColliderNodeConfig;
                                     newColliderNodeConfig.m_name = name;

+ 4 - 1
Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h

@@ -70,7 +70,10 @@ namespace AzPhysics
     using SimulatedBodyHandleList = AZStd::vector<SimulatedBodyHandle>;
 
     //! Helper used for pairing the ShapeConfiguration and ColliderConfiguration together which is used when creating a Simulated Body.
-    using ShapeColliderPair = AZStd::pair<Physics::ColliderConfiguration*, Physics::ShapeConfiguration*>;
+    using ShapeColliderPair = AZStd::pair<
+        AZStd::shared_ptr<Physics::ColliderConfiguration>,
+        AZStd::shared_ptr<Physics::ShapeConfiguration>>;
+    using ShapeColliderPairList = AZStd::vector<ShapeColliderPair>;
 
     //! Flags used to specifying which properties of a body to compute.
     enum class MassComputeFlags : AZ::u8

+ 0 - 3
Code/Framework/AzFramework/AzFramework/Physics/Shape.h

@@ -80,9 +80,6 @@ namespace Physics
         void OnContactOffsetChanged();
     };
 
-    using ShapeConfigurationPair = AZStd::pair<AZStd::shared_ptr<ColliderConfiguration>, AZStd::shared_ptr<ShapeConfiguration>>;
-    using ShapeConfigurationList = AZStd::vector<ShapeConfigurationPair>;
-
     struct RayCastRequest;
 
     class Shape

+ 1 - 1
Gems/Blast/Code/Source/Actor/ShapesProvider.cpp

@@ -27,7 +27,7 @@ namespace Blast
         PhysX::ColliderComponentRequestBus::Handler::BusDisconnect(m_entityId);
     }
 
-    Physics::ShapeConfigurationList ShapesProvider::GetShapeConfigurations()
+    AzPhysics::ShapeColliderPairList ShapesProvider::GetShapeConfigurations()
     {
         return {};
     }

+ 1 - 1
Gems/Blast/Code/Source/Actor/ShapesProvider.h

@@ -28,7 +28,7 @@ namespace Blast
         void AddShape(AZStd::shared_ptr<Physics::Shape> shape);
 
         // This class is not supposed to provide shape configurations, only shapes themselves.
-        Physics::ShapeConfigurationList GetShapeConfigurations() override;
+        AzPhysics::ShapeColliderPairList GetShapeConfigurations() override;
 
         AZStd::vector<AZStd::shared_ptr<Physics::Shape>> GetShapes() override;
 

+ 7 - 7
Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.cpp

@@ -251,7 +251,7 @@ namespace EMotionFX
             return false;
         }
 
-        Physics::ShapeConfigurationPair newCollider;
+        AzPhysics::ShapeColliderPair newCollider;
 
         // Either in case the contents got specified via a command parameter or in case of redo.
         if (m_contents)
@@ -263,7 +263,7 @@ namespace EMotionFX
         else if (m_colliderType)
         {
             // Create new collider.
-            AZ::Outcome<Physics::ShapeConfigurationPair> colliderOutcome = PhysicsSetup::CreateColliderByType(m_colliderType.value(), outResult);
+            AZ::Outcome<AzPhysics::ShapeColliderPair> colliderOutcome = PhysicsSetup::CreateColliderByType(m_colliderType.value(), outResult);
             if (!colliderOutcome.IsSuccess())
             {
                 return false;
@@ -367,7 +367,7 @@ namespace EMotionFX
             return false;
         }
 
-        const Physics::ShapeConfigurationPair& collider = nodeConfig->m_shapes[m_oldColliderIndex.value()];
+        const AzPhysics::ShapeColliderPair& collider = nodeConfig->m_shapes[m_oldColliderIndex.value()];
         m_contents = MCore::ReflectionSerializer::Serialize(&collider).GetValue();
 
         CommandColliderHelpers::RemoveCollider(m_actorId, m_jointName, m_configType, m_oldColliderIndex.value(), /*commandGroup*/ nullptr, true);
@@ -472,7 +472,7 @@ namespace EMotionFX
         AZ_UNUSED(parameters);
 
         Actor* actor = nullptr;
-        Physics::ShapeConfigurationPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult);
+        AzPhysics::ShapeColliderPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult);
         if (!shapeConfigPair)
         {
             return false;
@@ -524,7 +524,7 @@ namespace EMotionFX
         AZ_UNUSED(parameters);
 
         Actor* actor = nullptr;
-        Physics::ShapeConfigurationPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult);
+        AzPhysics::ShapeColliderPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult);
         if (!shapeConfigPair)
         {
             return false;
@@ -606,7 +606,7 @@ namespace EMotionFX
         return true;
     }
 
-    Physics::ShapeConfigurationPair* CommandAdjustCollider::GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const
+    AzPhysics::ShapeColliderPair* CommandAdjustCollider::GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const
     {
         Actor* actor = GetActor(this, outResult);
         if (!actor)
@@ -647,7 +647,7 @@ namespace EMotionFX
             return nullptr;
         }
 
-        Physics::ShapeConfigurationPair& shapeConfigPair = nodeConfig->m_shapes[m_index.value()];
+        AzPhysics::ShapeColliderPair& shapeConfigPair = nodeConfig->m_shapes[m_index.value()];
         return &shapeConfigPair;
     }
 

+ 1 - 1
Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.h

@@ -159,7 +159,7 @@ namespace EMotionFX
         static const char* s_commandName;
 
     private:
-        Physics::ShapeConfigurationPair* GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const;
+        AzPhysics::ShapeColliderPair* GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const;
 
         AZStd::optional<PhysicsSetup::ColliderConfigType> m_configType;
         AZStd::optional<size_t> m_index;

+ 8 - 6
Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.cpp

@@ -198,13 +198,13 @@ namespace EMotionFX
         return m_config.m_simulatedObjectColliderConfig;
     }
 
-    AZ::Outcome<Physics::ShapeConfigurationPair> PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId)
+    AZ::Outcome<AzPhysics::ShapeColliderPair> PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId)
     {
         AZStd::string outResult;
         return CreateColliderByType(typeId, outResult);
     }
 
-    AZ::Outcome<Physics::ShapeConfigurationPair> PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult)
+    AZ::Outcome<AzPhysics::ShapeColliderPair> PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult)
     {
         if (typeId.IsNull())
         {
@@ -227,14 +227,16 @@ namespace EMotionFX
             return AZ::Failure();
         }
 
-        Physics::ShapeConfiguration* shapeConfig = reinterpret_cast<Physics::ShapeConfiguration*>(classData->m_factory->Create(classData->m_name));
+        AZStd::shared_ptr<Physics::ShapeConfiguration> shapeConfig(
+            reinterpret_cast<Physics::ShapeConfiguration*>(classData->m_factory->Create(classData->m_name)));
+
         if (!shapeConfig)
         {
             outResult = AZStd::string::format("Could not create collider with type '%s'.", typeId.ToString<AZStd::string>().c_str());
             return AZ::Failure();
         }
         
-        Physics::ShapeConfigurationPair pair(AZStd::make_shared<Physics::ColliderConfiguration>(), shapeConfig);
+        AzPhysics::ShapeColliderPair pair(AZStd::make_shared<Physics::ColliderConfiguration>(), shapeConfig);
         if (pair.first->m_materialSelection.GetMaterialIdsAssignedToSlots().empty())
         {
             pair.first->m_materialSelection.SetMaterialSlots(Physics::MaterialSelection::SlotsArray());
@@ -242,7 +244,7 @@ namespace EMotionFX
         return AZ::Success(pair);
     }
 
-    void PhysicsSetup::AutoSizeCollider(Physics::ShapeConfigurationPair& collider, const Actor* actor, const Node* joint)
+    void PhysicsSetup::AutoSizeCollider(AzPhysics::ShapeColliderPair& collider, const Actor* actor, const Node* joint)
     {
         if (!collider.second || !actor || !joint)
         {
@@ -417,7 +419,7 @@ namespace EMotionFX
                         nodeConfig = &hitDetectionConfig.m_nodes.back();
                     }
 
-                    Physics::ShapeConfigurationList& collisionShapes = nodeConfig->m_shapes;
+                    AzPhysics::ShapeColliderPairList& collisionShapes = nodeConfig->m_shapes;
 
                     Physics::ColliderConfiguration* colliderConfig = aznew Physics::ColliderConfiguration();
                     colliderConfig->m_position = position;

+ 3 - 3
Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.h

@@ -68,9 +68,9 @@ namespace EMotionFX
 
         void OptimizeForServer();
 
-        static AZ::Outcome<Physics::ShapeConfigurationPair> CreateColliderByType(const AZ::TypeId& typeId);
-        static AZ::Outcome<Physics::ShapeConfigurationPair> CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult);
-        static void AutoSizeCollider(Physics::ShapeConfigurationPair& collider, const Actor* actor, const Node* node);
+        static AZ::Outcome<AzPhysics::ShapeColliderPair> CreateColliderByType(const AZ::TypeId& typeId);
+        static AZ::Outcome<AzPhysics::ShapeColliderPair> CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult);
+        static void AutoSizeCollider(AzPhysics::ShapeColliderPair& collider, const Actor* actor, const Node* node);
 
         static void Reflect(AZ::ReflectContext* context);
 

+ 2 - 2
Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp

@@ -51,7 +51,7 @@ namespace EMotionFX
         m_collisionObjects.reserve(3);
     }
 
-    void SpringSolver::CreateCollider(AZ::u32 skeletonJointIndex, const Physics::ShapeConfigurationPair& shapePair)
+    void SpringSolver::CreateCollider(AZ::u32 skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair)
     {
         const Physics::ShapeConfiguration* shapeConfig = shapePair.second.get();
         if (!shapeConfig)
@@ -104,7 +104,7 @@ namespace EMotionFX
             bool colliderFound = false;
             for (const auto& nodeConfig : colliderSetup.m_nodes) 
             {
-                for (const Physics::ShapeConfigurationPair& shapePair : nodeConfig.m_shapes)
+                for (const AzPhysics::ShapeColliderPair& shapePair : nodeConfig.m_shapes)
                 {
                     if (shapePair.first->m_tag == colliderTag)
                     {

+ 2 - 2
Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h

@@ -87,7 +87,7 @@ namespace EMotionFX
             AZ::Vector3 m_end = AZ::Vector3::CreateZero(); /**< The end position of the primitive. In case of a sphere this is ignored. */
             float m_radius = 1.0f; /**< The radius or thickness. */
             float m_scaledRadius = 1.0f; /**< The scaled radius value, scaled by the joint's world space transform. */
-            const Physics::ShapeConfigurationPair* m_shapePair = nullptr;
+            const AzPhysics::ShapeColliderPair* m_shapePair = nullptr;
         };
 
         struct EMFX_API InitSettings
@@ -151,7 +151,7 @@ namespace EMotionFX
 
     private:
         void InitColliders(const InitSettings& initSettings);
-        void CreateCollider(AZ::u32 skeletonJointIndex, const Physics::ShapeConfigurationPair& shapePair);
+        void CreateCollider(AZ::u32 skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair);
         void InitColliderFromColliderSetupShape(CollisionObject& collider);
         void InitCollidersFromColliderSetupShapes();
         bool RecursiveAddJoint(const SimulatedJoint* joint, size_t parentParticleIndex);

+ 7 - 7
Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.cpp

@@ -266,7 +266,7 @@ namespace EMotionFX
         connect(this, &AzQtComponents::Card::contextMenuRequested, this, &ColliderWidget::OnCardContextMenu);
     }
 
-    void ColliderWidget::Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationPair& collider)
+    void ColliderWidget::Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPair& collider)
     {
         m_actor = actor;
         m_joint = joint;
@@ -276,7 +276,7 @@ namespace EMotionFX
         if (!collider.first || !collider.second)
         {
             m_editor->ClearInstances(true);
-            m_collider = Physics::ShapeConfigurationPair();
+            m_collider = AzPhysics::ShapeColliderPair();
             return;
         }
 
@@ -520,7 +520,7 @@ namespace EMotionFX
         CommandSystem::GetCommandManager()->RemoveCommandCallback(m_commandCallback, /*delFromMem=*/true);
     }
 
-    void ColliderContainerWidget::Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationList& colliders, AZ::SerializeContext* serializeContext)
+    void ColliderContainerWidget::Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPairList& colliders, AZ::SerializeContext* serializeContext)
     {
         m_actor = actor;
         m_joint = joint;
@@ -557,7 +557,7 @@ namespace EMotionFX
         for (size_t i = numColliders; i < numAvailableColliderWidgets; ++i)
         {
             m_colliderWidgets[i]->hide();
-            m_colliderWidgets[i]->Update(nullptr, nullptr, MCORE_INVALIDINDEX32, PhysicsSetup::ColliderConfigType::Unknown, Physics::ShapeConfigurationPair());
+            m_colliderWidgets[i]->Update(nullptr, nullptr, MCORE_INVALIDINDEX32, PhysicsSetup::ColliderConfigType::Unknown, AzPhysics::ShapeColliderPair());
         }
     }
 
@@ -571,7 +571,7 @@ namespace EMotionFX
 
     void ColliderContainerWidget::Reset()
     {
-        Update(nullptr, nullptr, PhysicsSetup::ColliderConfigType::Unknown, Physics::ShapeConfigurationList(), nullptr);
+        Update(nullptr, nullptr, PhysicsSetup::ColliderConfigType::Unknown, AzPhysics::ShapeColliderPairList(), nullptr);
     }
 
     void ColliderContainerWidget::contextMenuEvent(QContextMenuEvent* event)
@@ -614,7 +614,7 @@ namespace EMotionFX
         return QWidget::sizeHint() + QSize(0, s_layoutSpacing);
     }
 
-    void ColliderContainerWidget::RenderColliders(const Physics::ShapeConfigurationList& colliders,
+    void ColliderContainerWidget::RenderColliders(const AzPhysics::ShapeColliderPairList& colliders,
         const ActorInstance* actorInstance,
         const Node* node,
         EMStudio::EMStudioPlugin::RenderInfo* renderInfo,
@@ -704,7 +704,7 @@ namespace EMotionFX
                     if (joint)
                     {
                         const bool jointSelected = selectedJointIndices.empty() || selectedJointIndices.find(joint->GetNodeIndex()) != selectedJointIndices.end();
-                        const Physics::ShapeConfigurationList& colliders = nodeConfig.m_shapes;
+                        const AzPhysics::ShapeColliderPairList& colliders = nodeConfig.m_shapes;
                         RenderColliders(colliders, actorInstance, joint, renderInfo, jointSelected ? selectedColor : defaultColor);
                     }
                 }

+ 4 - 4
Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.h

@@ -71,7 +71,7 @@ namespace EMotionFX
     public:
         ColliderWidget(QIcon* icon, QWidget* parent, AZ::SerializeContext* serializeContext);
 
-        void Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationPair& collider);
+        void Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPair& collider);
         void Update();
         void Reset();
 
@@ -99,7 +99,7 @@ namespace EMotionFX
         PhysicsSetup::ColliderConfigType m_colliderType = PhysicsSetup::ColliderConfigType::Unknown;
         Node* m_joint = nullptr;
         size_t m_colliderIndex = MCORE_INVALIDINDEX32;
-        Physics::ShapeConfigurationPair m_collider;
+        AzPhysics::ShapeColliderPair m_collider;
 
         QIcon* m_icon;
     };
@@ -140,7 +140,7 @@ namespace EMotionFX
         ColliderContainerWidget(const QIcon& colliderIcon, QWidget* parent = nullptr);
         ~ColliderContainerWidget();
 
-        void Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationList& colliders, AZ::SerializeContext* serializeContext);
+        void Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPairList& colliders, AZ::SerializeContext* serializeContext);
         void Update();
         void Reset();
         PhysicsSetup::ColliderConfigType ColliderType() { return m_colliderType; }
@@ -156,7 +156,7 @@ namespace EMotionFX
          * @param[in] renderInfo Needed to access the render util.
          * @param[in] colliderColor The collider color.
          */
-        static void RenderColliders(const Physics::ShapeConfigurationList& colliders,
+        static void RenderColliders(const AzPhysics::ShapeColliderPairList& colliders,
             const ActorInstance* actorInstance,
             const Node* node,
             EMStudio::EMStudioPlugin::RenderInfo* renderInfo,

+ 2 - 2
Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.cpp

@@ -40,7 +40,7 @@ namespace EMotionFX
         const Physics::CharacterColliderNodeConfiguration* copyFromNodeConfig = copyFromColliderConfig->FindNodeConfigByName(joint->GetNameString());
         if (copyFromNodeConfig)
         {
-            for (const Physics::ShapeConfigurationPair& shapeConfigPair : copyFromNodeConfig->m_shapes)
+            for (const AzPhysics::ShapeColliderPair& shapeConfigPair : copyFromNodeConfig->m_shapes)
             {
                 const AZStd::string contents = MCore::ReflectionSerializer::Serialize(&shapeConfigPair).GetValue();
                 CommandColliderHelpers::AddCollider(actor->GetID(), joint->GetNameString(), copyTo, contents, AZStd::nullopt, &commandGroup);
@@ -231,7 +231,7 @@ namespace EMotionFX
         const Physics::CharacterColliderNodeConfiguration* copyFromNodeConfig = copyFromColliderConfig->FindNodeConfigByName(joint->GetNameString());
         if (copyFromNodeConfig && shapeIndex < copyFromNodeConfig->m_shapes.size())
         {
-            const Physics::ShapeConfigurationPair* shape = &copyFromNodeConfig->m_shapes[shapeIndex];
+            const AzPhysics::ShapeColliderPair* shape = &copyFromNodeConfig->m_shapes[shapeIndex];
             const AZStd::string contents = MCore::ReflectionSerializer::Serialize(shape).GetValue();
             QMimeData* mimeData = new QMimeData();
             mimeData->setData(

+ 1 - 1
Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.h

@@ -28,7 +28,7 @@ namespace EMotionFX
     public:
         static QString GetMimeTypeForColliderShape()
         {
-            return QString("com.amazon.lumberyard/%1").arg(azrtti_typeid<Physics::ShapeConfigurationPair>().ToString<QString>());
+            return QString("com.amazon.lumberyard/%1").arg(azrtti_typeid<AzPhysics::ShapeColliderPair>().ToString<QString>());
         }
 
         static void AddCopyColliderCommandToGroup(const Actor* actor, const Node* joint, PhysicsSetup::ColliderConfigType copyFrom, PhysicsSetup::ColliderConfigType copyTo, MCore::CommandGroup& commandGroup);

+ 1 - 1
Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp

@@ -507,7 +507,7 @@ namespace EMotionFX
                 const Physics::CharacterColliderNodeConfiguration* colliderNodeConfig = colliderConfig.FindNodeConfigByName(joint->GetNameString());
                 if (colliderNodeConfig)
                 {
-                    const Physics::ShapeConfigurationList& colliders = colliderNodeConfig->m_shapes;
+                    const AzPhysics::ShapeColliderPairList& colliders = colliderNodeConfig->m_shapes;
                     ColliderContainerWidget::RenderColliders(colliders, actorInstance, joint, renderInfo, finalColor);
                 }
             }

+ 1 - 1
Gems/EMotionFX/Code/Tests/ColliderCommandTests.cpp

@@ -196,7 +196,7 @@ namespace EMotionFX
         ASSERT_TRUE(nodeConfig != nullptr);
         EXPECT_EQ(nodeConfig->m_shapes.size(), 1);
 
-        Physics::ShapeConfigurationPair& shapeConfigPair = nodeConfig->m_shapes[0];
+        AzPhysics::ShapeColliderPair& shapeConfigPair = nodeConfig->m_shapes[0];
         Physics::ColliderConfiguration* colliderConfig = shapeConfigPair.first.get();
         Physics::ShapeConfiguration* shapeConfig = shapeConfigPair.second.get();
         Physics::BoxShapeConfiguration* boxShapeConfig = azdynamic_cast<Physics::BoxShapeConfiguration*>(shapeConfig);

+ 1 - 1
Gems/EMotionFX/Code/Tests/PhysicsSetupUtils.cpp

@@ -37,7 +37,7 @@ namespace EMotionFX
             else
             {
                 // Count in only the given collider type.
-                for (const Physics::ShapeConfigurationPair& shapeConfigPair : nodeConfig.m_shapes)
+                for (const AzPhysics::ShapeColliderPair& shapeConfigPair : nodeConfig.m_shapes)
                 {
                     if (shapeConfigPair.second->GetShapeType() == shapeTypeToCount)
                     {

+ 1 - 1
Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp

@@ -95,7 +95,7 @@ namespace NvCloth
                 continue;
             }
 
-            for (const Physics::ShapeConfigurationPair& shapeConfigPair : clothNodeConfig.m_shapes)
+            for (const AzPhysics::ShapeColliderPair& shapeConfigPair : clothNodeConfig.m_shapes)
             {
                 const auto& colliderConfig = shapeConfigPair.first;
 

+ 1 - 1
Gems/PhysX/Code/Include/PhysX/ColliderComponentBus.h

@@ -30,7 +30,7 @@ namespace PhysX
     {
     public:
         //! Gets the collection of collider configuration / shape configuration pairs used to define the collider's shapes.
-        virtual Physics::ShapeConfigurationList GetShapeConfigurations() = 0;
+        virtual AzPhysics::ShapeColliderPairList GetShapeConfigurations() = 0;
 
         //! Gets the collection of physics shapes associated with the collider.
         virtual AZStd::vector<AZStd::shared_ptr<Physics::Shape>> GetShapes() = 0;

+ 1 - 1
Gems/PhysX/Code/Include/PhysX/MeshAsset.h

@@ -58,7 +58,7 @@ namespace PhysX
             static constexpr AZ::u16 TriangleMeshMaterialIndex = (std::numeric_limits<AZ::u16>::max)();
 
             using ShapeConfigurationPair = AZStd::pair<AZStd::shared_ptr<AssetColliderConfiguration>, 
-                AZStd::shared_ptr<Physics::ShapeConfiguration>>; // Have to use shared_ptr here because Physics::ShapeConfigurationList uses it
+                AZStd::shared_ptr<Physics::ShapeConfiguration>>; // Have to use shared_ptr here because AzPhysics::ShapeColliderPairList uses it
             using ShapeConfigurationList = AZStd::vector<ShapeConfigurationPair>;
 
             ShapeConfigurationList m_colliderShapes; //!< Shapes data with optional collider configuration override.

+ 3 - 3
Gems/PhysX/Code/Source/BaseColliderComponent.cpp

@@ -104,7 +104,7 @@ namespace PhysX
         }
     }
 
-    void BaseColliderComponent::SetShapeConfigurationList(const Physics::ShapeConfigurationList& shapeConfigList)
+    void BaseColliderComponent::SetShapeConfigurationList(const AzPhysics::ShapeColliderPairList& shapeConfigList)
     {
         if (GetEntity()->GetState() == AZ::Entity::State::Active)
         {
@@ -115,7 +115,7 @@ namespace PhysX
         m_shapeConfigList = shapeConfigList;
     }
 
-    Physics::ShapeConfigurationList BaseColliderComponent::GetShapeConfigurations()
+    AzPhysics::ShapeColliderPairList BaseColliderComponent::GetShapeConfigurations()
     {
         return m_shapeConfigList;
     }
@@ -319,7 +319,7 @@ namespace PhysX
     {
         AZ_Assert(IsMeshCollider(), "InitMeshCollider called for a non-mesh collider.");
 
-        const Physics::ShapeConfigurationPair& shapeConfigurationPair = *(m_shapeConfigList.begin());
+        const AzPhysics::ShapeColliderPair& shapeConfigurationPair = *(m_shapeConfigList.begin());
         const Physics::ColliderConfiguration& componentColliderConfiguration = *(shapeConfigurationPair.first.get());
         const Physics::PhysicsAssetShapeConfiguration& physicsAssetConfiguration = 
             *(static_cast<const Physics::PhysicsAssetShapeConfiguration*>(shapeConfigurationPair.second.get()));

+ 3 - 3
Gems/PhysX/Code/Source/BaseColliderComponent.h

@@ -40,10 +40,10 @@ namespace PhysX
 
         BaseColliderComponent() = default;
 
-        void SetShapeConfigurationList(const Physics::ShapeConfigurationList& shapeConfigList);
+        void SetShapeConfigurationList(const AzPhysics::ShapeColliderPairList& shapeConfigList);
 
         // ColliderComponentRequestBus
-        Physics::ShapeConfigurationList GetShapeConfigurations() override;
+        AzPhysics::ShapeColliderPairList GetShapeConfigurations() override;
         AZStd::vector<AZStd::shared_ptr<Physics::Shape>> GetShapes() override;
 
         // TransformNotificationsBus
@@ -114,7 +114,7 @@ namespace PhysX
         virtual void UpdateScaleForShapeConfigs();
 
         ShapeInfoCache m_shapeInfoCache;
-        Physics::ShapeConfigurationList m_shapeConfigList;
+        AzPhysics::ShapeColliderPairList m_shapeConfigList;
     private:
         bool InitShapes();
         bool IsMeshCollider() const;

+ 30 - 12
Gems/PhysX/Code/Source/EditorColliderComponent.cpp

@@ -312,6 +312,26 @@ namespace PhysX
         }
     }
 
+    AZStd::shared_ptr<Physics::ShapeConfiguration> EditorProxyShapeConfig::CloneCurrent() const
+    {
+        switch (m_shapeType)
+        {
+        case Physics::ShapeType::Sphere:
+            return AZStd::make_shared<Physics::SphereShapeConfiguration>(m_sphere);
+        case Physics::ShapeType::Capsule:
+            return AZStd::make_shared<Physics::CapsuleShapeConfiguration>(m_capsule);
+        case Physics::ShapeType::PhysicsAsset:
+            return AZStd::make_shared<Physics::PhysicsAssetShapeConfiguration>(m_physicsAsset.m_configuration);
+        case Physics::ShapeType::CookedMesh:
+            return AZStd::make_shared<Physics::CookedMeshShapeConfiguration>(m_cookedMesh);
+        default:
+            AZ_Warning("EditorProxyShapeConfig", false, "Unsupported shape type, defaulting to Box.");
+            [[fallthrough]];
+        case Physics::ShapeType::Box:
+            return AZStd::make_shared<Physics::BoxShapeConfiguration>(m_box);
+        }
+    }
+
     bool EditorProxyShapeConfig::ShowingSubdivisionLevel() const
     {
         return (m_hasNonUniformScale && (IsCapsuleConfig() || IsSphereConfig() || IsAssetConfig()));
@@ -590,10 +610,6 @@ namespace PhysX
         configuration.m_entityId = GetEntityId();
         configuration.m_debugName = GetEntity()->GetName();
 
-        // This configuration needs to be at the scope of the function to be added
-        // to m_colliderAndShapeData as a pointer.
-        Physics::ColliderConfiguration colliderConfig;
-
         if (m_shapeConfiguration.IsAssetConfig())
         {
             AZStd::vector<AZStd::shared_ptr<Physics::Shape>> shapes;
@@ -603,13 +619,15 @@ namespace PhysX
         }
         else
         {
-            colliderConfig = GetColliderConfigurationScaled();
-            Physics::ShapeConfiguration& shapeConfig = m_shapeConfiguration.GetCurrent();
+            AZStd::shared_ptr<Physics::ColliderConfiguration> colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>(
+                GetColliderConfigurationScaled());
+            AZStd::shared_ptr<Physics::ShapeConfiguration> shapeConfig = m_shapeConfiguration.CloneCurrent();
+
             if (IsNonUniformlyScaledPrimitive(m_shapeConfiguration))
             {
-                auto convexConfig = Utils::CreateConvexFromPrimitive(GetColliderConfiguration(), shapeConfig,
-                    m_shapeConfiguration.m_subdivisionLevel, shapeConfig.m_scale);
-                auto colliderConfigurationNoOffset = colliderConfig;
+                auto convexConfig = Utils::CreateConvexFromPrimitive(GetColliderConfiguration(), *(shapeConfig.get()),
+                    m_shapeConfiguration.m_subdivisionLevel, shapeConfig->m_scale);
+                Physics::ColliderConfiguration colliderConfigurationNoOffset = *colliderConfig;
                 colliderConfigurationNoOffset.m_rotation = AZ::Quaternion::CreateIdentity();
                 colliderConfigurationNoOffset.m_position = AZ::Vector3::CreateZero();
 
@@ -622,7 +640,7 @@ namespace PhysX
             }
             else
             {
-                configuration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&colliderConfig, &shapeConfig);
+                configuration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig);
             }
         }
 
@@ -805,7 +823,7 @@ namespace PhysX
                 return;
             }
 
-            Physics::ShapeConfigurationList shapeConfigList;
+            AzPhysics::ShapeColliderPairList shapeConfigList;
             Utils::GetColliderShapeConfigsFromAsset(physicsAssetConfiguration, m_configuration, m_hasNonUniformScale,
                 m_shapeConfiguration.m_subdivisionLevel, shapeConfigList);
 
@@ -879,7 +897,7 @@ namespace PhysX
 
         const Physics::PhysicsAssetShapeConfiguration& physicsAssetConfiguration = m_shapeConfiguration.m_physicsAsset.m_configuration;
 
-        Physics::ShapeConfigurationList shapeConfigList;
+        AzPhysics::ShapeColliderPairList shapeConfigList;
         Utils::GetColliderShapeConfigsFromAsset(physicsAssetConfiguration, m_configuration, m_hasNonUniformScale,
             m_shapeConfiguration.m_subdivisionLevel, shapeConfigList);
 

+ 2 - 0
Gems/PhysX/Code/Source/EditorColliderComponent.h

@@ -86,6 +86,8 @@ namespace PhysX
         Physics::ShapeConfiguration& GetCurrent();
         const Physics::ShapeConfiguration& GetCurrent() const;
 
+        AZStd::shared_ptr<Physics::ShapeConfiguration> CloneCurrent() const;
+
         bool ShowingSubdivisionLevel() const;
 
         AZ::u32 OnConfigurationChanged();

+ 4 - 3
Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp

@@ -226,7 +226,7 @@ namespace PhysX
     void EditorShapeColliderComponent::BuildGameEntity(AZ::Entity* gameEntity)
     {
         auto* shapeColliderComponent = gameEntity->CreateComponent<ShapeColliderComponent>();
-        Physics::ShapeConfigurationList shapeConfigurationList;
+        AzPhysics::ShapeColliderPairList shapeConfigurationList;
         shapeConfigurationList.reserve(m_shapeConfigs.size());
         for (const auto& shapeConfig : m_shapeConfigs)
         {
@@ -257,11 +257,12 @@ namespace PhysX
         configuration.m_entityId = GetEntityId();
         configuration.m_debugName = GetEntity()->GetName();
 
-        AZStd::vector<AzPhysics::ShapeColliderPair> colliderShapePairs;
+        AzPhysics::ShapeColliderPairList colliderShapePairs;
         colliderShapePairs.reserve(m_shapeConfigs.size());
         for (const auto& shapeConfig : m_shapeConfigs)
         {
-            colliderShapePairs.emplace_back(&m_colliderConfig, shapeConfig.get());
+            colliderShapePairs.emplace_back(
+                AZStd::make_shared<Physics::ColliderConfiguration>(m_colliderConfig), shapeConfig);
         }
         configuration.m_colliderAndShapeData = colliderShapePairs;
 

+ 4 - 4
Gems/PhysX/Code/Source/Utils.cpp

@@ -770,7 +770,7 @@ namespace PhysX
                     return worldPosAabb;
                 }
 
-                Physics::ShapeConfigurationList colliderShapes;
+                AzPhysics::ShapeColliderPairList colliderShapes;
                 GetColliderShapeConfigsFromAsset(physicsAssetConfig,
                     colliderConfiguration,
                     hasNonUniformScale,
@@ -812,7 +812,7 @@ namespace PhysX
 
         void GetColliderShapeConfigsFromAsset(const Physics::PhysicsAssetShapeConfiguration& assetConfiguration,
             const Physics::ColliderConfiguration& originalColliderConfiguration, bool hasNonUniformScale,
-            AZ::u8 subdivisionLevel, Physics::ShapeConfigurationList& resultingColliderShapes)
+            AZ::u8 subdivisionLevel, AzPhysics::ShapeColliderPairList& resultingColliderShapes)
         {
             if (!assetConfiguration.m_asset.IsReady())
             {
@@ -896,13 +896,13 @@ namespace PhysX
             const Physics::ColliderConfiguration& originalColliderConfiguration, bool hasNonUniformScale,
             AZ::u8 subdivisionLevel, AZStd::vector<AZStd::shared_ptr<Physics::Shape>>& resultingShapes)
         {
-            Physics::ShapeConfigurationList resultingColliderShapeConfigs;
+            AzPhysics::ShapeColliderPairList resultingColliderShapeConfigs;
             GetColliderShapeConfigsFromAsset(assetConfiguration, originalColliderConfiguration,
                 hasNonUniformScale, subdivisionLevel, resultingColliderShapeConfigs);
 
             resultingShapes.reserve(resultingShapes.size() + resultingColliderShapeConfigs.size());
 
-            for (const Physics::ShapeConfigurationPair& shapeConfigPair : resultingColliderShapeConfigs)
+            for (const AzPhysics::ShapeColliderPair& shapeConfigPair : resultingColliderShapeConfigs)
             {
                 // Scale the collider offset
                 shapeConfigPair.first->m_position *= shapeConfigPair.second->m_scale;

+ 1 - 1
Gems/PhysX/Code/Source/Utils.h

@@ -179,7 +179,7 @@ namespace PhysX
 
         void GetColliderShapeConfigsFromAsset(const Physics::PhysicsAssetShapeConfiguration& assetConfiguration,
             const Physics::ColliderConfiguration& originalColliderConfiguration,
-            bool hasNonUniformScale, AZ::u8 subdivisionLevel, Physics::ShapeConfigurationList& resultingColliderShapes);
+            bool hasNonUniformScale, AZ::u8 subdivisionLevel, AzPhysics::ShapeColliderPairList& resultingColliderShapes);
 
         //! Gets the scale from the entity's Transform component.
         AZ::Vector3 GetTransformScale(AZ::EntityId entityId);

+ 10 - 6
Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarkWashingMachine.cpp

@@ -13,6 +13,7 @@
 #ifdef HAVE_BENCHMARK
 #include <Benchmarks/PhysXBenchmarkWashingMachine.h>
 
+#include <AzCore/std/smart_ptr/make_shared.h>
 #include <AzFramework/Physics/PhysicsScene.h>
 #include <AzFramework/Physics/PhysicsSystem.h>
 #include <AzFramework/Physics/SystemBus.h>
@@ -96,9 +97,12 @@ namespace PhysX::Benchmarks
             config.m_position.SetY((cylinderRadius + halfCylinderWallThickness) * std::sin(AZ::Constants::TwoPi * i / NumCylinderSide) + position.GetY());
             config.m_position.SetZ(z);
             config.m_orientation = AZ::Quaternion::CreateRotationZ(AZ::Constants::HalfPi + (cylinderTheta * i));
-            Physics::ColliderConfiguration colliderConfig;
-            Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(cylinderRadius, cylinderWallThickness, cylinderHeight));
-            config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&colliderConfig, &shapeConfiguration);
+            
+            auto shapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>(
+                AZ::Vector3(cylinderRadius, cylinderWallThickness, cylinderHeight));
+
+            config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+                AZStd::make_shared<Physics::ColliderConfiguration>(), shapeConfiguration);
             m_cylinder[i] = scene->AddSimulatedBody(&config);
         }
 
@@ -114,9 +118,9 @@ namespace PhysX::Benchmarks
         bladeRigidBodyConfig.m_position = position;
         bladeRigidBodyConfig.m_position.SetZ(position.GetZ() + (bladeHeight / 2.0f));
         bladeRigidBodyConfig.m_orientation = AZ::Quaternion::CreateRotationZ(0.0f);
-        Physics::ColliderConfiguration bladeColliderConfig;
-        Physics::BoxShapeConfiguration bladeShapeConfiguration(AZ::Vector3(bladeLength, 1.0f, bladeHeight));
-        bladeRigidBodyConfig.m_colliderAndShapeData = AZStd::make_pair(&bladeColliderConfig, &bladeShapeConfiguration);
+        auto bladeShapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3(bladeLength, 1.0f, bladeHeight));
+        bladeRigidBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+            AZStd::make_shared<Physics::ColliderConfiguration>(), bladeShapeConfiguration);
         m_blade = scene->AddSimulatedBody(&bladeRigidBodyConfig);
     }
 

+ 6 - 5
Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.cpp

@@ -13,6 +13,7 @@
 #include <Benchmarks/PhysXBenchmarksUtilities.h>
 
 #include <algorithm>
+#include <AzCore/std/smart_ptr/make_shared.h>
 #include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
 #include <AzFramework/Physics/Shape.h>
 #include <AzFramework/Physics/PhysicsScene.h>
@@ -34,9 +35,9 @@ namespace PhysX::Benchmarks
 
             AzPhysics::RigidBodyConfiguration rigidBodyConfig;
             rigidBodyConfig.m_ccdEnabled = enableCCD;
-            Physics::ColliderConfiguration rigidBodyColliderConfig;
+            auto rigidBodyColliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
 
-            Physics::BoxShapeConfiguration defaultShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3::CreateOne());
+            auto defaultShapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne());
             for (int i = 0; i < numRigidBodies; i++)
             {
                 //call the optional function pointers, otherwise assign a default
@@ -57,16 +58,16 @@ namespace PhysX::Benchmarks
                     rigidBodyConfig.m_orientation = (*genSpawnOriFuncPtr)(i);
                 }
 
-                Physics::ShapeConfiguration* shapeConfig = nullptr;
+                AZStd::shared_ptr<Physics::ShapeConfiguration> shapeConfig = nullptr;
                 if (genColliderFuncPtr != nullptr)
                 {
                     shapeConfig = (*genColliderFuncPtr)(i);
                 }
                 if (shapeConfig == nullptr)
                 {
-                    shapeConfig = &defaultShapeConfiguration;
+                    shapeConfig = defaultShapeConfiguration;
                 }
-                rigidBodyConfig.m_colliderAndShapeData = AZStd::make_pair(&rigidBodyColliderConfig, shapeConfig);
+                rigidBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(rigidBodyColliderConfig, shapeConfig);
 
                 AzPhysics::SimulatedBodyHandle simBodyHandle = scene->AddSimulatedBody(&rigidBodyConfig);
                 rigidBodies.push_back(simBodyHandle);

+ 1 - 1
Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.h

@@ -40,7 +40,7 @@ namespace PhysX::Benchmarks
     namespace Utils
     {
         //! Function pointer to allow Shape configuration customization rigid bodies created with Utils::CreateRigidBodies. int param is the id of the rigid body being created (values 0-N, where N=number requested to be created)
-        using GenerateColliderFuncPtr = AZStd::function<Physics::ShapeConfiguration*(int)>;
+        using GenerateColliderFuncPtr = AZStd::function<AZStd::shared_ptr<Physics::ShapeConfiguration>(int)>;
         //! Function pointer to allow spawn position customization rigid bodies created with Utils::CreateRigidBodies. int param is the id of the rigid body being created (values 0-N, where N=number requested to be created)
         using GenerateSpawnPositionFuncPtr = AZStd::function<const AZ::Vector3(int)>;
         //! Function pointer to allow spawn orientation customization rigid bodies created with Utils::CreateRigidBodies. int param is the id of the rigid body being created (values 0-N, where N=number requested to be created)

+ 6 - 7
Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp

@@ -136,9 +136,8 @@ namespace PhysX::Benchmarks
         {
             AZStd::vector<JointGroup> joints;
 
-            Physics::ColliderConfiguration colliderConfig;
-            Physics::SphereShapeConfiguration shapeConfiguration = Physics::SphereShapeConfiguration(JointConstants::CreateJointDefaults::ColliderRadius);
-            AzPhysics::ShapeColliderPair shapeColliderConfig(&colliderConfig, &shapeConfiguration);
+            auto shapeConfiguration = AZStd::make_shared<Physics::SphereShapeConfiguration>(JointConstants::CreateJointDefaults::ColliderRadius);
+            AzPhysics::ShapeColliderPair shapeColliderConfig(AZStd::make_shared<Physics::ColliderConfiguration>(), shapeConfiguration);
             for (int i = 0; i < numJoints; i++)
             {
                 JointGroup newJoint;
@@ -340,13 +339,13 @@ namespace PhysX::Benchmarks
         const int numSegments = aznumeric_cast<int>(state.range(0));
 
         //create the collider shape config to use on the whole snake
-        Physics::SphereShapeConfiguration snakePartShapeConfiguration = Physics::SphereShapeConfiguration(JointConstants::CreateJointDefaults::ColliderRadius);
-        Physics::ColliderConfiguration snakeHeadcolliderConfig;
+        auto snakePartShapeConfiguration = AZStd::make_shared<Physics::SphereShapeConfiguration>(JointConstants::CreateJointDefaults::ColliderRadius);
 
         //create the had of the snake this is the only static part.
         AzPhysics::StaticRigidBodyConfiguration snakeHeadBodyConfig;
         snakeHeadBodyConfig.m_position = AZ::Vector3::CreateZero();
-        snakeHeadBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&snakeHeadcolliderConfig, &snakePartShapeConfiguration);
+        snakeHeadBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+            AZStd::make_shared<Physics::ColliderConfiguration>(), snakePartShapeConfiguration);
 
         AzPhysics::SimulatedBody* snakeHead = nullptr;
         if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
@@ -358,7 +357,7 @@ namespace PhysX::Benchmarks
         //create the body
         Utils::GenerateColliderFuncPtr colliderGenerator = [&snakePartShapeConfiguration]([[maybe_unused]] int idx) -> auto
         {
-            return &snakePartShapeConfiguration;
+            return snakePartShapeConfiguration;
         };
         Utils::GenerateSpawnPositionFuncPtr posGenerator = [](int idx) -> auto
         {

+ 9 - 9
Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp

@@ -203,10 +203,10 @@ namespace PhysX::Benchmarks
             return AZ::Vector3(x, y, z);
         };
         
-        Physics::BoxShapeConfiguration boxShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize));
-        Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) -> Physics::ShapeConfiguration*
+        auto boxShapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize));
+        Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx)
         {
-            return &boxShapeConfiguration;
+            return boxShapeConfiguration;
         };
         //spawn the rigid bodies
         AzPhysics::SimulatedBodyHandleList rigidBodies = Utils::CreateRigidBodies(numRigidBodies, m_defaultScene,
@@ -275,10 +275,10 @@ namespace PhysX::Benchmarks
         Utils::GenerateMassFuncPtr massGenerator = [&rand]([[maybe_unused]] int idx) -> float {
             return rand.GetRandomFloat() * 25.0f + 5.0f;
         };
-        Physics::BoxShapeConfiguration boxShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize));
-        Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) -> Physics::ShapeConfiguration*
+        auto boxShapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize));
+        Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx)
         {
-            return &boxShapeConfiguration;
+            return boxShapeConfiguration;
         };
         //spawn the rigid bodies
         AzPhysics::SimulatedBodyHandleList rigidBodies = Utils::CreateRigidBodies(numRigidBodies, m_defaultScene,
@@ -408,10 +408,10 @@ namespace PhysX::Benchmarks
         Utils::GenerateEntityIdFuncPtr entityIdGenerator = [&rand](int idx) -> AZ::EntityId {
             return AZ::EntityId(static_cast<AZ::u64>(idx) + RigidBodyConstants::RigidBodys::RigidBodyEntityIdStart);
         };
-        Physics::BoxShapeConfiguration boxShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize));
-        Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) -> Physics::ShapeConfiguration*
+        auto boxShapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize));
+        Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx)
         {
-            return &boxShapeConfiguration;
+            return boxShapeConfiguration;
         };
         //spawn the rigid bodies
         AzPhysics::SimulatedBodyHandleList rigidBodies = Utils::CreateRigidBodies(numRigidBodies, m_defaultScene,

+ 1 - 1
Gems/PhysX/Code/Tests/ColliderScalingTests.cpp

@@ -30,7 +30,7 @@ namespace PhysXEditorTests
         PhysX::BaseColliderComponent* colliderComponent = gameEntity->FindComponent<PhysX::BaseColliderComponent>();
         ASSERT_TRUE(colliderComponent != nullptr);
 
-        Physics::ShapeConfigurationList shapeConfigList = colliderComponent->GetShapeConfigurations();
+        AzPhysics::ShapeColliderPairList shapeConfigList = colliderComponent->GetShapeConfigurations();
         EXPECT_EQ(shapeConfigList.size(), 1);
 
         for (const auto& shapeConfigPair : shapeConfigList)

+ 4 - 3
Gems/PhysX/Code/Tests/PhysXGenericTest.cpp

@@ -325,9 +325,10 @@ namespace PhysX
         // Box should start asleep
         AzPhysics::RigidBodyConfiguration config;
         config.m_startAsleep = true;
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::SphereShapeConfiguration shapeConfiguration;
-        config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::SphereShapeConfiguration>()
+        );
 
         AzPhysics::SimulatedBodyHandle rigidBodyHandle = sceneInterface->AddSimulatedBody(sceneHandle, &config);
         TestUtils::UpdateScene(sceneHandle, 1.0f / 60.0f, 100);

+ 2 - 2
Gems/PhysX/Code/Tests/PhysXGenericTestFixture.cpp

@@ -104,12 +104,12 @@ namespace PhysX
         auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
         colliderConfig->m_collisionLayer = config.m_layer;
 
-        Physics::ShapeConfigurationList shapeconfigurationList;
+        AzPhysics::ShapeColliderPairList shapeconfigurationList;
 
         struct Visitor
         {
             AZStd::shared_ptr<Physics::ColliderConfiguration>& colliderConfig;
-            Physics::ShapeConfigurationList& shapeconfigurationList;
+            AzPhysics::ShapeColliderPairList& shapeconfigurationList;
 
             void operator()(const MultiShapeConfig::ShapeList::ShapeData::Box& box) const
             {

+ 29 - 23
Gems/PhysX/Code/Tests/PhysXSceneTests.cpp

@@ -83,10 +83,10 @@ namespace PhysX
         auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();
 
         //add a static rigid body
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
         AzPhysics::StaticRigidBodyConfiguration config;
-        config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
         AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &config);
         EXPECT_FALSE(simBodyHandle == AzPhysics::InvalidSimulatedBodyHandle);
     }
@@ -104,14 +104,15 @@ namespace PhysX
         EXPECT_TRUE(emptyBodies.empty());
 
         //add some rigid bodies
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
+        AzPhysics::ShapeColliderPair shapeColliderData(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
         constexpr const int numberOfBodies = 100;
         for (int i = 0; i < numberOfBodies; i++)
         {
             const float xpos = 2.0f * static_cast<float>(i);
             AzPhysics::RigidBodyConfiguration* config = aznew AzPhysics::RigidBodyConfiguration();
-            config->m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+            config->m_colliderAndShapeData = shapeColliderData;
             config->m_position = AZ::Vector3::CreateAxisX(xpos);
             configs.emplace_back(config);
         }
@@ -150,15 +151,16 @@ namespace PhysX
 
         AzPhysics::SimulatedBodyConfigurationList configs;
         //add some rigid bodies
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
-
+        AzPhysics::ShapeColliderPair shapeColliderData(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
+        
         constexpr const int numberOfBodies = 100;
         for (int i = 0; i < numberOfBodies; i++)
         {
             const float xpos = 2.0f * static_cast<float>(i);
             AzPhysics::RigidBodyConfiguration* config = aznew AzPhysics::RigidBodyConfiguration();
-            config->m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+            config->m_colliderAndShapeData = shapeColliderData;
             config->m_position = AZ::Vector3::CreateAxisX(xpos);
             configs.emplace_back(config);
         }
@@ -205,10 +207,11 @@ namespace PhysX
         auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();
 
         //add a simulated body
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
+        AzPhysics::ShapeColliderPair shapeColliderData(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
         AzPhysics::StaticRigidBodyConfiguration config;
-        config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        config.m_colliderAndShapeData = shapeColliderData;
         AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &config);
 
         //remove the body
@@ -223,10 +226,11 @@ namespace PhysX
         auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();
 
         //add a few simulated body
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
+        AzPhysics::ShapeColliderPair shapeColliderData(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
         AzPhysics::StaticRigidBodyConfiguration config;
-        config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        config.m_colliderAndShapeData = shapeColliderData;
 
         AzPhysics::SimulatedBodyHandleList simBodyHandles;
         constexpr const int numBodies = 10;
@@ -281,10 +285,11 @@ namespace PhysX
         sceneInterface->RegisterSimulationBodyRemovedHandler(m_testSceneHandle, removedEvent);
 
         //add a simulated body
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
+        AzPhysics::ShapeColliderPair shapeColliderData(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
         AzPhysics::StaticRigidBodyConfiguration config;
-        config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        config.m_colliderAndShapeData = shapeColliderData;
         AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &config);
 
         EXPECT_TRUE(addTriggered);
@@ -552,17 +557,18 @@ namespace PhysX
         auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();
 
         // setup shape config
-        Physics::ColliderConfiguration colliderConfig;
-        Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f));
+        AzPhysics::ShapeColliderPair shapeColliderData(
+            AZStd::make_shared<Physics::ColliderConfiguration>(),
+            AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3::CreateOne()));
 
         // add a static simulated body - this is not expected to be reported as an active actor
         AzPhysics::StaticRigidBodyConfiguration staticConfig;
-        staticConfig.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        staticConfig.m_colliderAndShapeData = shapeColliderData;
         AzPhysics::SimulatedBodyHandle staticSphereHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &staticConfig);
 
         // add a rigid body - this is expect to be reported as an active actor
         AzPhysics::RigidBodyConfiguration rigidConfig;
-        rigidConfig.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+        rigidConfig.m_colliderAndShapeData = shapeColliderData;
         AzPhysics::SimulatedBodyHandle rigidSphereHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &rigidConfig);
 
         // create + register the active handler

+ 13 - 13
Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp

@@ -539,14 +539,14 @@ namespace PhysX
     TEST_F(PhysXSpecificTest, RigidBody_CenterOfMassOffsetComputed)
     {
         AZ::Vector3 halfExtents(1.0f, 2.0f, 3.0f);
-        Physics::BoxShapeConfiguration shapeConfig(halfExtents * 2.0f);
-        Physics::ColliderConfiguration colliderConfig;
-        colliderConfig.m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi);
+        auto shapeConfig = AZStd::make_shared<Physics::BoxShapeConfiguration>(halfExtents * 2.0f);
+        auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+        colliderConfig->m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi);
 
         AzPhysics::RigidBodyConfiguration rigidBodyConfiguration;
         rigidBodyConfiguration.m_computeCenterOfMass = true;
         rigidBodyConfiguration.m_computeInertiaTensor = true;
-        rigidBodyConfiguration.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig);
+        rigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig);
         AzPhysics::RigidBody* rigidBody = nullptr;
         if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
         {
@@ -562,15 +562,15 @@ namespace PhysX
     TEST_F(PhysXSpecificTest, RigidBody_CenterOfMassOffsetSpecified)
     {
         AZ::Vector3 halfExtents(1.0f, 2.0f, 3.0f);
-        Physics::BoxShapeConfiguration shapeConfig(halfExtents * 2.0f);
-        Physics::ColliderConfiguration colliderConfig;
-        colliderConfig.m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi);
+        auto shapeConfig = AZStd::make_shared<Physics::BoxShapeConfiguration>(halfExtents * 2.0f);
+        auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+        colliderConfig->m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi);
 
         AzPhysics::RigidBodyConfiguration rigidBodyConfiguration;
         rigidBodyConfiguration.m_computeCenterOfMass = false;
         rigidBodyConfiguration.m_centerOfMassOffset = AZ::Vector3::CreateOne();
         rigidBodyConfiguration.m_computeInertiaTensor = true;
-        rigidBodyConfiguration.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig);
+        rigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig);
 
         AzPhysics::RigidBody* rigidBody = nullptr;
         if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
@@ -1113,15 +1113,15 @@ namespace PhysX
         auto CreateBoxRigidBody = [this](const AZ::Vector3& position, bool simulatedFlag, bool triggerFlag) -> AzPhysics::RigidBody*
         {
 
-            Physics::ColliderConfiguration colliderConfig;
-            colliderConfig.m_isSimulated = simulatedFlag;
-            colliderConfig.m_isTrigger = triggerFlag;
-            Physics::BoxShapeConfiguration shapeConfig;
+            auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+            colliderConfig->m_isSimulated = simulatedFlag;
+            colliderConfig->m_isTrigger = triggerFlag;
 
             AzPhysics::RigidBodyConfiguration rigidBodyConfig;
             rigidBodyConfig.m_entityId = AZ::EntityId(0); // Set entity ID to avoid warnings in OnTriggerEnter 
             rigidBodyConfig.m_position = position;
-            rigidBodyConfig.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig);
+            rigidBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+                colliderConfig, AZStd::make_shared<Physics::BoxShapeConfiguration>());
 
             if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
             {

+ 36 - 35
Gems/PhysX/Code/Tests/PhysXTestCommon.cpp

@@ -107,7 +107,7 @@ namespace PhysX
 
             auto shapeConfig = AZStd::make_shared<Physics::SphereShapeConfiguration>(radius);
             auto shpereColliderComponent = entity->CreateComponent<PhysX::SphereColliderComponent>();
-            shpereColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) });
+            shpereColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) });
 
             AzPhysics::RigidBodyConfiguration rigidBodyConfig;
             rigidBodyConfig.m_computeMass = false;
@@ -136,7 +136,7 @@ namespace PhysX
             colliderConfig->m_collisionLayer = layer;
             auto shapeConfig = AZStd::make_shared<Physics::SphereShapeConfiguration>(radius);
             auto sphereColliderComponent = entity->CreateComponent<SphereColliderComponent>();
-            sphereColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) });
+            sphereColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) });
 
             entity->CreateComponent<StaticRigidBodyComponent>(sceneHandle);
 
@@ -171,7 +171,7 @@ namespace PhysX
             auto boxColliderComponent = entity->CreateComponent<PhysX::BoxColliderComponent>();
             auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
             colliderConfig->m_collisionLayer = layer;
-            boxColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) });
+            boxColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) });
             entity->CreateComponent<PhysX::StaticRigidBodyComponent>(sceneHandle);
             entity->Activate();
             return entity;
@@ -195,7 +195,7 @@ namespace PhysX
             colliderConfig->m_collisionLayer = layer;
             auto shapeConfig = AZStd::make_shared<Physics::CapsuleShapeConfiguration>(height, radius);
             auto capsuleColliderComponent = entity->CreateComponent<CapsuleColliderComponent>();
-            capsuleColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) });
+            capsuleColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) });
 
             AzPhysics::RigidBodyConfiguration rigidBodyConfig;
             rigidBodyConfig.m_computeMass = false;
@@ -223,7 +223,7 @@ namespace PhysX
             colliderConfig->m_collisionLayer = layer;
             auto shapeConfig = AZStd::make_shared<Physics::CapsuleShapeConfiguration>(height, radius);
             auto capsuleColliderComponent = entity->CreateComponent<CapsuleColliderComponent>();
-            capsuleColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) });
+            capsuleColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) });
 
             entity->CreateComponent<StaticRigidBodyComponent>(sceneHandle);
 
@@ -244,14 +244,13 @@ namespace PhysX
             AZ_Assert(cookingResult, "Failed to cook the cube mesh.");
 
             // Setup shape & collider configurations
-            Physics::CookedMeshShapeConfiguration shapeConfig;
-            shapeConfig.SetCookedMeshData(cookedData.data(), cookedData.size(),
+            auto shapeConfig = AZStd::make_shared<Physics::CookedMeshShapeConfiguration>();
+            shapeConfig->SetCookedMeshData(cookedData.data(), cookedData.size(),
                 Physics::CookedMeshShapeConfiguration::MeshType::TriangleMesh);
 
-            Physics::ColliderConfiguration colliderConfig;
-
             AzPhysics::StaticRigidBodyConfiguration staticRigidBodyConfiguration;
-            staticRigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&colliderConfig, &shapeConfig);
+            staticRigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+                AZStd::make_shared<Physics::ColliderConfiguration>(), shapeConfig);
 
             if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
             {
@@ -290,7 +289,7 @@ namespace PhysX
 
             auto shapeConfig = AZStd::make_shared<Physics::BoxShapeConfiguration>(dimensions);
             auto boxColliderComponent = entity->CreateComponent<PhysX::BoxColliderComponent>();
-            boxColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) });
+            boxColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) });
 
             AzPhysics::RigidBodyConfiguration rigidBodyConfig;
             rigidBodyConfig.m_computeMass = false;
@@ -307,7 +306,7 @@ namespace PhysX
             AZ::TransformConfig transformConfig;
             transformConfig.m_worldTransform = AZ::Transform::CreateTranslation(position);
             entity->CreateComponent<AzFramework::TransformComponent>()->SetConfiguration(transformConfig);
-            Physics::ShapeConfigurationList shapeConfigList = { AZStd::make_pair(
+            AzPhysics::ShapeColliderPairList shapeConfigList = { AzPhysics::ShapeColliderPair(
                 AZStd::make_shared<Physics::ColliderConfiguration>(),
                 AZStd::make_shared<Physics::BoxShapeConfiguration>()) };
             auto boxCollider = entity->CreateComponent<BoxColliderComponent>();
@@ -371,10 +370,10 @@ namespace PhysX
 
         AzPhysics::StaticRigidBody* AddStaticFloorToScene(AzPhysics::SceneHandle sceneHandle, const AZ::Transform& transform)
         {
-            Physics::ColliderConfiguration colliderConfig;
-            Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(20.0f, 20.0f, 1.0f));
             AzPhysics::StaticRigidBodyConfiguration staticBodyConfiguration;
-            staticBodyConfiguration.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+            staticBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+                AZStd::make_shared<Physics::ColliderConfiguration>(),
+                AZStd::make_shared<Physics::BoxShapeConfiguration>(AZ::Vector3(20.0f, 20.0f, 1.0f)));
             if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
             {
                 AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(sceneHandle, &staticBodyConfiguration);
@@ -410,10 +409,10 @@ namespace PhysX
         AzPhysics::SimulatedBodyHandle AddSphereToScene(AzPhysics::SceneHandle sceneHandle, const AZ::Vector3& position,
             const float radius /*= 0.5f*/, const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/)
         {
-            Physics::ColliderConfiguration colliderConfig;
-            colliderConfig.m_collisionLayer = layer;
-            Physics::SphereShapeConfiguration shapeConfiguration;
-            shapeConfiguration.m_radius = radius;
+            auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+            colliderConfig->m_collisionLayer = layer;
+            auto shapeConfiguration = AZStd::make_shared<Physics::SphereShapeConfiguration>();
+            shapeConfiguration->m_radius = radius;
             AzPhysics::RigidBodyConfiguration rigidBodySettings;
             rigidBodySettings.m_computeMass = false;
             rigidBodySettings.m_computeInertiaTensor = false;
@@ -421,7 +420,7 @@ namespace PhysX
             rigidBodySettings.m_mass = 1.0f;
             rigidBodySettings.m_position = position;
             rigidBodySettings.m_linearDamping = 0.0f;
-            rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+            rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfiguration);
 
             if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
             {
@@ -435,11 +434,12 @@ namespace PhysX
             const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/)
         {
             AzPhysics::RigidBodyConfiguration rigidBodySettings;
-            Physics::ColliderConfiguration colliderConfig;
-            colliderConfig.m_collisionLayer = layer;
-            colliderConfig.m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi);
-            Physics::CapsuleShapeConfiguration shapeConfig(height, radius);
-            rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig);
+            auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+            colliderConfig->m_collisionLayer = layer;
+            colliderConfig->m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi);
+            
+            rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig,
+                AZStd::make_shared<Physics::CapsuleShapeConfiguration>(height, radius));
             rigidBodySettings.m_position = position;
             rigidBodySettings.m_computeMass = false;
             rigidBodySettings.m_computeInertiaTensor = false;
@@ -457,10 +457,10 @@ namespace PhysX
             const AZ::Vector3& position, const AZ::Vector3& dimensions /*= AZ::Vector3(1.0f)*/,
             const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/)
         {
-            Physics::ColliderConfiguration colliderConfig;
-            colliderConfig.m_collisionLayer = layer;
-            Physics::BoxShapeConfiguration shapeConfiguration;
-            shapeConfiguration.m_dimensions = dimensions;
+            auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+            colliderConfig->m_collisionLayer = layer;
+            auto shapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>();
+            shapeConfiguration->m_dimensions = dimensions;
 
             AzPhysics::RigidBodyConfiguration rigidBodySettings;
             rigidBodySettings.m_computeMass = false;
@@ -469,7 +469,7 @@ namespace PhysX
             rigidBodySettings.m_mass = 1.0f;
             rigidBodySettings.m_position = position;
             rigidBodySettings.m_linearDamping = 0.0f;
-            rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+            rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfiguration);
             if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
             {
                 return sceneInterface->AddSimulatedBody(sceneHandle, &rigidBodySettings);
@@ -481,13 +481,14 @@ namespace PhysX
             const AZ::Vector3& position, const AZ::Vector3& dimensions /*= AZ::Vector3(1.0f)*/,
             const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/)
         {
-            Physics::ColliderConfiguration colliderConfig;
-            colliderConfig.m_collisionLayer = layer;
-            Physics::BoxShapeConfiguration shapeConfiguration;
-            shapeConfiguration.m_dimensions = dimensions;
+            auto colliderConfig = AZStd::make_shared<Physics::ColliderConfiguration>();
+            colliderConfig->m_collisionLayer = layer;
+            auto shapeConfiguration = AZStd::make_shared<Physics::BoxShapeConfiguration>();
+            shapeConfiguration->m_dimensions = dimensions;
+
             AzPhysics::StaticRigidBodyConfiguration rigidBodySettings;
             rigidBodySettings.m_position = position;
-            rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration);
+            rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfiguration);
 
             if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
             {

+ 4 - 1
Gems/WhiteBox/Code/Source/Components/EditorWhiteBoxColliderComponent.cpp

@@ -18,6 +18,7 @@
 
 #include <AzCore/Component/TransformBus.h>
 #include <AzCore/Serialization/EditContext.h>
+#include <AzCore/std/smart_ptr/make_shared.h>
 #include <AzFramework/Physics/PhysicsScene.h>
 #include <AzFramework/Physics/SystemBus.h>
 #include <AzFramework/Physics/Configuration/StaticRigidBodyConfiguration.h>
@@ -150,7 +151,9 @@ namespace WhiteBox
         bodyConfiguration.m_entityId = GetEntityId();
         bodyConfiguration.m_orientation = GetTransform()->GetWorldRotationQuaternion();
         bodyConfiguration.m_position = GetTransform()->GetWorldTranslation();
-        bodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&m_physicsColliderConfiguration, &m_meshShapeConfiguration);
+        bodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(
+            AZStd::make_shared<Physics::ColliderConfiguration>(m_physicsColliderConfiguration),
+            AZStd::make_shared<Physics::CookedMeshShapeConfiguration>(m_meshShapeConfiguration));
 
         if (m_sceneInterface)
         {