From 5594a61ece5f502b9f49e425529c1b79f5f0b5d0 Mon Sep 17 00:00:00 2001 From: greerdv Date: Tue, 16 Nov 2021 15:56:56 +0000 Subject: [PATCH] apply feedback from PR Signed-off-by: greerdv --- .../Source/PhysXCharacters/API/CharacterUtils.cpp | 6 +++--- .../PhysXCharacters/Components/RagdollComponent.cpp | 11 ++++++----- .../PhysXCharacters/Components/RagdollComponent.h | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp b/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp index 05de1055b2..46f4c04880 100644 --- a/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp +++ b/Gems/PhysX/Code/Source/PhysXCharacters/API/CharacterUtils.cpp @@ -369,10 +369,10 @@ namespace PhysX depth++; if (depth > numNodes) { - AZ_Assert(false, "Loop detected in ragdoll configuration."); + AZ_Error("PhysX Ragdoll", false, "Loop detected in hierarchy depth computation."); return nodeDepths; } - size_t parentIndex = parentIndices[currentIndex]; + const size_t parentIndex = parentIndices[currentIndex]; if (parentIndex >= numNodes || nodeDepths[currentIndex].m_depth != -1) { @@ -384,7 +384,7 @@ namespace PhysX } currentIndex = nodeIndex; - for (int i = depth; i >= 0 && currentIndex < numNodes; i--) + for (int i = depth; i >= 0; i--) { nodeDepths[currentIndex] = { ancestorDepth + i, currentIndex }; currentIndex = parentIndices[currentIndex]; diff --git a/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.cpp b/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.cpp index f1b3db69e6..7615a175d1 100644 --- a/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.cpp +++ b/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.cpp @@ -141,12 +141,12 @@ namespace PhysX } } - bool RagdollComponent::IsJointProjectionVisible() + bool RagdollComponent::IsJointProjectionVisible() const { return m_enableJointProjection; } - bool RagdollComponent::IsMaxMassRatioVisible() + bool RagdollComponent::IsMaxMassRatioVisible() const { return m_enableMassRatioClamping; } @@ -423,9 +423,10 @@ namespace PhysX }); bool massesClamped = false; - for (const auto [depth, nodeIndex] : nodeDepths) + for (const auto& nodeDepth : nodeDepths) { - size_t parentIndex = ragdollConfiguration.m_parentIndices[nodeIndex]; + const size_t nodeIndex = nodeDepth.m_index; + const size_t parentIndex = ragdollConfiguration.m_parentIndices[nodeIndex]; if (parentIndex < numNodes) { AzPhysics::RigidBody& nodeRigidBody = ragdoll->GetNode(nodeIndex)->GetRigidBody(); @@ -438,7 +439,7 @@ namespace PhysX const float clampedMass = AZStd::clamp(originalMass, minMass, maxMass); nodeRigidBody.SetMass(clampedMass); massesClamped = true; - if (!AZ::IsCloseMag(originalMass, 0.0f)) + if (!AZ::IsClose(originalMass, 0.0f)) { // scale the inertia proportionally to how the mass was modified auto pxRigidBody = static_cast(nodeRigidBody.GetNativePointer()); diff --git a/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.h b/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.h index 1eb46d183d..3ef59bf623 100644 --- a/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.h +++ b/Gems/PhysX/Code/Source/PhysXCharacters/Components/RagdollComponent.h @@ -103,8 +103,8 @@ namespace PhysX Ragdoll* GetPhysXRagdoll(); const Ragdoll* GetPhysXRagdollConst() const; - bool IsJointProjectionVisible(); - bool IsMaxMassRatioVisible(); + bool IsJointProjectionVisible() const; + bool IsMaxMassRatioVisible() const; AzPhysics::SimulatedBodyHandle m_ragdollHandle = AzPhysics::InvalidSimulatedBodyHandle; AzPhysics::SceneHandle m_attachedSceneHandle = AzPhysics::InvalidSceneHandle;