42 using VertexArray = std::vector<fge::Vector2f>;
53 [[nodiscard]]
bool checkIfRightHanded();
55 void convexDecomposition();
57 void setVertices(VertexArray
const& vertices);
58 void setVertices(VertexArray&& vertices);
59 [[nodiscard]]
inline fge::Vector2f& vertex(std::size_t index) {
return this->g_vertices[index]; }
60 [[nodiscard]]
inline fge::Vector2f
const& vertex(std::size_t index)
const {
return this->g_vertices[index]; }
61 [[nodiscard]]
inline VertexArray
const& vertices()
const {
return this->g_vertices; }
63 [[nodiscard]]
inline VertexArray
const& subPolygon(std::size_t subPolyIndex)
const
65 return this->g_subPolygons[subPolyIndex];
67 [[nodiscard]]
inline std::size_t subPolygonCount()
const {
return this->g_subPolygons.size(); }
69 [[nodiscard]]
inline std::size_t totalVertexCount()
const {
return this->g_totalVertexCount; }
74 VertexArray g_vertices;
75 std::vector<VertexArray> g_subPolygons;
76 std::size_t g_totalVertexCount = 0;
78 using VertexIndexMap = std::map<std::size_t, fge::Vector2f>;
79 using Indices = std::vector<std::size_t>;
81 [[nodiscard]]
static bool checkIfRightHanded(VertexArray
const& vertices);
83 [[nodiscard]]
static std::pair<ConcavePolygon::VertexArray, ConcavePolygon::VertexArray>
84 slicePolygon(std::size_t
const& startVertexIndex,
85 std::size_t
const& stopVertexIndex,
86 VertexArray
const& inputVertices);
88 [[nodiscard]]
static Indices findVerticesInCone(
fge::Line const& line1,
90 fge::Vector2f
const& origin,
91 VertexArray
const& inputVertices);
93 [[nodiscard]]
static bool checkVisibility(fge::Vector2f
const& originalPosition,
94 fge::Vector2f
const& vert,
95 VertexArray
const& polygonVertices);
97 [[nodiscard]]
static std::optional<std::size_t>
98 getBestVertexToConnect(Indices
const& indices, VertexArray
const& polygonVertices, fge::Vector2f
const& origin);
100 [[nodiscard]]
static std::optional<std::size_t> findFirstReflexVertex(VertexArray
const& polygon);
102 static void flipPolygon(VertexArray& vertices);
104 [[nodiscard]]
static VertexIndexMap verticesAlongLineSegment(
fge::Line const& segment, VertexArray
const& vertices);
106 [[nodiscard]]
static std::optional<std::size_t>
107 addNewVertex(std::size_t& positionIndex, fge::Vector2f
const& direction, VertexArray& vertices);