fixed joint crash when no lead entity is selected (#2867)
Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
This commit is contained in:
@@ -46,11 +46,26 @@ namespace PhysX
|
||||
|
||||
JointComponent::LeadFollowerInfo leadFollowerInfo;
|
||||
ObtainLeadFollowerInfo(leadFollowerInfo);
|
||||
if (!leadFollowerInfo.m_followerActor)
|
||||
if (leadFollowerInfo.m_followerActor == nullptr ||
|
||||
leadFollowerInfo.m_followerBody == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if there is no lead body, this will be a constraint of the follower's global position, so use invalid body handle.
|
||||
AzPhysics::SimulatedBodyHandle parentHandle = AzPhysics::InvalidSimulatedBodyHandle;
|
||||
if (leadFollowerInfo.m_leadBody != nullptr)
|
||||
{
|
||||
parentHandle = leadFollowerInfo.m_leadBody->m_bodyHandle;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_TracePrintf(
|
||||
"PhysX", "Entity [%s] Ball Joint component missing lead entity. This joint will be a global constraint on the follower's global position.",
|
||||
GetEntity()->GetName().c_str());
|
||||
}
|
||||
|
||||
|
||||
BallJointConfiguration configuration;
|
||||
configuration.m_parentLocalPosition = leadFollowerInfo.m_leadLocal.GetTranslation();
|
||||
configuration.m_parentLocalRotation = leadFollowerInfo.m_leadLocal.GetRotation();
|
||||
@@ -65,7 +80,7 @@ namespace PhysX
|
||||
m_jointHandle = sceneInterface->AddJoint(
|
||||
leadFollowerInfo.m_followerBody->m_sceneOwner,
|
||||
&configuration,
|
||||
leadFollowerInfo.m_leadBody->m_bodyHandle,
|
||||
parentHandle,
|
||||
leadFollowerInfo.m_followerBody->m_bodyHandle);
|
||||
m_jointSceneOwner = leadFollowerInfo.m_followerBody->m_sceneOwner;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user