Object falling when turning

Post Reply
Posts: 33
Joined: Fri Jun 05, 2020 8:36 am

Object falling when turning

Post by water »

I set up a concave sealed pipe and placed a convex ball in the pipe,
but when I turned the pipe (btQuaternion), the ball fell out of the pipe
How should I prevent this from happening?
Thank you for your help
User avatar
Posts: 698
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Object falling when turning

Post by drleviathan »

The ball easily falls out of the pipe because when the pipe is "teleported" to a new transform the two objects interpenetrate and the "interpenetration logic" is happy to push the ball to the outside. It doesn't know inside from outside: it just tries to resolve the overlap.

You could probably reduce the problem by:

(1) Take smaller substeps as you animate the pipe from transformA to transformB.

(2) Set the velocity of the pipe to agree with its motion as you move it. This will not animate the pipe forward for you (Bullet does not integrate keyframed objects -- you have to do it yourself via CustomMotionState or something) however the ball will be influenced by the pipe's velocity at collisions and it will be less likely to interpenetrate. Don't forget to set velocity to zero when the pipe reaches its final destination.

Those two measures should reduce the problem but will not solve it in general. For even more reliable results use convex decomposition to build a btCompoundShape of convex parts, and make them thick enough to keep the ball on the correct side. Alternatively, you could try using btGImpactShape stuff for your convex pipe (if not yet doing so), however I don't have any personal experience with that and don't know how helpful it would be.
Post Reply