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

Method AppendPolygon

TheForceEngine/TFE_Polygon/clipper.cpp:2367–2460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2365//------------------------------------------------------------------------------
2366
2367void Clipper::AppendPolygon(TEdge *e1, TEdge *e2)
2368{
2369 //get the start and ends of both output polygons ...
2370 OutRec *outRec1 = m_PolyOuts[e1->OutIdx];
2371 OutRec *outRec2 = m_PolyOuts[e2->OutIdx];
2372
2373 OutRec *holeStateRec;
2374 if (OutRec1RightOfOutRec2(outRec1, outRec2))
2375 holeStateRec = outRec2;
2376 else if (OutRec1RightOfOutRec2(outRec2, outRec1))
2377 holeStateRec = outRec1;
2378 else
2379 holeStateRec = GetLowermostRec(outRec1, outRec2);
2380
2381 //get the start and ends of both output polygons and
2382 //join e2 poly onto e1 poly and delete pointers to e2 ...
2383
2384 OutPt* p1_lft = outRec1->Pts;
2385 OutPt* p1_rt = p1_lft->Prev;
2386 OutPt* p2_lft = outRec2->Pts;
2387 OutPt* p2_rt = p2_lft->Prev;
2388
2389 //join e2 poly onto e1 poly and delete pointers to e2 ...
2390 if( e1->Side == esLeft )
2391 {
2392 if( e2->Side == esLeft )
2393 {
2394 //z y x a b c
2395 ReversePolyPtLinks(p2_lft);
2396 p2_lft->Next = p1_lft;
2397 p1_lft->Prev = p2_lft;
2398 p1_rt->Next = p2_rt;
2399 p2_rt->Prev = p1_rt;
2400 outRec1->Pts = p2_rt;
2401 } else
2402 {
2403 //x y z a b c
2404 p2_rt->Next = p1_lft;
2405 p1_lft->Prev = p2_rt;
2406 p2_lft->Prev = p1_rt;
2407 p1_rt->Next = p2_lft;
2408 outRec1->Pts = p2_lft;
2409 }
2410 } else
2411 {
2412 if( e2->Side == esRight )
2413 {
2414 //a b c z y x
2415 ReversePolyPtLinks(p2_lft);
2416 p1_rt->Next = p2_rt;
2417 p2_rt->Prev = p1_rt;
2418 p2_lft->Next = p1_lft;
2419 p1_lft->Prev = p2_lft;
2420 } else
2421 {
2422 //a b c x y z
2423 p1_rt->Next = p2_lft;
2424 p2_lft->Prev = p1_rt;

Callers

nothing calls this directly

Calls 3

OutRec1RightOfOutRec2Function · 0.85
GetLowermostRecFunction · 0.85
ReversePolyPtLinksFunction · 0.85

Tested by

no test coverage detected