Game Development Reference
12.5 Order of Cloth Update Stages
Ordering what parts of the simulation happen when is critically important for
minimizing simulation artifacts. When coding, good engineering practices say
that we should not have direct coupling between the character animation system
and the cloth simulator. The skinning data represent a significant amount of data
to hold on to for any length of time. We will want to use it immediately after we
have calculated it. Since the skinning data are updated by the character animation
system and we have efficiency in mind, the natural thinking is to apply the pinning
constraint as the very first thing we do in our update. This is the wrong order.
Looking at Figure 12.2 shows why. This figure shows a particle anchored between
two collision spheres. The spheres translate a large distance in the first frame.
This is not a configuration we would see in practice, but it serves our instructional
purposes here. During the render phase (right after the frame boundaries), we
are able to see the cloth particle on the wrong side of a collision body. A better
ordering is to apply the pinning constraint after integration and before collision
Figure 12.3. Cloth update: correct ordering.