// 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 // The query considers the cylinder and box to be solids. namespace WwiseGTE { template class TIQuery, Cylinder3> { public: struct Result { bool intersect; }; Result operator()(OrientedBox3 const& box, Cylinder3 const& cylinder) { // Transform the box and cylinder so that the box is axis-aligned. AlignedBox3 aabb(-box.extent, box.extent); Vector3 diff = cylinder.axis.origin - box.center; Cylinder3 transformedCylinder; transformedCylinder.radius = cylinder.radius; transformedCylinder.height = cylinder.height; for (int i = 0; i < 3; ++i) { transformedCylinder.axis.origin[i] = Dot(box.axis[i], diff); transformedCylinder.axis.direction[i] = Dot(box.axis[i], cylinder.axis.direction); } TIQuery, Cylinder3> aabbCylinderQuery; auto aabbCylinderResult = aabbCylinderQuery(aabb, transformedCylinder); Result result; result.intersect = aabbCylinderResult.intersect; return result; } }; }