colliding object with constant speed

Please don't post Bullet support questions here, use the above forums instead.
csch
Posts: 1
Joined: Tue Feb 02, 2010 5:11 am

colliding object with constant speed

Post by csch »

Hi everyone,

sorry if this has been asked and answered before but i couldn't apply anything from related threads to my case and i'm also a gigantic bullet greenhorn ;-)

What's the best way to setup a physical world where i have a sphere that collides with other objects but remains moving with a constant speed?

A metapher for what i want to achieve is a squash court with an accelerated ball that doesn't get faster or slower and even though it gets redirected on collision it doesn't change its speed.

What i setup so far:

- a discrete dynamics world with no gravity
- 6 walls using static plane shapes with mass 0 and friction 0
- a ball (sphere shape) with mass 1 and friction 0 and with a central force [x:0, y:0, y:-50] applied to it to send it straight along the z axis to the back wall.

The current effect is that the ball starts moving with the right speed and gets redirected after colliding with the back wall but gets a lot slower after the collision.

What attributes (as in restitution, damping etc.) of which objects (ball, planes) do i have to tweak to achieve a constant speed for the ball?

thx,

christian
User avatar
Dennis
Posts: 12
Joined: Sat Jun 23, 2007 9:13 pm
Location: San Francisco

Re: colliding object with constant speed

Post by Dennis »

In theory it should be enough to set restitution to 1.0, no damping and give it an infinite moment of inertia. Part of the behavior you see now is probably due to transfer of linear momentum to angular momentum. It sounds like you don't want this, so setting moment of inertia to infinite should do the trick.

However, due to the way collision response is implemented in the solver the result can deviate a little bit. If you really want the exact same output speed, I'd just normalize the linear velocity every frame and set it to whatever you want (not altering the direction of course)

Dennis