MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / addEdgeToBPoly

Function addEdgeToBPoly

TheForceEngine/TFE_Polygon/polygon.cpp:824–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

822 }
823
824 bool addEdgeToBPoly(Vec2f v0, Vec2f v1, BPolygon* poly)
825 {
826 // Discard degenerate edges.
827 if (vtxEqual(&v0, &v1))
828 {
829 return false;
830 }
831
832 BEdge newEdge = {};
833 newEdge.v0 = v0;
834 newEdge.v1 = v1;
835
836 const s32 newEdgeIndex = (s32)poly->edges.size();
837 const s32 edgeCount = (s32)poly->edges.size();
838 BEdge* edge = poly->edges.data();
839 for (s32 e = 0; e < edgeCount; e++, edge++)
840 {
841 if (vtxEqual(&v0, &edge->v0) && vtxEqual(&v1, &edge->v1))
842 {
843 return false;
844 }
845
846 if (vtxEqual(&v1, &edge->v0))
847 {
848 newEdge.nextEdge = e;
849 edge->prevEdge = newEdgeIndex;
850 }
851 if (vtxEqual(&v0, &edge->v1))
852 {
853 newEdge.prevEdge = e;
854 edge->nextEdge = newEdgeIndex;
855 }
856 }
857
858 poly->edges.push_back(newEdge);
859 return true;
860 }
861
862 struct Intersection
863 {

Callers 5

insertPointsIntoPolygonsFunction · 0.85
clipPolygonsFunction · 0.85
insertShapeWithBooleanFunction · 0.85

Calls 4

vtxEqualFunction · 0.85
dataMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected