1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #pragma once
- #include <Mathematics/IntrLine3Plane3.h>
- #include <Mathematics/Ray.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class TIQuery<Real, Ray3<Real>, Plane3<Real>>
- {
- public:
- struct Result
- {
- bool intersect;
- };
- Result operator()(Ray3<Real> const& ray, Plane3<Real> const& plane)
- {
- Result result;
-
- DCPQuery<Real, Vector3<Real>, Plane3<Real>> vpQuery;
- auto vpResult = vpQuery(ray.origin, plane);
- Real DdN = Dot(ray.direction, plane.normal);
- if (DdN > (Real)0)
- {
-
-
- result.intersect = (vpResult.signedDistance <= (Real)0);
- }
- else if (DdN < (Real)0)
- {
-
-
- result.intersect = (vpResult.signedDistance >= (Real)0);
- }
- else
- {
-
- result.intersect = (vpResult.distance == (Real)0);
- }
- return result;
- }
- };
- template <typename Real>
- class FIQuery<Real, Ray3<Real>, Plane3<Real>>
- :
- public FIQuery<Real, Line3<Real>, Plane3<Real>>
- {
- public:
- struct Result
- :
- public FIQuery<Real, Line3<Real>, Plane3<Real>>::Result
- {
-
- };
- Result operator()(Ray3<Real> const& ray, Plane3<Real> const& plane)
- {
- Result result;
- DoQuery(ray.origin, ray.direction, plane, result);
- if (result.intersect)
- {
- result.point = ray.origin + result.parameter * ray.direction;
- }
- return result;
- }
- protected:
- void DoQuery(Vector3<Real> const& rayOrigin,
- Vector3<Real> const& rayDirection, Plane3<Real> const& plane,
- Result& result)
- {
- FIQuery<Real, Line3<Real>, Plane3<Real>>::DoQuery(rayOrigin,
- rayDirection, plane, result);
- if (result.intersect)
- {
-
-
- if (result.parameter < (Real)0)
- {
- result.intersect = false;
- result.numIntersections = 0;
- }
- }
- }
- };
- }
|