123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #pragma once
- #include <Mathematics/Polyhedron3.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class ExtremalQuery3
- {
- public:
-
- virtual ~ExtremalQuery3() = default;
-
- ExtremalQuery3(ExtremalQuery3 const&) = delete;
- ExtremalQuery3& operator=(ExtremalQuery3 const&) = delete;
-
- inline Polyhedron3<Real> const& GetPolytope() const
- {
- return mPolytope;
- }
- inline std::vector<Vector3<Real>> const& GetFaceNormals() const
- {
- return mFaceNormals;
- }
-
-
- virtual void GetExtremeVertices(Vector3<Real> const& direction,
- int& positiveDirection, int& negativeDirection) = 0;
- protected:
-
- ExtremalQuery3(Polyhedron3<Real> const& polytope)
- :
- mPolytope(polytope)
- {
-
- auto vertexPool = mPolytope.GetVertices();
- auto const& indices = mPolytope.GetIndices();
- int const numTriangles = static_cast<int>(indices.size()) / 3;
- mFaceNormals.resize(numTriangles);
- for (int t = 0; t < numTriangles; ++t)
- {
- Vector3<Real> v0 = vertexPool[indices[3 * t + 0]];
- Vector3<Real> v1 = vertexPool[indices[3 * t + 1]];
- Vector3<Real> v2 = vertexPool[indices[3 * t + 2]];
- Vector3<Real> edge1 = v1 - v0;
- Vector3<Real> edge2 = v2 - v0;
- mFaceNormals[t] = UnitCross(edge1, edge2);
- }
- }
- Polyhedron3<Real> const& mPolytope;
- std::vector<Vector3<Real>> mFaceNormals;
- };
- }
|