Browse Source

Add GetCenterOfMassTransform to BodyInterface (#83)

Joshie 3 years ago
parent
commit
f4d5f82394
2 changed files with 10 additions and 0 deletions
  1. 9 0
      Jolt/Physics/Body/BodyInterface.cpp
  2. 1 0
      Jolt/Physics/Body/BodyInterface.h

+ 9 - 0
Jolt/Physics/Body/BodyInterface.cpp

@@ -405,6 +405,15 @@ Mat44 BodyInterface::GetWorldTransform(const BodyID &inBodyID) const
 		return Mat44::sIdentity();
 		return Mat44::sIdentity();
 }
 }
 
 
+Mat44 BodyInterface::GetCenterOfMassTransform(const BodyID &inBodyID) const
+{
+	BodyLockRead lock(*mBodyLockInterface, inBodyID);
+	if (lock.Succeeded())
+		return lock.GetBody().GetCenterOfMassTransform();
+	else
+		return Mat44::sIdentity();
+}
+
 void BodyInterface::MoveKinematic(const BodyID &inBodyID, Vec3Arg inTargetPosition, QuatArg inTargetRotation, float inDeltaTime)
 void BodyInterface::MoveKinematic(const BodyID &inBodyID, Vec3Arg inTargetPosition, QuatArg inTargetRotation, float inDeltaTime)
 {
 {
 	BodyLockWrite lock(*mBodyLockInterface, inBodyID);
 	BodyLockWrite lock(*mBodyLockInterface, inBodyID);

+ 1 - 0
Jolt/Physics/Body/BodyInterface.h

@@ -116,6 +116,7 @@ public:
 	void						SetRotation(const BodyID &inBodyID, QuatArg inRotation, EActivation inActivationMode);
 	void						SetRotation(const BodyID &inBodyID, QuatArg inRotation, EActivation inActivationMode);
 	Quat						GetRotation(const BodyID &inBodyID) const;
 	Quat						GetRotation(const BodyID &inBodyID) const;
 	Mat44						GetWorldTransform(const BodyID &inBodyID) const;
 	Mat44						GetWorldTransform(const BodyID &inBodyID) const;
+	Mat44						GetCenterOfMassTransform(const BodyID &inBodyID) const;
 	///@}
 	///@}
 
 
 	/// Set velocity of body such that it will be positioned at inTargetPosition/Rotation in inDeltaTime seconds (will activate body if needed)
 	/// Set velocity of body such that it will be positioned at inTargetPosition/Rotation in inDeltaTime seconds (will activate body if needed)