123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #pragma once
- #include <Mathematics/Segment.h>
- #include <Mathematics/IntrLine3Cone3.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class FIQuery<Real, Segment3<Real>, Cone3<Real>>
- :
- public FIQuery<Real, Line3<Real>, Cone3<Real>>
- {
- public:
- struct Result
- :
- public FIQuery<Real, Line3<Real>, Cone3<Real>>::Result
- {
-
- };
- Result operator()(Segment3<Real> const& segment, Cone3<Real> const& cone)
- {
-
- Result result;
- Vector3<Real> segOrigin = segment.p[0];
- Vector3<Real> segDirection = segment.p[1] - segment.p[0];
- this->DoQuery(segOrigin, segDirection, cone, result);
-
-
-
-
- if (result.type != Result::isEmpty)
- {
- using QFN1 = typename FIQuery<Real, Line3<Real>, Cone3<Real>>::QFN1;
- QFN1 zero(0, 0, result.t[0].d), one(1, 0, result.t[0].d);
- if (result.type == Result::isPoint)
- {
- if (result.t[0] < zero || result.t[0] > one)
- {
-
- this->SetEmpty(result);
- }
-
- }
- else if (result.type == Result::isSegment)
- {
- if (result.t[1] < zero || result.t[0] > one)
- {
-
- this->SetEmpty(result);
- }
- else
- {
- auto t0 = std::max(zero, result.t[0]);
- auto t1 = std::min(one, result.t[1]);
- if (t0 < t1)
- {
-
- this->SetSegment(t0, t1, result);
- }
- else
- {
-
- this->SetPoint(t0, result);
- }
- }
- }
- else if (result.type == Result::isRayPositive)
- {
- if (one < result.t[0])
- {
-
- this->SetEmpty(result);
- }
- else if (one > result.t[0])
- {
-
- this->SetSegment(std::max(zero, result.t[0]), one, result);
- }
- else
- {
-
- this->SetPoint(one, result);
- }
- }
- else
- {
- if (zero > result.t[1])
- {
-
- this->SetEmpty(result);
- }
- else if (zero < result.t[1])
- {
-
- this->SetSegment(zero, std::min(one, result.t[1]), result);
- }
- else
- {
-
- this->SetPoint(zero, result);
- }
- }
- }
- result.ComputePoints(segment.p[0], segDirection);
- result.intersect = (result.type != Result::isEmpty);
- return result;
- }
- };
- }
|