Browse Source

Switched PathConstraint to use the cheaper RotationEulerConstraintPart

Jorrit Rouwe 3 years ago
parent
commit
08532d96a1

+ 3 - 3
Jolt/Physics/Constraints/PathConstraint.cpp

@@ -92,7 +92,7 @@ void PathConstraint::SetPath(const PathConstraintPath *inPath, float inPathFract
 
 		// Calculate initial orientation
 		if (mRotationConstraintType == EPathRotationConstraintType::FullyConstrained)
-			mInvInitialOrientation = RotationQuatConstraintPart::sGetInvInitialOrientation(*mBody1, *mBody2);
+			mInvInitialOrientation = RotationEulerConstraintPart::sGetInvInitialOrientation(*mBody1, *mBody2);
 	}
 }
 
@@ -161,7 +161,7 @@ void PathConstraint::CalculateConstraintProperties(float inDeltaTime)
 		break;
 
 	case EPathRotationConstraintType::ConstaintToPath:
-		// We need to calculate the inverse of the rotation from body 1 to body 2 for the current path position (see: RotationQuatConstraintPart::sGetInvInitialOrientation)
+		// We need to calculate the inverse of the rotation from body 1 to body 2 for the current path position (see: RotationEulerConstraintPart::sGetInvInitialOrientation)
 		// RotationBody2 = RotationBody1 * InitialOrientation <=> InitialOrientation^-1 = RotationBody2^-1 * RotationBody1
 		// We can express RotationBody2 in terms of RotationBody1: RotationBody2 = RotationBody1 * PathToBody1 * RotationClosestPointOnPath * PathToBody2^-1
 		// Combining these two: InitialOrientation^-1 = PathToBody2 * (PathToBody1 * RotationClosestPointOnPath)^-1
@@ -169,7 +169,7 @@ void PathConstraint::CalculateConstraintProperties(float inDeltaTime)
 		[[fallthrough]];
 
 	case EPathRotationConstraintType::FullyConstrained:
-		mRotationConstraintPart.CalculateConstraintProperties(*mBody1, transform1.GetRotation(), *mBody2, transform2.GetRotation(), mInvInitialOrientation);
+		mRotationConstraintPart.CalculateConstraintProperties(*mBody1, transform1.GetRotation(), *mBody2, transform2.GetRotation());
 		break;
 	}
 

+ 2 - 2
Jolt/Physics/Constraints/PathConstraint.h

@@ -9,7 +9,7 @@
 #include <Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h>
 #include <Jolt/Physics/Constraints/ConstraintPart/DualAxisConstraintPart.h>
 #include <Jolt/Physics/Constraints/ConstraintPart/HingeRotationConstraintPart.h>
-#include <Jolt/Physics/Constraints/ConstraintPart/RotationQuatConstraintPart.h>
+#include <Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h>
 
 JPH_NAMESPACE_BEGIN
 
@@ -168,7 +168,7 @@ private:
 
 	// Rotation constraint parts
 	HingeRotationConstraintPart		mHingeConstraintPart;									///< Constraint part that removes 2 degrees of rotation freedom
-	RotationQuatConstraintPart		mRotationConstraintPart;								///< Constraint part that removes all rotational freedom
+	RotationEulerConstraintPart		mRotationConstraintPart;								///< Constraint part that removes all rotational freedom
 };
 
 JPH_NAMESPACE_END