3 ms·
His engine is doing a pretty good job. I looked at the code and can't figure out how he gets stable multipoint contact for the pile of balls out of that. There'
by Animats 6y ago
His engine is doing a pretty good job. I looked at the code and can't figure out how he gets stable multipoint contact for the pile of balls out of that. There's no linear complementary problem solver. There's no elaborate integrator. Yet it's resolving problems where balls are in contact with many other balls, and where many balls are constrained in multiple directions. Naive approaches to that usually go "sprong" and send something flying.
Maybe it's just using a really tiny physics time step. That allows forces to propagate through the whole pile over many time steps.
- johndough 6y agoThe trick is to only apply positive impulses and discard negative ones: https://github.com/IainWinter/IwEngine/blob/6f94a946a90db989412ff29320a0baeca7a5f8cb/IwEngine/src/physics/Dynamics/ImpulseSolver.cpp#L26 https://github.com/IainWinter/IwEngine/blob/6f94a946a90db989... Things will sort themselves out over several frames. Objects might sink into each other a bit, but that is generally not very noticeable unless you make huge piles of spheres. However, it might quickly become a problem in 2D, since you only need a quadratic number of objects to get a "critical" pile, compared to a cubic number of spheres in 3D.
- IainWinter 6y agoThat makes it so nothing explodes, and then there is a second solver that does a small raw position correction after. So it's not lifelike realism, but it works to stop objects sinking into each other too much. There is still a small error though, I'd have to look into more iterations and all that.