Skip to Main Content
3D Game Engine Design, 2nd Edition
book

3D Game Engine Design, 2nd Edition

by David Eberly
November 2006
Intermediate to advanced content levelIntermediate to advanced
1040 pages
26h 31m
English
CRC Press
Content preview from 3D Game Engine Design, 2nd Edition
414 Chapter 8 Collision Detection
bool TestIntersection (ConvexPolygon C0, Vector V0,
ConvexPolygon C1, Vector V1, double tmax, double& tfirst,
double& tlast)
{
// Process as if C0 is stationary, C1 is moving.
V=V1-V0;
tfirst = 0;
tlast = INFINITY;
// Test edges of C0 for separation.
for (i0 = C0.GetN() - 1, i1 = 0; i1 < C0.GetN(); i0 = i1++)
{
D = C0.GetNormal(i0);
ComputeInterval(C0,D,min0,max0);
ComputeInterval(C1,D,min1,max1);
speed = Dot(D,V);
if (NoIntersect(tmax,speed,min0,max0,min1,max1,
tfirst,tlast))
{
return false;
}
}
// Test edges of C1 for separation.
for (i0 = C1.N - 1, i1 = 0; i1 < C1.N; i0 = i1++)
{
D = C1.GetNormal(i0);
ComputeInterval(C0,D,min0,max0);
ComputeInterval(C1,D,min1,max1);
speed = Dot(D,V);
if (NoIntersect(tmax,speed,min0,max0,min1,max1, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

3D Game Engine Architecture

3D Game Engine Architecture

David Eberly
Blender 3D By Example - Second Edition

Blender 3D By Example - Second Edition

Oscar Baechler, Xury Greer
Computer Graphics

Computer Graphics

Alexey Boreskov, Evgeniy Shikin

Publisher Resources

ISBN: 9781482267303