Restitution not working like it should?

Nickeeh
Posts: 14
Joined: Wed Feb 09, 2011 8:35 pm

Restitution not working like it should?

Post by Nickeeh »

In a zero gravity environment, I'm letting a unit-sized dynamic rigid body sphere with mass = 1.0f bounce between 2 kinematic objects. I'm doing this by giving the sphere a velocity with btRigidBody::setLinearVelocity() upon creation.

The sphere and the kinematic objects have an equal restitution, but even when the restitution is >= 1.0, the sphere loses velocity. I've output the restitution and the course of velocity for some restitution values and wondering how this can be. I'm using quite a cutting edge value of Bullet from the SVN trunk, latest update was on the 11th of April.

Note that I'm enforcing a maximum velocity of 120 on the sphere. Enforcing is done in a tickCallback, exactly like the "spaceship speedcap" in the wiki. :) Also, CCD is enabled on the sphere (else it goes way too fast).

Restitution: 1.0
Course of velocity
{0, 50, 0}
{0, 5.0019, 0}

Restitution: 1.1
Course of velocity
{0, 50, 0}
{0, -5.4981, 0}
{0, 5.18728, 0}

Restitution: 1.2
Course of velocity
{0, 50, 0}
{0, -16.9981, 0}
{0, 8.16622, 0}
{0, -0.76113, 0}

Restitution: 1.3
Course of velocity
{0, 50, 0}
{0, -29.4981, 0}
{0, 26.6687, 0}
{0, -11.8026, 0}
{0, 11.2669, 0}
{0, -2.05647, 0}
{0, -0.16802, 0}
{0, -0.11487, 0}
{0, 0, 0}

Restitution: 1.4
Course of velocity
{0, 50, 0}
{0, -42.9981, 0}
{0, 67.1551, 0}
{0, -78.4135, 0}
{0, 102.202, 0}
{0, -107.449, 0}
{0, 198.603, 0}
{0, 120, 0}
{0, -199.801, 0}
{0, -120, 0}
{0, 224.4, 0}
{0, 120, 0}

Restitution: 1.37
Course of velocity
{0, 50, 0}
{0, -38.8431, 0}
{0, 53.4513, 0}
{0, -42.6947, 0}
{0, 45.6122, 0}
{0, -38.091, 0}
{0, 27.7444, 0}
{0, -43.4922, 0}
{0, 50.6954, 0}
{0, -55.0297, 0}
{0, 94.9538, 0}
{0, -125.163, 0}
{0, -120, 0}
{0, 205.447, 0}
{0, 120, 0}
{0, -204.456, 0}
{0, -120, 0}
{0, 204.456, 0}
{0, 120, 0}

Here's a movie of the last run:
http://astrant.net/Bullet-restitution-weirdness.mov

So my question is basically: what am I doing wrong, and how can I fix this?

Thanks in advance,
youcancallmeAl
Posts: 5
Joined: Thu Jul 21, 2011 5:18 pm

Re: Restitution not working like it should?

Post by youcancallmeAl »

What are you using for your timestep? On my machine, for smaller timesteps, collisions cease to display any restitution at all... In particular, in the helloworld example, a timestep of 0.001 shows no restitution for two objects with coefficients of 0.9, whereas a timestep of 0.016 (floor(1/60)) shows fine restitution, and a timestep of 0.004 demonstrates behavior suggesting vastly lower restitution values, bordering on inelastic collision.

Might it be that this bug is causing your problems as well?