Speed Capping?

chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Speed Capping?

Post by chunky »

Heya, just a small question

What's the best way to cap the linear speed of btRigidBodies?

I was looking, and don't see any obvious standard constraints that would do the job - am I missing something there?

Should I just calculate the speed each frame and apply a force on the body in the opposite direction if it's too high?
Perhaps directly set the velocity of the body if I find the speed is too high, simply scaling the vector down a little? That last one doesn't seem to sit well overall [directly setting velocities usually bad...]

Thank-you very much,
Gary (-;
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Speed Capping?

Post by Erwin Coumans »

In most cases, it is fine to clamp the linear velocity, after calling stepSimulation.

The angular velocity is already clamped to a maximum in void btRigidBody::integrateVelocities(btScalar step).

Please let us know if this causes problems for you,
Erwin