// 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 test-intersection queries use the method of separating axes. // https://www.geometrictools.com/Documentation/MethodOfSeparatingAxes.pdf // The find-intersection queries use parametric clipping against the six // faces of the box. The find-intersection queries use Liang-Barsky // clipping. The queries consider the box to be a solid. The algorithms // are described in // https://www.geometrictools.com/Documentation/IntersectionLineBox.pdf namespace WwiseGTE { template class TIQuery, OrientedBox3> : public TIQuery, AlignedBox3> { public: struct Result : public TIQuery, AlignedBox3>::Result { // No additional information to compute. }; Result operator()(Ray3 const& ray, OrientedBox3 const& box) { // Transform the ray to the oriented-box coordinate system. Vector3 diff = ray.origin - box.center; Vector3 rayOrigin { Dot(diff, box.axis[0]), Dot(diff, box.axis[1]), Dot(diff, box.axis[2]) }; Vector3 rayDirection = Vector3 { Dot(ray.direction, box.axis[0]), Dot(ray.direction, box.axis[1]), Dot(ray.direction, box.axis[2]) }; Result result; this->DoQuery(rayOrigin, rayDirection, box.extent, result); return result; } }; template class FIQuery, OrientedBox3> : public FIQuery, AlignedBox3> { public: struct Result : public FIQuery, AlignedBox3>::Result { // No additional information to compute. }; Result operator()(Ray3 const& ray, OrientedBox3 const& box) { // Transform the ray to the oriented-box coordinate system. Vector3 diff = ray.origin - box.center; Vector3 rayOrigin { Dot(diff, box.axis[0]), Dot(diff, box.axis[1]), Dot(diff, box.axis[2]) }; Vector3 rayDirection = Vector3 { Dot(ray.direction, box.axis[0]), Dot(ray.direction, box.axis[1]), Dot(ray.direction, box.axis[2]) }; Result result; this->DoQuery(rayOrigin, rayDirection, box.extent, result); for (int i = 0; i < result.numPoints; ++i) { result.point[i] = ray.origin + result.lineParameter[i] * ray.direction; } return result; } }; }