First of all, thanks for this insightful document! It has been very helpful while implementing a MAP compiler.
In the document MAP files file format description, algorithms, and code, the pseudocode implementation of Brush::ClipToBrush is:
void Brush::ClipToBrush ( Brush *pBrush, bool bClipOnPlane )
{
for i = 0 to NumberOfPolygons – 1
{
Polygons[ i ] = Polygons[ i ].ClipToList ( pBrush.Polygons, bClipOnPlane );
}
}
But I think it should be:
void Brush::ClipToBrush ( Brush *pBrush, bool bClipOnPlane )
{
for i = 0 to NumberOfPolygons – 1
{
Polygons[ i ] = pBrush.Polygons.ClipToList ( Polygons[ i ], bClipOnPlane );
}
}
I had a hard time understanding the implementation of ClipToList since it was treating this (Polygons[ i ]) as a list of polygons, whereas it is actually a single polygon. After some googling I found this repository and within it the actual implementation:
|
void Brush::ClipToBrush ( Brush *pBrush_, bool bClipOnPlane_ ) |
|
{ |
|
Poly *pPolyList = NULL; |
|
Poly *pPoly = m_pPolys; |
|
|
|
for ( int i = 0; i < GetNumberOfPolys ( ); i++ ) |
|
{ |
|
Poly *pClippedPoly = pBrush_->GetPolys ( )->ClipToList ( pPoly, bClipOnPlane_ ); |
|
|
|
if ( pPolyList == NULL ) |
|
{ |
|
pPolyList = pClippedPoly; |
|
} |
|
else |
|
{ |
|
pPolyList->AddPoly ( pClippedPoly ); |
|
} |
|
|
|
pPoly = pPoly->GetNext ( ); |
|
} |
|
|
|
delete m_pPolys; |
|
m_pPolys = pPolyList; |
|
} |
which seems to confirm that the this argument and the first argument to ClipToList are indeed swapped in the document's pseudocode implementation of Brush::ClipToBrush.
First of all, thanks for this insightful document! It has been very helpful while implementing a MAP compiler.
In the document MAP files file format description, algorithms, and code, the pseudocode implementation of
Brush::ClipToBrushis:But I think it should be:
I had a hard time understanding the implementation of
ClipToListsince it was treatingthis(Polygons[ i ]) as a list of polygons, whereas it is actually a single polygon. After some googling I found this repository and within it the actual implementation:map-files/brush.cpp
Lines 8 to 31 in f28e6a3
which seems to confirm that the
thisargument and the first argument toClipToListare indeed swapped in the document's pseudocode implementation ofBrush::ClipToBrush.