Game Development Reference
In-Depth Information
proj = (p * u) * u;
d = p^u;
dist = d.Magnitude();
vCollisionPoint = vList1[i];
body1->vCollisionPoint = vCollisionPoint −
body1->vPosition;
body2->vCollisionPoint = vCollisionPoint −
body2->vPosition;
vCollisionNormal = ((u^p)^u);
vCollisionNormal.Normalize();
v1 = body1->vVelocityBody +
(body1->vAngularVelocity ^
body1->vCollisionPoint);
v2 = body2->vVelocityBody +
(body2->vAngularVelocity ^
body2->vCollisionPoint);
v1 = VRotate2D(body1->fOrientation, v1);
v2 = VRotate2D(body2->fOrientation, v2);
vRelativeVelocity = (v1 - v2);
Vrn = vRelativeVelocity * vCollisionNormal;
if( (proj.Magnitude() > 0.0f) &&
(proj.Magnitude() <= edge.Magnitude()) &&
(dist <= ctol) &&
(Vrn < 0.0) )
haveNodeEdge = true;
}
}
}
// Check for penetration
if(!haveNodeNode && !haveNodeEdge)
{
for(i=0; i<4 && !interpenetrating; i++)
{
for(j=0; j<4 && !interpenetrating; j++)
{
if(j==3)
edge = vList2[0] - vList2[j];
else
edge = vList2[j+1] - vList2[j];
p = vList1[i] - vList2[j];
dot = p * edge;
Search Nedrilad ::




Custom Search