Game Development Reference
In-Depth Information
if(dot < 0)
{
interpenetrating = true;
}
}
}
}
if(interpenetrating)
{
retval = −1;
} else if(haveNodeNode || haveNodeEdge)
{
retval = 1;
} else
retval = 0;
} else
{
retval = 0;
}
return retval;
}
The first thing that CheckForCollision does is perform a quick bounding-circle check
to see if there is a possible collision. If no collision is detected, the function simply exits,
returning 0 . This is the same bounding-circle check performed in the earlier version:
r = body1->fLength/2 + body2->fLength/2;
d = body1->vPosition - body2->vPosition;
s = d.Magnitude() - r;
if(s <= ctol)
{
.
.
.
} else
retval = 0;
}
If the bounding-circle check indicates the possibility of a collision, then CheckForCol
lision proceeds by setting up a couple of polygons, represented by vertex lists, for each
hovercraft:
wd = body1->fWidth;
lg = body1->fLength;
vList1[0].y = wd/2; vList1[0].x = lg/2;
vList1[1].y = -wd/2; vList1[1].x = lg/2;
vList1[2].y = -wd/2; vList1[2].x = -lg/2;
vList1[3].y = wd/2; vList1[3].x = -lg/2;
Search Nedrilad ::




Custom Search