123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #pragma once
- #include <Mathematics/IntrLine3Plane3.h>
- #include <Mathematics/Segment.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class TIQuery<Real, Segment3<Real>, Plane3<Real>>
- {
- public:
- struct Result
- {
- bool intersect;
- };
- Result operator()(Segment3<Real> const& segment, Plane3<Real> const& plane)
- {
- Result result;
-
-
- DCPQuery<Real, Vector3<Real>, Plane3<Real>> vpQuery;
- Real sdistance0 = vpQuery(segment.p[0], plane).signedDistance;
- if (sdistance0 == (Real)0)
- {
-
- result.intersect = true;
- return result;
- }
- Real sdistance1 = vpQuery(segment.p[1], plane).signedDistance;
- if (sdistance1 == (Real)0)
- {
-
- result.intersect = true;
- return result;
- }
-
- result.intersect = (sdistance0 * sdistance1 < (Real)0);
- return result;
- }
- };
- template <typename Real>
- class FIQuery<Real, Segment3<Real>, Plane3<Real>>
- :
- public FIQuery<Real, Line3<Real>, Plane3<Real>>
- {
- public:
- struct Result
- :
- public FIQuery<Real, Line3<Real>, Plane3<Real>>::Result
- {
-
- };
- Result operator()(Segment3<Real> const& segment, Plane3<Real> const& plane)
- {
- Vector3<Real> segOrigin, segDirection;
- Real segExtent;
- segment.GetCenteredForm(segOrigin, segDirection, segExtent);
- Result result;
- DoQuery(segOrigin, segDirection, segExtent, plane, result);
- if (result.intersect)
- {
- result.point = segOrigin + result.parameter * segDirection;
- }
- return result;
- }
- protected:
- void DoQuery(Vector3<Real> const& segOrigin,
- Vector3<Real> const& segDirection, Real segExtent,
- Plane3<Real> const& plane, Result& result)
- {
- FIQuery<Real, Line3<Real>, Plane3<Real>>::DoQuery(segOrigin,
- segDirection, plane, result);
- if (result.intersect)
- {
-
-
- if (std::fabs(result.parameter) > segExtent)
- {
- result.intersect = false;
- result.numIntersections = 0;
- }
- }
- }
- };
- }
|