The intersection routines in this module test for intersections with points, edges, and surfaces, but not volumes. If no intersection is reported, the volume of the polyhedron might still contain the entire unit box. To perform a complete test, you must check if the polyhedron contains the origin (the center of the unit cube).
Complete Test Algorithm (Pseudo-code):
switch(trivial_vertex_tests(verts))
{
case 1: return true /* trivial accept: all vertices are inside or on the cube */
case 0: return false /* trivial reject: all vertices are outside a single plane */
case -1:
/* Ambiguous case: perform detailed checks */
for each edge
if(segment_intersects_cube(edge))
return true
for each face
if(fast_polygon_intersects_cube(..., true, true))
return true
/* Final check: does the polyhedron volume contain the cube center? */
return polyhedra_contains_point(polyhedra, origin)
}
switch(trivial_vertex_tests(verts))
{
case 1: return true /* trivial accept */
case 0: return false /* trivial reject */
case -1: for each edge
if(segment_intersects_cube(edge))
return true
for each face
if(fast_polygon_intersects_cube(..., true, true))
return true
return polyhedra_contains_point(polyhedra, origin)
}