|
@@ -178,7 +178,7 @@ TEST_SUITE("WheeledVehicleTests")
|
|
|
// Start driving forward
|
|
// Start driving forward
|
|
|
controller->SetDriverInput(1.0f, 0.0f, 0.0f, 0.0f);
|
|
controller->SetDriverInput(1.0f, 0.0f, 0.0f, 0.0f);
|
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
|
- c.Simulate(1.0f);
|
|
|
|
|
|
|
+ c.Simulate(2.0f);
|
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
|
RVec3 pos2 = body->GetPosition();
|
|
RVec3 pos2 = body->GetPosition();
|
|
|
CHECK_APPROX_EQUAL(pos2.GetX(), 0, 1.0e-2_r); // Not moving left/right
|
|
CHECK_APPROX_EQUAL(pos2.GetX(), 0, 1.0e-2_r); // Not moving left/right
|
|
@@ -228,7 +228,7 @@ TEST_SUITE("WheeledVehicleTests")
|
|
|
// Turn right
|
|
// Turn right
|
|
|
controller->SetDriverInput(1.0f, 1.0f, 0.0f, 0.0f);
|
|
controller->SetDriverInput(1.0f, 1.0f, 0.0f, 0.0f);
|
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
|
- c.Simulate(1.0f);
|
|
|
|
|
|
|
+ c.Simulate(2.0f);
|
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
|
Vec3 omega = body->GetAngularVelocity();
|
|
Vec3 omega = body->GetAngularVelocity();
|
|
|
CHECK(omega.GetY() < -0.4f); // Rotating right
|
|
CHECK(omega.GetY() < -0.4f); // Rotating right
|
|
@@ -237,7 +237,7 @@ TEST_SUITE("WheeledVehicleTests")
|
|
|
// Hand brake
|
|
// Hand brake
|
|
|
controller->SetDriverInput(0.0f, 0.0f, 0.0f, 1.0f);
|
|
controller->SetDriverInput(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
|
- c.Simulate(5.0f);
|
|
|
|
|
|
|
+ c.Simulate(7.0f);
|
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
|
CHECK(!body->IsActive()); // Car should have gone to sleep
|
|
CHECK(!body->IsActive()); // Car should have gone to sleep
|
|
|
vel = body->GetLinearVelocity();
|
|
vel = body->GetLinearVelocity();
|
|
@@ -246,7 +246,7 @@ TEST_SUITE("WheeledVehicleTests")
|
|
|
// Turn left
|
|
// Turn left
|
|
|
controller->SetDriverInput(1.0f, -1.0f, 0.0f, 0.0f);
|
|
controller->SetDriverInput(1.0f, -1.0f, 0.0f, 0.0f);
|
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
c.GetBodyInterface().ActivateBody(body->GetID());
|
|
|
- c.Simulate(1.0f);
|
|
|
|
|
|
|
+ c.Simulate(2.0f);
|
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
CheckOnGround(constraint, settings, floor_id);
|
|
|
omega = body->GetAngularVelocity();
|
|
omega = body->GetAngularVelocity();
|
|
|
CHECK(omega.GetY() > 0.4f); // Rotating left
|
|
CHECK(omega.GetY() > 0.4f); // Rotating left
|
|
@@ -305,6 +305,14 @@ TEST_SUITE("WheeledVehicleTests")
|
|
|
Body *body = constraint->GetVehicleBody();
|
|
Body *body = constraint->GetVehicleBody();
|
|
|
WheeledVehicleController *controller = static_cast<WheeledVehicleController *>(constraint->GetController());
|
|
WheeledVehicleController *controller = static_cast<WheeledVehicleController *>(constraint->GetController());
|
|
|
|
|
|
|
|
|
|
+ // Give the wheels extra grip
|
|
|
|
|
+ controller->SetTireMaxImpulseCallback(
|
|
|
|
|
+ [](uint, float &outLongitudinalImpulse, float &outLateralImpulse, float inSuspensionImpulse, float inLongitudinalFriction, float inLateralFriction, float, float, float)
|
|
|
|
|
+ {
|
|
|
|
|
+ outLongitudinalImpulse = 10.0f * inLongitudinalFriction * inSuspensionImpulse;
|
|
|
|
|
+ outLateralImpulse = inLateralFriction * inSuspensionImpulse;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
// Simulate till vehicle rests on block
|
|
// Simulate till vehicle rests on block
|
|
|
bool vehicle_on_floor = false;
|
|
bool vehicle_on_floor = false;
|
|
|
for (float time = 0; time < 2.0f; time += c.GetDeltaTime())
|
|
for (float time = 0; time < 2.0f; time += c.GetDeltaTime())
|