// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2020 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #pragma once #include #include #include namespace WwiseGTE { template class TIQuery, Capsule3> { public: struct Result { bool intersect; }; Result operator()(Plane3 const& plane, Capsule3 const& capsule) { Result result; DCPQuery, Plane3> vpQuery; Real sdistance0 = vpQuery(capsule.segment.p[0], plane).signedDistance; Real sdistance1 = vpQuery(capsule.segment.p[1], plane).signedDistance; if (sdistance0 * sdistance1 <= (Real)0) { // A capsule segment endpoint is on the plane or the two // endpoints are on opposite sides of the plane. result.intersect = true; return result; } // The endpoints on same side of plane, but the endpoint spheres // might intersect the plane. result.intersect = std::fabs(sdistance0) <= capsule.radius || std::fabs(sdistance1) <= capsule.radius; return result; } }; }