(0d12b23e4) Fix the crash due to NaN value in torso or head angle (#1349).
This commit is contained in:
@@ -369,7 +369,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
float movementAngle = MathUtils.VectorToAngle(movement) - MathHelper.PiOver2;
|
float movementAngle = MathUtils.VectorToAngle(movement) - MathHelper.PiOver2;
|
||||||
|
|
||||||
float mainLimbAngle = (MainLimb.type == LimbType.Torso ? TorsoAngle.Value : HeadAngle.Value) * Dir;
|
float mainLimbAngle = 0;
|
||||||
|
if (MainLimb.type == LimbType.Torso && TorsoAngle.HasValue)
|
||||||
|
{
|
||||||
|
mainLimbAngle = TorsoAngle.Value;
|
||||||
|
}
|
||||||
|
else if (MainLimb.type == LimbType.Head && HeadAngle.HasValue)
|
||||||
|
{
|
||||||
|
mainLimbAngle = HeadAngle.Value;
|
||||||
|
}
|
||||||
|
mainLimbAngle *= Dir;
|
||||||
while (MainLimb.Rotation - (movementAngle + mainLimbAngle) > MathHelper.Pi)
|
while (MainLimb.Rotation - (movementAngle + mainLimbAngle) > MathHelper.Pi)
|
||||||
{
|
{
|
||||||
movementAngle += MathHelper.TwoPi;
|
movementAngle += MathHelper.TwoPi;
|
||||||
@@ -701,6 +710,22 @@ namespace Barotrauma
|
|||||||
limb?.body.SmoothRotate(angle, torque, wrapAngle: false);
|
limb?.body.SmoothRotate(angle, torque, wrapAngle: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SmoothRotateWithoutWrapping(Limb limb, float angle, Limb referenceLimb, float torque)
|
||||||
|
{
|
||||||
|
//make sure the angle "has the same number of revolutions" as the reference limb
|
||||||
|
//(e.g. we don't want to rotate the legs to 0 if the torso is at 360, because that'd blow up the hip joints)
|
||||||
|
while (referenceLimb.Rotation - angle > MathHelper.TwoPi)
|
||||||
|
{
|
||||||
|
angle += MathHelper.TwoPi;
|
||||||
|
}
|
||||||
|
while (referenceLimb.Rotation - angle < -MathHelper.TwoPi)
|
||||||
|
{
|
||||||
|
angle -= MathHelper.TwoPi;
|
||||||
|
}
|
||||||
|
|
||||||
|
limb?.body.SmoothRotate(angle, torque, wrapAngle: false);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Flip()
|
public override void Flip()
|
||||||
{
|
{
|
||||||
base.Flip();
|
base.Flip();
|
||||||
|
|||||||
@@ -1035,8 +1035,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
CheckValidity();
|
CheckValidity();
|
||||||
|
|
||||||
CheckValidity();
|
|
||||||
|
|
||||||
UpdateNetPlayerPosition(deltaTime);
|
UpdateNetPlayerPosition(deltaTime);
|
||||||
CheckDistFromCollider();
|
CheckDistFromCollider();
|
||||||
UpdateCollisionCategories();
|
UpdateCollisionCategories();
|
||||||
|
|||||||
Reference in New Issue
Block a user