From 90c50016739267765c5c43d8f8baa5918f7ee44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 12 Dec 2016 18:26:24 +0100 Subject: [PATCH] Math: remove dead frustum/box intersection code. The additional corner checks are not implemented now, thus the code is more complex than it needs to be. --- src/Magnum/Math/Geometry/Intersection.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Magnum/Math/Geometry/Intersection.h b/src/Magnum/Math/Geometry/Intersection.h index 06d557c4e..8d846d3e9 100644 --- a/src/Magnum/Math/Geometry/Intersection.h +++ b/src/Magnum/Math/Geometry/Intersection.h @@ -166,29 +166,23 @@ template bool Intersection::pointFrustum(const Vector3& point, const } template bool Intersection::boxFrustum(const Range3D& box, const Frustum& frustum) { - /* Create the 8 vertices of the box from the 2 given vertices min and max - Check for each corner of an octant whether it is inside the frustum. If - only some of the corners are inside, the octant requires further checks. */ - Int planes = 0; - for(const Vector4& plane: frustum.planes()) { - Int corners = 0; + bool cornerHit = 0; for(UnsignedByte c = 0; c != 8; ++c) { const Vector3 corner = Math::lerp(box.min(), box.max(), Math::BoolVector<3>{c}); - if(Distance::pointPlaneScaled(corner, plane) >= T(0)) - ++corners; + if(Distance::pointPlaneScaled(corner, plane) >= T(0)) { + cornerHit = true; + break; + } } /* All corners are outside this plane */ - if(corners == 0) return false; - - if(corners == 8) ++planes; + if(!cornerHit) return false; } /** @todo potentially check corners here to avoid false positives */ - /* if(planes == 6) return true; */ return true; }