CsabaConsulting / ARPhysics

Testing Physics engines with AR
MIT License
2 stars 0 forks source link

The slab structure bounces and jitters from the point of being placed #3

Open MrCsabaToth opened 4 years ago

MrCsabaToth commented 4 years ago

Even if I set the friction to 1.0 the slabs slowly slide on each other due to jitter and an impossible physical state. I'm trying to make them a kinetic body instead of a static body. Also start them as ISLAND_DISABLED state and then enable them at the time the ball is added. But so far that doesn't work.

MrCsabaToth commented 4 years ago

It helps that I start the simulation clock when the ball is placed (that's when the simulation actually have to start). Otherwise a huge amount of time can pass between the tower and the ball placement and that would cause the explosion of the slabs. This also guarantees no jitter and movement until the ball is hurdled. However at the point of the hurdle there's still an initial movement and then jitter.

MrCsabaToth commented 4 years ago

So there's no explosion any more just a small bounce. The slabs were floating on each other because the simulation engine needs a margin around the convex hulls. The engine uses that to compute normal vectors related to the simulation so it's needed.

https://pybullet.org/Bullet/phpBB3/viewtopic.php?f=9&t=2358&sid=c757996ff8459a33e0a7674d4e71e66e

De default margin is 0.04 which is way too big, we need rather 0.0025. That helps to decrease the visual gap.Sphere won't have problem. I also tried to transparently apply the gap (shrink the slabs a tiny bit) just within the Physics layer and then of the reverse transformation when the engine enforces sets the new positions.

There's still some bump thought so that logic right now is disabled.

MrCsabaToth commented 4 years ago

Eventually this can be solved by a proper selection of setSleepingThresholds. Maybe we'll also need to remove setActivationState(DISABLE_DEACTIVATION);. We'll see.