apply feedback from PR

Signed-off-by: greerdv <greerdv@amazon.com>
monroegm-disable-blank-issue-2
greerdv 4 years ago
parent ced217a96b
commit 5594a61ece

@ -369,10 +369,10 @@ namespace PhysX
depth++; depth++;
if (depth > numNodes) if (depth > numNodes)
{ {
AZ_Assert(false, "Loop detected in ragdoll configuration."); AZ_Error("PhysX Ragdoll", false, "Loop detected in hierarchy depth computation.");
return nodeDepths; return nodeDepths;
} }
size_t parentIndex = parentIndices[currentIndex]; const size_t parentIndex = parentIndices[currentIndex];
if (parentIndex >= numNodes || nodeDepths[currentIndex].m_depth != -1) if (parentIndex >= numNodes || nodeDepths[currentIndex].m_depth != -1)
{ {
@ -384,7 +384,7 @@ namespace PhysX
} }
currentIndex = nodeIndex; currentIndex = nodeIndex;
for (int i = depth; i >= 0 && currentIndex < numNodes; i--) for (int i = depth; i >= 0; i--)
{ {
nodeDepths[currentIndex] = { ancestorDepth + i, currentIndex }; nodeDepths[currentIndex] = { ancestorDepth + i, currentIndex };
currentIndex = parentIndices[currentIndex]; currentIndex = parentIndices[currentIndex];

@ -141,12 +141,12 @@ namespace PhysX
} }
} }
bool RagdollComponent::IsJointProjectionVisible() bool RagdollComponent::IsJointProjectionVisible() const
{ {
return m_enableJointProjection; return m_enableJointProjection;
} }
bool RagdollComponent::IsMaxMassRatioVisible() bool RagdollComponent::IsMaxMassRatioVisible() const
{ {
return m_enableMassRatioClamping; return m_enableMassRatioClamping;
} }
@ -423,9 +423,10 @@ namespace PhysX
}); });
bool massesClamped = false; 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) if (parentIndex < numNodes)
{ {
AzPhysics::RigidBody& nodeRigidBody = ragdoll->GetNode(nodeIndex)->GetRigidBody(); AzPhysics::RigidBody& nodeRigidBody = ragdoll->GetNode(nodeIndex)->GetRigidBody();
@ -438,7 +439,7 @@ namespace PhysX
const float clampedMass = AZStd::clamp(originalMass, minMass, maxMass); const float clampedMass = AZStd::clamp(originalMass, minMass, maxMass);
nodeRigidBody.SetMass(clampedMass); nodeRigidBody.SetMass(clampedMass);
massesClamped = true; massesClamped = true;
if (!AZ::IsCloseMag(originalMass, 0.0f)) if (!AZ::IsClose(originalMass, 0.0f))
{ {
// scale the inertia proportionally to how the mass was modified // scale the inertia proportionally to how the mass was modified
auto pxRigidBody = static_cast<physx::PxRigidDynamic*>(nodeRigidBody.GetNativePointer()); auto pxRigidBody = static_cast<physx::PxRigidDynamic*>(nodeRigidBody.GetNativePointer());

@ -103,8 +103,8 @@ namespace PhysX
Ragdoll* GetPhysXRagdoll(); Ragdoll* GetPhysXRagdoll();
const Ragdoll* GetPhysXRagdollConst() const; const Ragdoll* GetPhysXRagdollConst() const;
bool IsJointProjectionVisible(); bool IsJointProjectionVisible() const;
bool IsMaxMassRatioVisible(); bool IsMaxMassRatioVisible() const;
AzPhysics::SimulatedBodyHandle m_ragdollHandle = AzPhysics::InvalidSimulatedBodyHandle; AzPhysics::SimulatedBodyHandle m_ragdollHandle = AzPhysics::InvalidSimulatedBodyHandle;
AzPhysics::SceneHandle m_attachedSceneHandle = AzPhysics::InvalidSceneHandle; AzPhysics::SceneHandle m_attachedSceneHandle = AzPhysics::InvalidSceneHandle;

Loading…
Cancel
Save