Browse Source

Removed assert that translation needs to be zero in Mat44::GetQuaternion (#1002)

Jorrit Rouwe 1 year ago
parent
commit
0191c72d5f

+ 0 - 2
Jolt/Math/Mat44.inl

@@ -782,8 +782,6 @@ bool Mat44::SetInversed3x3(Mat44Arg inM)
 
 Quat Mat44::GetQuaternion() const
 {
-	JPH_ASSERT(mCol[3] == Vec4(0, 0, 0, 1));
-
 	float tr = mCol[0].mF32[0] + mCol[1].mF32[1] + mCol[2].mF32[2];
 
 	if (tr >= 0.0f)

+ 1 - 1
Jolt/Physics/Collision/Shape/CapsuleShape.cpp

@@ -384,7 +384,7 @@ void CapsuleShape::TransformShape(Mat44Arg inCenterOfMassTransform, TransformedS
 {
 	Vec3 scale;
 	Mat44 transform = inCenterOfMassTransform.Decompose(scale);
-	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetRotation().GetQuaternion(), this, BodyID(), SubShapeIDCreator());
+	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetQuaternion(), this, BodyID(), SubShapeIDCreator());
 	ts.SetShapeScale(ScaleHelpers::MakeUniformScale(scale.Abs()));
 	ioCollector.AddHit(ts);
 }

+ 1 - 1
Jolt/Physics/Collision/Shape/CylinderShape.cpp

@@ -364,7 +364,7 @@ void CylinderShape::TransformShape(Mat44Arg inCenterOfMassTransform, Transformed
 {
 	Vec3 scale;
 	Mat44 transform = inCenterOfMassTransform.Decompose(scale);
-	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetRotation().GetQuaternion(), this, BodyID(), SubShapeIDCreator());
+	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetQuaternion(), this, BodyID(), SubShapeIDCreator());
 	Vec3 abs_scale = scale.Abs();
 	float xz = 0.5f * (abs_scale.GetX() + abs_scale.GetZ());
 	ts.SetShapeScale(Vec3(xz, abs_scale.GetY(), xz));

+ 1 - 1
Jolt/Physics/Collision/Shape/Shape.cpp

@@ -58,7 +58,7 @@ void Shape::TransformShape(Mat44Arg inCenterOfMassTransform, TransformedShapeCol
 {
 	Vec3 scale;
 	Mat44 transform = inCenterOfMassTransform.Decompose(scale);
-	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetRotation().GetQuaternion(), this, BodyID(), SubShapeIDCreator());
+	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetQuaternion(), this, BodyID(), SubShapeIDCreator());
 	ts.SetShapeScale(scale);
 	ioCollector.AddHit(ts);
 }

+ 1 - 1
Jolt/Physics/Collision/Shape/SphereShape.cpp

@@ -307,7 +307,7 @@ void SphereShape::TransformShape(Mat44Arg inCenterOfMassTransform, TransformedSh
 {
 	Vec3 scale;
 	Mat44 transform = inCenterOfMassTransform.Decompose(scale);
-	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetRotation().GetQuaternion(), this, BodyID(), SubShapeIDCreator());
+	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetQuaternion(), this, BodyID(), SubShapeIDCreator());
 	ts.SetShapeScale(ScaleHelpers::MakeUniformScale(scale.Abs()));
 	ioCollector.AddHit(ts);
 }

+ 1 - 1
Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp

@@ -410,7 +410,7 @@ void TaperedCapsuleShape::TransformShape(Mat44Arg inCenterOfMassTransform, Trans
 {
 	Vec3 scale;
 	Mat44 transform = inCenterOfMassTransform.Decompose(scale);
-	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetRotation().GetQuaternion(), this, BodyID(), SubShapeIDCreator());
+	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetQuaternion(), this, BodyID(), SubShapeIDCreator());
 	ts.SetShapeScale(scale.GetSign() * ScaleHelpers::MakeUniformScale(scale.Abs()));
 	ioCollector.AddHit(ts);
 }

+ 1 - 1
Jolt/Physics/Collision/Shape/TriangleShape.cpp

@@ -317,7 +317,7 @@ void TriangleShape::TransformShape(Mat44Arg inCenterOfMassTransform, Transformed
 {
 	Vec3 scale;
 	Mat44 transform = inCenterOfMassTransform.Decompose(scale);
-	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetRotation().GetQuaternion(), this, BodyID(), SubShapeIDCreator());
+	TransformedShape ts(RVec3(transform.GetTranslation()), transform.GetQuaternion(), this, BodyID(), SubShapeIDCreator());
 	ts.SetShapeScale(mConvexRadius == 0.0f? scale : scale.GetSign() * ScaleHelpers::MakeUniformScale(scale.Abs()));
 	ioCollector.AddHit(ts);
 }

+ 1 - 1
Jolt/Physics/Collision/TransformedShape.h

@@ -108,7 +108,7 @@ public:
 	{
 		Vec3 scale;
 		RMat44 rot_trans = inTransform.Decompose(scale);
-		SetWorldTransform(rot_trans.GetTranslation(), rot_trans.GetRotation().GetQuaternion(), scale);
+		SetWorldTransform(rot_trans.GetTranslation(), rot_trans.GetQuaternion(), scale);
 	}
 
 	/// Calculates the world transform including scale of this shape (not from the center of mass but in the space the shape was created)

+ 2 - 2
Jolt/Physics/Ragdoll/Ragdoll.cpp

@@ -552,7 +552,7 @@ void Ragdoll::SetPose(RVec3Arg inRootOffset, const Mat44 *inJointMatrices, bool
 	for (int i = 0; i < (int)mBodyIDs.size(); ++i)
 	{
 		const Mat44 &joint = inJointMatrices[i];
-		bi.SetPositionAndRotation(mBodyIDs[i], inRootOffset + joint.GetTranslation(), joint.GetRotation().GetQuaternion(), EActivation::DontActivate);
+		bi.SetPositionAndRotation(mBodyIDs[i], inRootOffset + joint.GetTranslation(), joint.GetQuaternion(), EActivation::DontActivate);
 	}
 }
 
@@ -608,7 +608,7 @@ void Ragdoll::DriveToPoseUsingKinematics(RVec3Arg inRootOffset, const Mat44 *inJ
 	for (int i = 0; i < (int)mBodyIDs.size(); ++i)
 	{
 		const Mat44 &joint = inJointMatrices[i];
-		bi.MoveKinematic(mBodyIDs[i], inRootOffset + joint.GetTranslation(), joint.GetRotation().GetQuaternion(), inDeltaTime);
+		bi.MoveKinematic(mBodyIDs[i], inRootOffset + joint.GetTranslation(), joint.GetQuaternion(), inDeltaTime);
 	}
 }
 

+ 1 - 1
Jolt/Skeleton/SkeletonPose.cpp

@@ -47,7 +47,7 @@ void SkeletonPose::CalculateJointStates()
 
 		JointState &joint = mJoints[i];
 		joint.mTranslation = local_transform.GetTranslation();
-		joint.mRotation = local_transform.GetRotation().GetQuaternion();
+		joint.mRotation = local_transform.GetQuaternion();
 	}
 }
 

+ 1 - 1
Samples/Tests/Character/CharacterSpaceShipTest.cpp

@@ -81,7 +81,7 @@ void CharacterSpaceShipTest::PrePhysicsUpdate(const PreUpdateParams &inParams)
 
 	// Update the character rotation and its up vector to match the new up vector of the ship
 	mCharacter->SetUp(new_space_ship_transform.GetAxisY());
-	mCharacter->SetRotation(new_space_ship_transform.GetRotation().GetQuaternion());
+	mCharacter->SetRotation(new_space_ship_transform.GetQuaternion());
 
 	// Draw character pre update (the sim is also drawn pre update)
 	// Note that we have first updated the position so that it matches the new position of the ship