apply feedback from PR

Signed-off-by: greerdv <greerdv@amazon.com>
This commit is contained in:
greerdv
2021-11-16 15:56:56 +00:00
parent ced217a96b
commit 5594a61ece
3 changed files with 11 additions and 10 deletions
@@ -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];
@@ -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<physx::PxRigidDynamic*>(nodeRigidBody.GetNativePointer());
@@ -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;