Problem: Setting very small torques on free-floating bodies (no gravity) with zero angular damping slows down the object to stop. The expected behaviour would be small but constant rotation.
Testing this is easy - set up your body like this (I'm using entity class from tutorials, just to easily visualize the bodies)
- Code: Select all
eStage2 = sceneManager->CreateEntity();
eStage2->LoadMesh ("dumb.dat");
eStage2->m_curPosition.m_x = 0.0f;
eStage2->m_curPosition.m_y = 0.0f;
eStage2->m_curPosition.m_z = -2.0f;
eStage2->m_prevPosition = eStage2->m_curPosition;
// add a body with a Convex hull shape
shape = CreateNewtonBox (world, eStage2, 2);
Stage2Body = CreateRigidBody (world, eStage2, shape, 20.0f);
NewtonBodySetLinearDamping( Stage2Body, 0.00000000000f);
dFloat angularDamp[3];
angularDamp[0] = -0.0000000000000000000000000f;
angularDamp[1] = -0.0000000000000000000000000f;
angularDamp[2] = -0.0000000000000000000000000f;
NewtonBodySetAngularDamping(Stage2Body, angularDamp);
NewtonBodySetAutoSleep(Stage2Body,0);
NewtonReleaseCollision (world, shape);
Then, in ApplyForceAndTorqueCallback,
- Code: Select all
dFloat Torques[3];
Torques[0] = 0.0f;
Torques[1] = 0.0f;
Torques[2] = 0.0f;
if(FKey)
Torques[0] = 0.5f;
if(GKey)
Torques[0] = -0.5f;
NewtonBodySetTorque(body, Torques);
NewtonBodyGetOmega(body, mOmega);
FKey and GKey are booleans that are true when F and G keys are down. You can use them to apply torque to the object in + and - direction on x axis, effectively speeding up or slowing down rotation.
With this setup, you'll see that small omegas of less than 0.03 rps will "stop". Also, you'll notice that, if you just tap the F/G key and add very small torque, there will be a small Omega value displayed momentarily, and it will instantly go back to 0. I have the omega values displayed on screen:
- Code: Select all
Print (dVector (1.0f, 1.0f, 1.0f, 1.0f), 10, 124, "Omega: x = %5.8f", mOmega[0]);
Print (dVector (1.0f, 1.0f, 1.0f, 1.0f), 10, 144, "Omega: y = %5.8f", mOmega[1]);
Print (dVector (1.0f, 1.0f, 1.0f, 1.0f), 10, 164, "Omega: z = %5.8f", mOmega[2]);
Cheers,
Misho