123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #pragma once
- #include <Mathematics/Ray.h>
- #include <Mathematics/IntrLine3Cone3.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class FIQuery<Real, Ray3<Real>, Cone3<Real>>
- :
- public FIQuery<Real, Line3<Real>, Cone3<Real>>
- {
- public:
- struct Result
- :
- public FIQuery<Real, Line3<Real>, Cone3<Real>>::Result
- {
-
- };
- Result operator()(Ray3<Real> const& ray, Cone3<Real> const& cone)
- {
-
- Result result;
- this->DoQuery(ray.origin, ray.direction, 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);
- if (result.type == Result::isPoint)
- {
- if (result.t[0] < zero)
- {
-
- this->SetEmpty(result);
- }
-
- }
- else if (result.type == Result::isSegment)
- {
- if (result.t[1] > zero)
- {
-
- this->SetSegment(std::max(result.t[0], zero), result.t[1], result);
- }
- else if (result.t[1] < zero)
- {
-
- this->SetEmpty(result);
- }
- else
- {
-
- this->SetPoint(zero, result);
- }
- }
- else if (result.type == Result::isRayPositive)
- {
-
- this->SetRayPositive(std::max(result.t[0], zero), result);
- }
- else
- {
- if (result.t[1] > zero)
- {
-
- this->SetSegment(zero, result.t[1], result);
- }
- else if (result.t[1] < zero)
- {
-
- this->SetEmpty(result);
- }
- else
- {
-
- this->SetPoint(zero, result);
- }
- }
- }
- result.ComputePoints(ray.origin, ray.direction);
- result.intersect = (result.type != Result::isEmpty);
- return result;
- }
- };
- }
|