16 decltype(polygon->pHead) vertex,
18 Interpolate interpolate,
21 { polygon->nCount } -> std::same_as<int &>;
22 { vertex->pNext } -> std::same_as<
decltype(polygon->pHead) &>;
23 { distance(vertex) } -> std::convertible_to<float>;
24 { interpolate(vertex, vertex, 0.0f) } -> std::same_as<
decltype(polygon->pHead)>;
25 { recycle(vertex) } -> std::same_as<void>;
44 Interpolate interpolate,
47 if (pPolygon->pHead ==
nullptr || pPolygon->nCount <= 0) {
52 auto *pCurrent = pPolygon->pHead;
53 auto *pNext = pCurrent->pNext;
54 auto *pPrevious = pCurrent;
55 decltype(pCurrent) pRemoved =
nullptr;
56 int nRemaining = pPolygon->nCount;
59 auto *head = pPrevious->pNext;
62 auto *next = vertex->pNext;
65 }
while (vertex != head);
67 auto *removed = pRemoved;
68 pRemoved = removed->pNext;
71 pPolygon->pHead =
nullptr;
75 while (nRemaining > 0) {
76 float fNextDistance = distance(pNext);
77 float fCurrentDistance = distance(pCurrent);
78 auto *pFollowing = pNext->pNext;
79 if (fNextDistance >= 0.0f) {
80 if (fCurrentDistance >= 0.0f) {
83 float fFraction =
static_cast<float>(
85 (
static_cast<long double>(fCurrentDistance) - fNextDistance));
86 auto *pIntersection = interpolate(pCurrent, pNext, fFraction);
88 if (pIntersection ==
nullptr) {
93 pIntersection->pNext = pPrevious->pNext;
94 pPrevious->pNext = pIntersection;
99 if (pPrevious->pNext) {
100 pPrevious->pNext = pPrevious->pNext->pNext;
102 pNext->pNext = pRemoved;
104 if (fCurrentDistance >= 0.0f) {
105 float fFraction =
static_cast<float>(
106 fNextDistance / (
static_cast<long double>(fNextDistance) - fCurrentDistance));
107 auto *pIntersection = interpolate(pNext, pCurrent, fFraction);
109 if (pIntersection ==
nullptr) {
114 pIntersection->pNext = pPrevious->pNext;
115 pPrevious->pNext = pIntersection;
116 pPrevious = pIntersection;
123 if (pPolygon->nCount < 2) {
128 pPolygon->pHead = pNext;
130 auto *pVertex = pRemoved;
131 pRemoved = pRemoved->pNext;
static void ClipLinkedPolygonPlane(Polygon *pPolygon, Distance distance, Interpolate interpolate, Recycle recycle)
Clip a circular vertex list to the non-negative side of a plane.
Definition clipplane.h:42
Require a circular vertex list, signed distances, interpolation, and recycling operations.
Definition clipplane.h:15