// // Cut a partitioning poly by a list of polys, and add the resulting inside pieces to the // front list and back list. // static void SplitPartitioner ( UModel* Model, FPoly** PolyList, FPoly** FrontList, FPoly** BackList, int32 n, int32 nPolys, int32& nFront, int32& nBack, FPoly InfiniteEdPoly, TArray<FPoly*>& AllocatedFPolys ) { FPoly FrontPoly,BackPoly; while( n < nPolys ) { FPoly* Poly = PolyList[n]; switch( InfiniteEdPoly.SplitWithPlane(Poly->Vertices[0],Poly->Normal,&FrontPoly,&BackPoly,0) ) { case SP_Coplanar: // May occasionally happen. // UE_LOG(LogBSPOps, Log, TEXT("FilterBound: Got inficoplanar") ); break; case SP_Front: // Shouldn't happen if hull is correct. // UE_LOG(LogBSPOps, Log, TEXT("FilterBound: Got infifront") ); return; case SP_Split: InfiniteEdPoly = BackPoly; break; case SP_Back: break; } n++; } FPoly* New = new FPoly; *New = InfiniteEdPoly; New->Reverse(); New->iBrushPoly |= 0x40000000; FrontList[nFront++] = New; AllocatedFPolys.Add( New ); New = new FPoly; *New = InfiniteEdPoly; BackList[nBack++] = New; AllocatedFPolys.Add( New ); }
FPoly FPoly::BuildAndCutInfiniteFPoly(const FPlane& InPlane, const TArray<FPlane>& InCutPlanes, ABrush* InOwnerBrush) { FPoly PolyMerged = BuildInfiniteFPoly( InPlane ); PolyMerged.Finalize( InOwnerBrush, 1 ); FPoly Front, Back; int32 result; for( int32 p = 0 ; p < InCutPlanes.Num() ; ++p ) { const FPlane* Plane = &InCutPlanes[p]; result = PolyMerged.SplitWithPlane( Plane->GetSafeNormal() * Plane->W, Plane->GetSafeNormal(), &Front, &Back, 1 ); if( result == SP_Split ) { PolyMerged = Back; } } PolyMerged.Reverse(); return PolyMerged; }