soft-body-cube / README.md
The idea Squishy cubes you can grab.
A real time soft body simulator in Python, PyOpenGL and Pygame. Deformable cube meshes, interactive mouse grabbing and a 3D camera.
Entirely based on the XPBD paper. Making the video took longer than the code, because I had to learn manim to animate the maths.
Position based dynamics Predict, then correct.
Instead of integrating forces directly, each particle’s next position is predicted and then corrected until the constraints hold. That keeps it stable even with large time steps.
Constraints
- Distance
- Every pair of connected particles keeps its rest length, like an elastic link.
- Volume
- Each cube is split into tetrahedra and each one keeps its rest volume, so the cube squashes instead of collapsing or inflating.

