Game Development Reference
In-Depth Information
updated based on the changes that were made. If there are more velocity iterations
available, then the algorithm repeats.
Updating Velocities
The largest change from the penetration version of this algorithm lies in the equations
for updating velocities. As before we search through to find only those contacts with
an object that has just been altered.
If the first object in the contact has changed, the update of the velocity looks like
this:
cp = rotationChange[0].vectorProduct(
c[i].relativeContactPosition[0]
);
cp += velocityChange[0];
c[i].contactVelocity += c[i].contactToWorld.transformTranspose(cp);
c[i].calculateDesiredDeltaVelocity(duration);
The corresponding code for the second object looks like this:
cp = rotationChange[0].vectorProduct(
c[i].relativeContactPosition[1]
);
cp += velocityChange[0];
c[i].contactVelocity -= c[i].contactToWorld.transformTranspose(cp);
c[i].calculateDesiredDeltaVelocity(duration);
The calculateDesiredDeltaVelocity function is implemented as
Excerpt from src/contacts.cpp
// Calculate the acceleration-induced velocity accumulated this frame.
real velocityFromAcc =
body[0]->getLastFrameAcceleration() * duration * contactNormal;
if (body[1])
{
velocityFromAcc -=
body[1]->getLastFrameAcceleration() * duration * contactNormal;
}
Search Nedrilad ::




Custom Search