1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- // 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 <Mathematics/DistLine3OrientedBox3.h>
- #include <Mathematics/DistPointOrientedBox.h>
- #include <Mathematics/Ray.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class DCPQuery<Real, Ray3<Real>, OrientedBox3<Real>>
- {
- public:
- struct Result
- {
- Real distance, sqrDistance;
- Real rayParameter;
- Vector3<Real> closestPoint[2];
- };
- Result operator()(Ray3<Real> const& ray, OrientedBox3<Real> const& box)
- {
- Result result;
- Line3<Real> line(ray.origin, ray.direction);
- DCPQuery<Real, Line3<Real>, OrientedBox3<Real>> lbQuery;
- auto lbResult = lbQuery(line, box);
- if (lbResult.lineParameter >= (Real)0)
- {
- result.sqrDistance = lbResult.sqrDistance;
- result.distance = lbResult.distance;
- result.rayParameter = lbResult.lineParameter;
- result.closestPoint[0] = lbResult.closestPoint[0];
- result.closestPoint[1] = lbResult.closestPoint[1];
- }
- else
- {
- DCPQuery<Real, Vector3<Real>, OrientedBox3<Real>> pbQuery;
- auto pbResult = pbQuery(ray.origin, box);
- result.sqrDistance = pbResult.sqrDistance;
- result.distance = pbResult.distance;
- result.rayParameter = (Real)0;
- result.closestPoint[0] = ray.origin;
- result.closestPoint[1] = pbResult.boxClosest;
- }
- return result;
- }
- };
- }
|