// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2020 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #pragma once #include namespace WwiseGTE { template class ExtremalQuery3PRJ : public ExtremalQuery3 { public: // Construction. ExtremalQuery3PRJ(Polyhedron3 const& polytope) : ExtremalQuery3(polytope) { mCentroid = this->mPolytope.ComputeVertexAverage(); } // Disallow copying and assignment. ExtremalQuery3PRJ(ExtremalQuery3PRJ const&) = delete; ExtremalQuery3PRJ& operator=(ExtremalQuery3PRJ const&) = delete; // Compute the extreme vertices in the specified direction and return // the indices of the vertices in the polyhedron vertex array. virtual void GetExtremeVertices(Vector3 const& direction, int& positiveDirection, int& negativeDirection) override { Real minValue = std::numeric_limits::max(), maxValue = -minValue; negativeDirection = -1; positiveDirection = -1; auto vertexPool = this->mPolytope.GetVertexPool(); for (auto i : this->mPolytope.GetUniqueIndices()) { Vector3 diff = vertexPool.get()->at(i) - mCentroid; Real dot = Dot(direction, diff); if (dot < minValue) { negativeDirection = i; minValue = dot; } if (dot > maxValue) { positiveDirection = i; maxValue = dot; } } } private: Vector3 mCentroid; }; }