I have problem with bullet collisions. You can see problem on this video (around 0:18):


Objects are "embeded" inside vertical bars - that is not correct - they should be bouncing like at the beggining of the video. I am using sphere and box as bullet bodies. I have also enabled CCD, that improves stability a little, but problem is still there.

Pulsing bars are controlled with this code:

dist = distance I need the bar to change its position in a single frame
float g = (2 * dist) / (times.dTime); //dTime = 1/60
bars[i]->GetBulletBody()->setLinearVelocity(btVector3(0, 0, 0));
bars[i]->GetBulletBody()->setGravity(btVector3(0, speedUpFactor * g, 0));

I have constant update rate of physics and world, set to be 1/60 s.

  • 1
    \$\begingroup\$ It seems like the collision works just fine but the boxes are trapped below the bar when bars move over them. When extending bars, you could try to move any boxes below bars to the new level of bars. \$\endgroup\$ – wondra Aug 4 '14 at 18:40
  • \$\begingroup\$ @wondra Shouldn´t that be solved by Bullet? I mean, if ball is in position and bar move over it, I would expect Bullet to push ball out of collision and let him rest on top of the bar. \$\endgroup\$ – Martin Perry Aug 5 '14 at 17:04
  • \$\begingroup\$ Why should it? You didnt move the bar, you "teleported" it by t * dS, there is no continous movement on computer, only discrete. \$\endgroup\$ – wondra Aug 5 '14 at 17:07
  • \$\begingroup\$ @wondra I never set position manually, but through gravity change. If I do the same using force change, it has the same outcome. Before Bullet runs its loop, positions are correct (ball is above bar), but after that they are stucked inside each other. The only solution will be to "teleport" ball after Bullet loop, just before rendering, but that will mess my engine logic a little bit. \$\endgroup\$ – Martin Perry Aug 5 '14 at 17:10
  • \$\begingroup\$ That doesnt change the fact, you set the position discretely. \$\endgroup\$ – wondra Aug 5 '14 at 17:13

The problem is objects movement in digital world is discrete. In real world, it seems natural if a bar extends, it does is over time - computers cannot "move" objects, so they simulate this behaviour by setting their position by small steps dS.
However, if the movement of an object is too fast, it can produce weird resulst like shown on video - bars actually trapped balls below if extended too quickly.
There are generally three solutions:

  • make smaller steps - instead of moving t * dS each frame, move n times t/n * dS
  • non-discrete intersections - instead of point intersections use line segments
  • repair what is broken - if there is an illegal state (ball inside bar), fix it

    trapped ball
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.