Game Development Reference
In-Depth Information
The sum of all impulses applied to a contacting rope vertex must be zero
(otherwise it'll gain infinite velocity, since the impulses have dimensions
relative to the main set of bodies, which is infinitely heavier than the rope).
Thus, P i must be equal in length to P i , and their vector sum must be
equal to P i (applied from the contacting body along the normal).
Impulses don't change along straight fragments, so P i =
P i +1 .
There should be no relative movement between the rope vertices along the
rope direction, also, no relative movement between the contacting vertices
and the corresponding point on the body. These last two conditions are
only active while the rope remains strained (note that this state can alternate
during the solving process). This gives us
d i = v i +1 ·
v i
d i
d i )= v i
v i
( d i− 1
( d i− 1
d i )
v i
v i
d i = v i ·
d i− 1
( d i− 1
d i )
Since we know v 0 ·
d 0 , we can use Equation (8.1) to compute v 1 ·
d 0 ,then
use v 1 and Equation (8.2) to compute v 1 ·
d 1 , and so on, until we reach the
last segment, for which we can now write the dynamic contact inequality:
N− 1
v i
v N
d N
v 0 ·
d 0 +
( d i− 1
d i ) < 0 .
i =1
The zero on the right-hand side can of course be replaced by a desired
“penalty” velocity that will pull the rope ends together if the total length
after simulation exceeds the target one.
Now we need to compute how applying an impulse will affect this inequality.
To do that, we apply a test impulse with magnitude one to the two end bodies and
along all contact normals (in the latter case multiplied by ( d i d i− 1 ) since it's
being applied from both sides) and measure the changes in velocities, summing
them in accordance with Equation (8.3). Let's denote this change d v . Resolving
this contact is now simple: whenever the inequality in Equation (8.3) becomes
violated by v , we apply an impulse v/ d v to the rope (which means applying it to
all affected bodies). It's also quite straightforward to use it in a direct-ish solver,
since those usually just need to know the dot product between the contact impulse
and the resulting velocity changes.
The following pseudocode shows the two core steps of the procedure—
applying an impulse at all contact points and measuring velocity response.
Search Nedrilad ::

Custom Search