Graphics Reference
In-Depth Information
// Keep b as the starting point of the next edge
a=b;
aSide = bSide;
}
// Create (and return) two new polygons from the two vertex lists
*frontPoly = new Polygon(numFront, frontVerts);
*backPoly = new Polygon(numBack, backVerts);
}
Note that calls to assert() have been added to verify that the computed intersec-
tion points really do lie on the thick plane. The call serves as a sanity check that the
plane thickness has been well chosen with respect to the range of coordinate values
present in the input data.
Figure 8.14 illustrates the result of splitting two polygons against a plane. The
original polygons are given in outlines and the resulting pieces are shown in gray,
slightly inset.
Although polygons are split during the construction of the tree, this does not
necessarily mean that the polygon fragments ending up in the leaves must be the
polygons output in the final tree.
For collision detection, it is better to store a reference to the original polygon
with each fragment generated during splitting. In the leaves, the reference is output,
rather than the fragment itself. Storing a reference to the original polygon avoids
many robustness issues caused by clipping to planes, such as the introduction of
e
e
P
P
n
n
HG
H
G
A
F
A
F
B
B
E
E
D
D
C
C
Figure 8.14 Two different polygons clipped to a thickened plane using the modified robust
clipping algorithm. Resulting polygon pieces are shown in dark gray (slightly inset).
 
Search WWH ::




Custom Search