dropped object does not come to rest on longer edge

Post Reply
ed_welch
Posts: 43
Joined: Wed Mar 04, 2015 6:16 pm

dropped object does not come to rest on longer edge

Post by ed_welch »

I have a problem if a capsule shape object it dropped on to the ground on it's top or bottom side, it comes to rest on the same edge, which is round (because it's a capsule). It should fall over onto its longer edge. I also notice the same problem with btConvexHullShape - the object come to standstill on the narrowest edge and it should topple over onto it's longer edge. Does anyone know a solution for this problem?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: dropped object does not come to rest on longer edge

Post by drleviathan »

Due to the capsule's symmetry, the perfection of its orientation, and the simplicity of the Bullet deactivation logic I could see how this would happen. Here are some strategies you could try to reduce the likelihood bodies will be deactivated in a state of unstable balance. Dunno which will work best for you since there are tradeoffs for each change.

(1) Increase restitution (bounciness) of objects and the floor. Low restitution can cause the minimum velocity thresholds to be met sooner and so shapes are more likely to stop before they topple. However, this could cause objects to take longer to settle.

(2) Reduce damping. The damping feature helps the simulation sink energy and keeps it stable but if your scene is relatively low energy and doesn't have big piles of interacting objects then you can get by with little or no damping.

(3) Lower the velocity deactivation thresholds (aka the "sleeping" thresholds). Bullet will deactivate an active object if both its velocities are below some thresholds for longer than 2 seconds. Note: when the thresholds are too high even some ballistic objects could be deactivated at the apex of their parabola when falling under low-gravity. The default thresholds are (I believe) 0.8 m/sec for the linear and 1.0 radians/sec for the angular. These can be changed on a per-body basis. If you set these too low then active objects might never settle, especially when in a pile with other dynanic objects. Use btRigidBody::setSleepingThresholds(btScalar linear, btScalar angular).

(4) Activate your bodies with a slight non-zero angular velocity. This might be a way to convince a particular bit of content to tumble into an unbalanced state rather than fall straight down onto a symmetric contact.

(5) Unbalance your objects. A capsule might be a simple approximate shape for your object but most real objects are not so perfect. You can introduce asymmetry by wrapping the btCapsuleShape with a btCompoundShape and giving the sub-shape a slight transform off to one side. Effectively this would shift the body's center of mass away from the symmetric center. However, you might have to adjust the render offset of your visible geometry to keep it aligned with the collision shape.
ed_welch
Posts: 43
Joined: Wed Mar 04, 2015 6:16 pm

Re: dropped object does not come to rest on longer edge

Post by ed_welch »

Thanks for your answer, drleviathan. Adding small amount of angular velocity seemed to do the trick
Post Reply