Browse Source

Rewrote comment / conveyor belt code to use more conventional w x r instead of -r x w

Jorrit Rouwe 2 years ago
parent
commit
706b29f888

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

@@ -48,7 +48,7 @@ public:
 	float					mInvInertiaScale2 = 1.0f;			///< Scale factor for the inverse inertia of body 2 (usually same as mInvMassScale2)
 	bool					mIsSensor;							///< If the contact should be treated as a sensor vs body contact (no collision response)
 	Vec3					mRelativeSurfaceVelocity = Vec3::sZero(); ///< Relative surface velocity between the bodies (world space surface velocity of body 2 - world space surface velocity of body 1), can be used to create a conveyor belt effect
-	Vec3					mRelativeAngularSurfaceVelocity = Vec3::sZero(); ///< Relative angular surface velocity between the bodies (world space angular surface velocity of body 2 - world space angular surface velocity of body 1). Note that this angular velocity is relative to the center of mass of body 1, so if you want it relative to body 2's center of mass you need to add (body 2 world space center of mass - body 1 world space center of mass) x mRelativeAngularSurfaceVelocity to mRelativeSurfaceVelocity.
+	Vec3					mRelativeAngularSurfaceVelocity = Vec3::sZero(); ///< Relative angular surface velocity between the bodies (world space angular surface velocity of body 2 - world space angular surface velocity of body 1). Note that this angular velocity is relative to the center of mass of body 1, so if you want it relative to body 2's center of mass you need to add body 2 angular velocity x (body 1 world space center of mass - body 2 world space center of mass) to mRelativeSurfaceVelocity.
 };
 
 /// Return value for the OnContactValidate callback. Determines if the contact is being processed or not.

+ 1 - 1
Samples/Tests/General/ConveyorBeltTest.cpp

@@ -96,7 +96,7 @@ void ConveyorBeltTest::OnContactAdded(const Body &inBody1, const Body &inBody2,
 		Vec3 body2_angular_surface_velocity = body2_angular? inBody2.GetRotation() * cLocalSpaceAngularVelocity : Vec3::sZero();
 
 		// Note that the angular velocity is the angular velocity around body 1's center of mass, so we need to add the linear velocity of body 2's center of mass
-		Vec3 body2_linear_surface_velocity = body2_angular? Vec3(inBody2.GetCenterOfMassPosition() - inBody1.GetCenterOfMassPosition()).Cross(body2_angular_surface_velocity) : Vec3::sZero();
+		Vec3 body2_linear_surface_velocity = body2_angular? body2_angular_surface_velocity.Cross(Vec3(inBody1.GetCenterOfMassPosition() - inBody2.GetCenterOfMassPosition())) : Vec3::sZero();
 		
 		// Calculate the relative angular surface velocity
 		ioSettings.mRelativeSurfaceVelocity = body2_linear_surface_velocity;