Browse Source

Improved 2D example by setting attachment point (#407)

Jorrit Rouwe 2 years ago
parent
commit
5aeba6ad9d
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Samples/Tests/General/TwoDFunnelTest.cpp

+ 2 - 0
Samples/Tests/General/TwoDFunnelTest.cpp

@@ -35,6 +35,7 @@ void TwoDFunnelTest::Initialize()
 
 	// Constraint to limit motion in XY plane
 	SixDOFConstraintSettings constraint_settings;
+	constraint_settings.mSpace = EConstraintSpace::LocalToBodyCOM;
 	constraint_settings.MakeFreeAxis(SixDOFConstraintSettings::EAxis::RotationX); // Don't limit, we use inertia tensor to limit rotation
 	constraint_settings.MakeFreeAxis(SixDOFConstraintSettings::EAxis::RotationY); // Don't limit, we use inertia tensor to limit rotation
 	constraint_settings.MakeFreeAxis(SixDOFConstraintSettings::EAxis::RotationZ);
@@ -53,6 +54,7 @@ void TwoDFunnelTest::Initialize()
 			mBodyInterface->AddBody(body.GetID(), EActivation::Activate);
 
 			// Constraint the body to the XY plane
+			constraint_settings.mPosition1 = body.GetCenterOfMassPosition(); // Attach it at the initial position of the body for best precision
 			TwoBodyConstraint *constraint = constraint_settings.Create(Body::sFixedToWorld, body);
 			mPhysicsSystem->AddConstraint(constraint);