Game Development Reference
In-Depth Information
Figure 8.2. Collision-based dynamic subdivision.
ners in appropriate places when needed. An approach that seems to have worked
reasonably well is to keep a set of (initially) fixed-length segments that can form
temporary inner vertices based on the current frame's collisions.
Segment ends test collisions as independent particles (and their main concern
is to stay outside any potentially colliding geometry, which is not a terribly hard
thing to do for a point). Segment bodies are first traced as rays, and if such
a ray goes through something, it gets unprojected to the state where it touches
the geometry at a single point (the direction can be chosen using some heuristic
magic, based on the contact normal, neighboring-segments directions, and the last
frame's state). A new temporary vertex is created at this point, and the procedure
is repeated for the two new edges that connect it to the original segment's ends
(see Figure 8.2 ) . The process can stop when either the amount of subvertices
reaches a limit or a subsegment length becomes short enough.
The next step is finding out whether the rope is actually strained, and this is
obviously not as straightforward as in the case of a straight rope (apologies for
the pun). First thing to think about here is friction. In a frictionless case, the
rope won't be able to apply any force on the objects it collides with while it's
“tilted” relative to the surface normal since any pull force will be fully transferred
to the rope's lateral sliding motion (we are making an assumption that the rope is
infinitesimally light compared to the rigid bodies it interacts with—an assumption
that, perhaps, hasn't been postulated sufficiently clearly so far).
Such perfect alignment will obviously not happen during a discrete simula-
tion, so a tilt tolerance will be required. In practice, it makes sense to have
two separate and independent frictions, in lateral and pull directions. The for-
mer would simply define a maximum tilt angle that keeps the rope in a strained
state. If all noncontacting fragments of the rope are sufficiently close to a straight
line and all contacts are within the friction-allowed tilt range, the entire rope can
be considered strained, and we can proceed. Unfortunately, as with a depressingly