123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #pragma once
- #include <Mathematics/IntrSegment3AlignedBox3.h>
- #include <Mathematics/OrientedBox.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class TIQuery<Real, Segment3<Real>, OrientedBox3<Real>>
- :
- public TIQuery<Real, Segment3<Real>, AlignedBox3<Real>>
- {
- public:
- struct Result
- :
- public TIQuery<Real, Segment3<Real>, AlignedBox3<Real>>::Result
- {
-
- };
- Result operator()(Segment3<Real> const& segment, OrientedBox3<Real> const& box)
- {
-
- Vector3<Real> tmpOrigin, tmpDirection;
- Real segExtent;
- segment.GetCenteredForm(tmpOrigin, tmpDirection, segExtent);
- Vector3<Real> diff = tmpOrigin - box.center;
- Vector3<Real> segOrigin
- {
- Dot(diff, box.axis[0]),
- Dot(diff, box.axis[1]),
- Dot(diff, box.axis[2])
- };
- Vector3<Real> segDirection
- {
- Dot(tmpDirection, box.axis[0]),
- Dot(tmpDirection, box.axis[1]),
- Dot(tmpDirection, box.axis[2])
- };
- Result result;
- this->DoQuery(segOrigin, segDirection, segExtent, box.extent, result);
- return result;
- }
- };
- template <typename Real>
- class FIQuery<Real, Segment3<Real>, OrientedBox3<Real>>
- :
- public FIQuery<Real, Segment3<Real>, AlignedBox3<Real>>
- {
- public:
- struct Result
- :
- public FIQuery<Real, Segment3<Real>, AlignedBox3<Real>>::Result
- {
-
- };
- Result operator()(Segment3<Real> const& segment, OrientedBox3<Real> const& box)
- {
-
- Vector3<Real> tmpOrigin, tmpDirection;
- Real segExtent;
- segment.GetCenteredForm(tmpOrigin, tmpDirection, segExtent);
- Vector3<Real> diff = tmpOrigin - box.center;
- Vector3<Real> segOrigin
- {
- Dot(diff, box.axis[0]),
- Dot(diff, box.axis[1]),
- Dot(diff, box.axis[2])
- };
- Vector3<Real> segDirection
- {
- Dot(tmpDirection, box.axis[0]),
- Dot(tmpDirection, box.axis[1]),
- Dot(tmpDirection, box.axis[2])
- };
- Result result;
- this->DoQuery(segOrigin, segDirection, segExtent, box.extent, result);
- for (int i = 0; i < result.numPoints; ++i)
- {
- // Compute the intersection point in the oriented-box
- // coordinate system.
- Vector3<Real> y = segOrigin + result.lineParameter[i] * segDirection;
-
-
- result.point[i] = box.center;
- for (int j = 0; j < 3; ++j)
- {
- result.point[i] += y[j] * box.axis[j];
- }
- }
- return result;
- }
- };
- }
|