Browse Source

Added support for constructing a RotatedTranslatedShape with an existing Shape*. (#134)

sherief 2 years ago
parent
commit
fc03b055af

+ 11 - 0
Jolt/Physics/Collision/Shape/RotatedTranslatedShape.cpp

@@ -45,6 +45,17 @@ RotatedTranslatedShape::RotatedTranslatedShape(const RotatedTranslatedShapeSetti
 	outResult.Set(this);
 	outResult.Set(this);
 }
 }
 
 
+RotatedTranslatedShape::RotatedTranslatedShape(Vec3Arg inPosition, QuatArg inRotation, const Shape *inShape) :
+	DecoratedShape(EShapeSubType::RotatedTranslated, inShape)
+{
+	// Calculate center of mass position
+	mCenterOfMass = inPosition + inRotation * mInnerShape->GetCenterOfMass(); 
+
+	// Store rotation (position is always zero because we center around the center of mass)
+	mRotation = inRotation;
+	mIsRotationIdentity = mRotation.IsClose(Quat::sIdentity());
+}
+
 MassProperties RotatedTranslatedShape::GetMassProperties() const
 MassProperties RotatedTranslatedShape::GetMassProperties() const
 {
 {
 	// Rotate inertia of child into place
 	// Rotate inertia of child into place

+ 1 - 0
Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h

@@ -42,6 +42,7 @@ public:
 	/// Constructor
 	/// Constructor
 									RotatedTranslatedShape() : DecoratedShape(EShapeSubType::RotatedTranslated) { }
 									RotatedTranslatedShape() : DecoratedShape(EShapeSubType::RotatedTranslated) { }
 									RotatedTranslatedShape(const RotatedTranslatedShapeSettings &inSettings, ShapeResult &outResult);
 									RotatedTranslatedShape(const RotatedTranslatedShapeSettings &inSettings, ShapeResult &outResult);
+									RotatedTranslatedShape(Vec3Arg inPosition, QuatArg inRotation, const Shape *inShape);
 
 
 	/// Access the rotation that is applied to the inner shape
 	/// Access the rotation that is applied to the inner shape
 	Quat							GetRotation() const										{ return mRotation; }
 	Quat							GetRotation() const										{ return mRotation; }