From 9f0075c9dfeda0869a50d30c3a2916d15b40bdd2 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Fri, 23 Apr 2021 11:00:08 +0100 Subject: [PATCH] cleanup of create ragdoll ptr handling --- .../Code/Source/PhysXCharacters/API/CharacterUtils.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp b/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp index 75cf536403..893e622701 100644 --- a/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp +++ b/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp @@ -177,14 +177,13 @@ namespace PhysX return nullptr; } - Ragdoll* ragdoll = aznew Ragdoll(sceneHandle); + AZStd::unique_ptr ragdoll = AZStd::make_unique(sceneHandle); ragdoll->SetParentIndices(configuration.m_parentIndices); auto* sceneInterface = AZ::Interface::Get(); if (sceneInterface == nullptr) { AZ_Error("PhysX Ragdoll", false, "Unable to Create Ragdoll, Physics Scene Interface is missing."); - delete ragdoll; return nullptr; } @@ -207,7 +206,6 @@ namespace PhysX else { AZ_Error("PhysX Ragdoll", false, "Failed to create collider shape for ragdoll node %s", nodeConfig.m_debugName.c_str()); - delete ragdoll; return nullptr; } } @@ -289,7 +287,6 @@ namespace PhysX else { AZ_Error("PhysX Ragdoll", false, "Failed to create joint for node index %i.", nodeIndex); - delete ragdoll; return nullptr; } } @@ -301,8 +298,8 @@ namespace PhysX } ragdoll->SetRootIndex(rootIndex); - - return ragdoll; + + return ragdoll.release(); } physx::PxD6JointDrive CreateD6JointDrive(float stiffness, float dampingRatio, float forceLimit)