Game Development Reference
In-Depth Information
than a linear effect. So, if we want a subtle effect, we need to use quite a small
value for the pinning strength.
It is important to have a flexible pinning function because different sections
of a piece of clothing require different pinning values. The bottom of a shirt can
move large distances, while the areas under an armpit need tighter control. Arms
of a shirt are especially tricky to tune because we want both dramatic simulation
and control. The radius for the collision geometry representing arms is relatively
small. What works well in practice for maximum visual effect is to have a pinning
strength of 0 and a radius of under half of the bone's collision radius. Then apply
a distance-proportional pinning strength after the radius has been exceeded. This
softens the constraint, while providing good control. An easy-to-use interface that
allows the character team to paint pinning values on a cloth mesh is a very useful
thing.
12.3.2 Collisions
Spheres and capsules are easy-to-use collision geometries and are a fair represen-
tation of character limbs. To respond to collisions, we simply push the position of
any interpenetrating particle via the shortest path to the surface. This path points
along the vector formed from the position of the particle and the center of the
collision object.
For a high-resolution cloth mesh, the torso of a character's body is too com-
plicated to model with spheres and capsules. Unless we are using a very large
number of capsules and spheres, the way the cloth rests on the character will be-
tray the underlying geometric approximations we used. A triangle mesh can yield
good performance by utilizing a caching optimization. Each particle should keep
track of which triangle it collided with in the last frame. Check to see whether a
particle is within the edge boundaries of its cached triangle (the triangle's extruded
wedge). If so, collide with that triangle. If not, use an edge-walking algorithm
to find the new triangle whose extruded wedge contains the particle. Typically,
the particle will be in the bounds of its cached triangle or have moved to a di-
rectly neighboring triangle. Performance is actually quite good. For best results,
the mesh should be closed and convex. Responding to the collision is simply a
matter of pushing the particle's position out to the surface of the triangle along its
normal.
12.4
Performance
By far, the most expensive part of the simulation is the collision detection. Since
the constraints directly and immediately update the positions of the particles, we