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

Method SetWindingCount

TheForceEngine/TFE_Polygon/clipper.cpp:1624–1722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1622//------------------------------------------------------------------------------
1623
1624void Clipper::SetWindingCount(TEdge &edge)
1625{
1626 TEdge *e = edge.PrevInAEL;
1627 //find the edge of the same polytype that immediately preceeds 'edge' in AEL
1628 while (e && ((e->PolyTyp != edge.PolyTyp) || (e->WindDelta == 0))) e = e->PrevInAEL;
1629 if (!e)
1630 {
1631 if (edge.WindDelta == 0)
1632 {
1633 PolyFillType pft = (edge.PolyTyp == ptSubject ? m_SubjFillType : m_ClipFillType);
1634 edge.WindCnt = (pft == pftNegative ? -1 : 1);
1635 }
1636 else
1637 edge.WindCnt = edge.WindDelta;
1638 edge.WindCnt2 = 0;
1639 e = m_ActiveEdges; //ie get ready to calc WindCnt2
1640 }
1641 else if (edge.WindDelta == 0 && m_ClipType != ctUnion)
1642 {
1643 edge.WindCnt = 1;
1644 edge.WindCnt2 = e->WindCnt2;
1645 e = e->NextInAEL; //ie get ready to calc WindCnt2
1646 }
1647 else if (IsEvenOddFillType(edge))
1648 {
1649 //EvenOdd filling ...
1650 if (edge.WindDelta == 0)
1651 {
1652 //are we inside a subj polygon ...
1653 bool Inside = true;
1654 TEdge *e2 = e->PrevInAEL;
1655 while (e2)
1656 {
1657 if (e2->PolyTyp == e->PolyTyp && e2->WindDelta != 0)
1658 Inside = !Inside;
1659 e2 = e2->PrevInAEL;
1660 }
1661 edge.WindCnt = (Inside ? 0 : 1);
1662 }
1663 else
1664 {
1665 edge.WindCnt = edge.WindDelta;
1666 }
1667 edge.WindCnt2 = e->WindCnt2;
1668 e = e->NextInAEL; //ie get ready to calc WindCnt2
1669 }
1670 else
1671 {
1672 //nonZero, Positive or Negative filling ...
1673 if (e->WindCnt * e->WindDelta < 0)
1674 {
1675 //prev edge is 'decreasing' WindCount (WC) toward zero
1676 //so we're outside the previous polygon ...
1677 if (Abs(e->WindCnt) > 1)
1678 {
1679 //outside prev poly but still inside another.
1680 //when reversing direction of prev poly use the same WC
1681 if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;

Callers

nothing calls this directly

Calls 1

AbsFunction · 0.85

Tested by

no test coverage detected