In this project, we implemented a real-time cloth balloon and rigid body simulator from scratch. Our simulation is based on the Extended Position-Based Dynamics (XPBD) algorithm and runs inside the Unity game engine.
XPBD#
XPBD is a fast and stable method that can be employed for many physically-based simulations, such as for fluids, cloth, soft bodies or rigid bodies. In a nutshell, it is a particle-based method where we repeatedly take unconstrained time steps (e.g. with explicit Euler) and then iterate over all our constraints and locally correct them. For a more detailed discussion of XPBD, I recommend the original paper.
Cloth Balloons#
We implemented the following constraints for our cloth balloon simulation:
- Stretching
- Overpressure
- Bending
- Collisions (+ Spatial Hash Grid for good performance)
The stiffness of all constraints (how strictly it is enforced) can be tweaked individually, allowing vastly different material behaviours.

Further, we allow user interaction by dynamically adding stiff stretching constraints between the users mouse position and the grabbed object. We also incorporate tearing of edges based on their stretching force.

Rigid Bodies#
The XPBD algorithm can also be generalized to rigid bodies. In a nutshell, only a single particle at the center of mass is simulated (as opposed to one particle per mesh vertex for soft bodies), but we need to additionally keep track of this particle’s orientation and angular velocity. The position of all mesh vertices stays constant relative to the center of mass and is solely used for collision handling.

Our code is published on GitHub.