3 ms·
Note that there are multiple approaches to implementing rigid body simulation (especially when it comes to resolving collisions), and each of them all have thei
by cyber_kinetist 4y ago
Note that there are multiple approaches to implementing rigid body simulation (especially when it comes to resolving collisions), and each of them all have their benefits and disadvantages.
For example, Mujoco uses a soft contact model where penetrations can happen, this can be undesirable for some use cases but might not really matter for most people. Mujoco also assumes every object in the simulation to be defined beforehand and remain static. This is good for performance (since memory can be preallocated beforehand, some values can be precalculated, etc.) but the drawback is that it's hard to dynamically add/remove/change objects in your simulation. In overall, Mujoco is fine-tuned and intended to be used in robotics simulations, and might have some undesirable properties when used in other applications like games and 3D animation.
Although Baraff's notes for rigid body simulation are more than 20 years ago, it's still roughly the same method used in most game physics engines (PhysX, Havok, Bullet, etc.). It struggles with modelling accurate friction (you can't do that much with LCP constraints), and the contact solver can be unstable at times (especially when CCD comes into the picture), but it's still really performant and "realistic" enough for a wide variety of games and animation.
- Animats 4y agoI was doing spring/damper collision ragdolls in the late 1990s.[1] Slower, but more accurate. Friction works. Not real time back then, though. Not enough CPU power yet. You can be too early. Impulse-constraint systems have a "boink" problem. Velocities change instantaneously. This looks OK for small objects, but bad for large ones. [1] https://www.youtube.com/watch?v=5lHqEwk7YHs https://www.youtube.com/watch?v=5lHqEwk7YHs
- erwincoumans 4y agoHi John, I recall that, those ragdolls falling down stairs. From what I heard from a few Pixel employees, Pixar uses Bullet for some rigid body VFX effects, and Bullet still uses velocity-level LCP in combination with maximal coordinate constraints or with Featherstone-style reduced coordinate forward dynamics. The impulse/velocity-based contact model allows to model arbitrary soft contact (using contact force mixing (CFM) and error reduction parameter (ERP) terms), similar to spring-damper or MuJoCo-style contact (for MuJoCo see https://mujoco.readthedocs.io/en/latest/computation.html https://mujoco.readthedocs.io/en/latest/computation.html and https://github.com/deepmind/mujoco https://github.com/deepmind/mujoco). For the last 10 years we use this also for robotics simulation for quadruped robots and robot arm grasping contact. Check out Erin Catto's presentation about re-inventing soft springs in this PDF: https://box2d.org/files/ErinCatto_SoftConstraints_GDC2011.pdf https://box2d.org/files/ErinCatto_SoftConstraints_GDC2011.pd... Furthermore, impulse/velocity-level LCP based constraint solving can be combined with finite element method (FEM) or mass-spring based deformable contact solving if higher-accuracy contact and friction modeling is needed.
- saboot 4y agoI've been implementing a 2D physics sim myself, I'd take be interested to hear more about different approaches. For example one that can handle the creation of more objects and handles friction accurately.
- Stevvo 4y agoSome years ago I did a project with LiquidFun; https://google.github.io/liquidfun/ https://google.github.io/liquidfun/ It was an interactive art thing for kids; had a TV with a maze of transparent PVC pipes mounted on the front with valves (rotary encoders inside). The kids would open and close the valves, and watch the flow of water be redirected on the TV behind.
- cyber_kinetist 4y agoWell, it’s a pretty huge topic. I recommend taking a look at the SIGGRAPH course notes on contact and friction simulation: https://siggraphcontact.github.io/ https://siggraphcontact.github.io/ Also, look at some recent papers on SIGGRAPH and SCA, such as: - https://matthias-research.github.io/pages/publications/PBDBodies.pdf https://matthias-research.github.io/pages/publications/PBDBo... - https://mmacklin.com/primaldual.pdf https://mmacklin.com/primaldual.pdf - https://arxiv.org/pdf/2201.10022.pdf https://arxiv.org/pdf/2201.10022.pdf Note that these are all cutting-edge stuff, and most physics simulations in production still use more traditional methods (which you can learn from Box2D’s source code and related GDC slides). The links: - https://github.com/erincatto/box2d https://github.com/erincatto/box2d - https://box2d.org/publications/ https://box2d.org/publications/
- saboot 4y agoThank you very much! This is great stuff, I have definitely found it overwhelming.