bool PlaneCullTest(const Plane3& plane, const AABB3& box){ Vector3 testVertex; // find the vertex with the greatest distance value if(plane.n.x >= 0.f){ if(plane.n.y >= 0.f){ if(plane.n.z >= 0.f){ testVertex = box.max; }else{ testVertex = MakeVector3(box.max.x, box.max.y, box.min.z); } }else{ if(plane.n.z >= 0.f){ testVertex = MakeVector3(box.max.x, box.min.y, box.max.z); }else{ testVertex = MakeVector3(box.max.x, box.min.y, box.min.z); } } }else{ if(plane.n.y >= 0.f){ if(plane.n.z >= 0.f){ testVertex = MakeVector3(box.min.x, box.max.y, box.max.z); }else{ testVertex = MakeVector3(box.min.x, box.max.y, box.min.z); } }else{ if(plane.n.z >= 0.f){ testVertex = MakeVector3(box.min.x, box.min.y, box.max.z); }else{ testVertex = box.min; } } } return plane.GetDistanceTo(testVertex) >= 0.f; }
static Segment ZRange(Vector3 base, Vector3 dir, Plane3 plane1, Plane3 plane2){ return Segment(plane1.GetDistanceTo(base)/Vector3::Dot(dir,plane1.n), plane2.GetDistanceTo(base)/Vector3::Dot(dir,plane2.n)); }