12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #pragma once
- #include <Mathematics/DistPointOrientedBox.h>
- #include <Mathematics/IntrAlignedBox3Sphere3.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class TIQuery<Real, OrientedBox3<Real>, Sphere3<Real>>
- :
- public TIQuery<Real, AlignedBox3<Real>, Sphere3<Real>>
- {
- public:
-
-
-
- struct Result
- :
- public TIQuery<Real, AlignedBox3<Real>, Sphere3<Real>>::Result
- {
-
- };
- Result operator()(OrientedBox3<Real> const& box, Sphere3<Real> const& sphere)
- {
- DCPQuery<Real, Vector3<Real>, OrientedBox3<Real>> pbQuery;
- auto pbResult = pbQuery(sphere.center, box);
- Result result;
- result.intersect = (pbResult.sqrDistance <= sphere.radius * sphere.radius);
- return result;
- }
- };
- template <typename Real>
- class FIQuery<Real, OrientedBox3<Real>, Sphere3<Real>>
- :
- public FIQuery<Real, AlignedBox3<Real>, Sphere3<Real>>
- {
- public:
-
-
- struct Result
- :
- public FIQuery<Real, AlignedBox3<Real>, Sphere3<Real>>::Result
- {
-
- };
- Result operator()(OrientedBox3<Real> const& box, Vector3<Real> const& boxVelocity,
- Sphere3<Real> const& sphere, Vector3<Real> const& sphereVelocity)
- {
- Result result;
- result.intersectionType = 0;
- result.contactTime = (Real)0;
- result.contactPoint = { (Real)0, (Real)0, (Real)0 };
-
-
-
- Vector3<Real> temp = sphere.center - box.center;
- Vector3<Real> C
- {
- Dot(temp, box.axis[0]),
- Dot(temp, box.axis[1]),
- Dot(temp, box.axis[2])
- };
- temp = sphereVelocity - boxVelocity;
- Vector3<Real> V
- {
- Dot(temp, box.axis[0]),
- Dot(temp, box.axis[1]),
- Dot(temp, box.axis[2])
- };
- this->DoQuery(box.extent, C, sphere.radius, V, result);
-
- if (result.intersectionType != 0)
- {
- auto& P = result.contactPoint;
- P = box.center + P[0] * box.axis[0] + P[1] * box.axis[1] + P[2] * box.axis[2];
- }
- return result;
- }
- };
- }
|