Introduction to constraints

Obi models all physical simulations as a set of particles and constraints. Particles are freely-moving lumps of matter (like tiny atoms), and constraints are rules that control their behavior. Each constraint takes a set of particles and information about the "outside" world as input (colliders, rigidbodies, wind, athmospheric pressure, etc), and modifies the particles' positions so that they satisfy a certain condition.


Rope:
Modeled as a row of particles, linked together by constraints that force them to stay within a certain distance of each other (distance constraints).

Cloth:
A piece of cloth can be modeled as a bidimensional grid of particles, linked together by distance and bend constraints.

Fluid:
Modeled as a bunch of particles, and density constraints that make particles repel or attract each other.

Each and every frame, Obi advances the particles according to their velocities and then modifies their positions in an attempt to satisfy the constraints. When there are very few constraints this is easy to do. However when there are many constraints present, enforcing some constraints can violate others, and this makes it difficult to make sure all constraints are properly met. Obi will try to find a global solution in an iterative fashion. With each iteration, we will get a better solution: one that is closer to satisfying all constraints simultaneously. In the following animations, three particles (A, B and C) generate two collision constraints which are then solved:

Two collision constraints solved in sequential mode.

Two collision constraints solved in parallel mode.

All iterations are repeated each frame, so only the final result after the last iteration is presented on screen. Each iteration will get your simulation closer to the ground-truth, but will also slightly erode performance. So the amount of iterations acts as a slider between performance -few iterations- and quality -many iterations-.

Unlike other engines, Obi allows you to set the amount of iterations spent in each type of constraint individually. Each one will affect the simulation in a different way, depending on what the specific type of constraint does, so you can really fine tune your simulation:

Collision constraints

Collision constraints try to keep particles outside of colliders. High iteration counts will yield more robust collision detection when there are multiple colllisions per particle.

Particle collision constraints

Identical to collision constraints, but for when collisions happen between particles.

Distance constraints

Each distance constraint tries to keep two particles at a fixed distance form each other. These are responsible for the elasticity of cloth and ropes. High iteration counts will allow them to reach higher stiffnesses, so your ropes/cloth will be less stretchy.

Pin constraints

A pin constraint will apply forces to a particle and a rigidbody so that they maintain their relative position. They are used to attach rope and cloth to rigidbodies (or any collider, in fact). High iteration counts will reduce the amount of drift at the pin location, making the attachment more robust.

Volume constraints

Each volume constraint takes a group of particles positioned at the vertices of a mesh, and tries to maintain the mesh volume. Used to inflate cloth and create balloons. High iteration counts will allow the ballons to reach higher pressures, and keep their shape more easily.

Aerodynamic constraints

This is the only type of constraint that doesn't have an iteration count. They are always applied only once, that is enough. Used to simulate wind.

Bend constraints

Each bend constraint will work on three particles, trying to get them in a straight line. These are used to make cloth and ropes resistant to bending. As with distance constraints, high iteration counts will allow them to reach higher stiffness.

Tether constraints

These constraints are used to reduce stretching of cloth and ropes, when increasing the amount of distance constraint iterations would be too expensive. Generally 1-4 iterations are enough for tether constraints.

Skin constraints

Skin constraints are used to keep skeletally animated cloth close to its skinned shape. They are mostly used for character clothing. Generally 1-2 iterations are enough for skin constraints.

Density constraints

Each density constraint tries to keep the amount of mass in the neighborhood around a particle constant. This will push out particles getting too close (as that would increase the mass) and pull in particles going away (which results in surface tension effects). Used to simulate fluids. High iteration counts will make the fluid more incompressible, so it will behave less like jelly.