mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-27 22:42:57 +00:00
*BinPack fixes -- disjointRects only defined #ifdef _DEBUG
This commit is contained in:
parent
b63eb391f7
commit
7358817975
2 changed files with 26 additions and 3 deletions
|
@ -144,7 +144,9 @@ void GuillotineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst, bool
|
|||
usedRectangles.Push(newNode);
|
||||
|
||||
// Check that we're really producing correct packings here.
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Add(newNode) == true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,8 +357,9 @@ Rect GuillotineBinPack::Insert(int width, int height, bool merge, FreeRectChoice
|
|||
usedRectangles.Push(newRect);
|
||||
|
||||
// Check that we're really producing correct packings here.
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Add(newRect) == true);
|
||||
|
||||
#endif
|
||||
return newRect;
|
||||
}
|
||||
|
||||
|
@ -442,7 +445,9 @@ Rect GuillotineBinPack::FindPositionForNewNode(int width, int height, FreeRectCh
|
|||
bestNode.height = height;
|
||||
bestScore = INT_MIN;
|
||||
*nodeIndex = i;
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(bestNode));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
// If this is a perfect fit sideways, choose it.
|
||||
|
@ -470,7 +475,9 @@ Rect GuillotineBinPack::FindPositionForNewNode(int width, int height, FreeRectCh
|
|||
bestNode.height = height;
|
||||
bestScore = score;
|
||||
*nodeIndex = i;
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(bestNode));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// Does the rectangle fit sideways?
|
||||
|
@ -575,8 +582,10 @@ void GuillotineBinPack::SplitFreeRectAlongAxis(const Rect &freeRect, const Rect
|
|||
if (right.width > 0 && right.height > 0)
|
||||
freeRectangles.Push(right);
|
||||
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(bottom));
|
||||
assert(disjointRects.Disjoint(right));
|
||||
#endif
|
||||
}
|
||||
|
||||
void GuillotineBinPack::MergeFreeList()
|
||||
|
|
|
@ -69,7 +69,9 @@ void SkylineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst)
|
|||
int score2;
|
||||
int index;
|
||||
newNode = FindPositionForNewNodeMinWaste(rects[i].width, rects[i].height, score2, score1, index);
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
#endif
|
||||
if (newNode.height != 0)
|
||||
{
|
||||
if (score1 < bestScore1 || (score1 == bestScore1 && score2 < bestScore2))
|
||||
|
@ -87,8 +89,8 @@ void SkylineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst)
|
|||
return;
|
||||
|
||||
// Perform the actual packing.
|
||||
assert(disjointRects.Disjoint(bestNode));
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(bestNode));
|
||||
disjointRects.Add(bestNode);
|
||||
#endif
|
||||
AddSkylineLevel(bestSkylineIndex, bestNode);
|
||||
|
@ -103,7 +105,9 @@ Rect SkylineBinPack::Insert(int width, int height)
|
|||
// First try to pack this rectangle into the waste map, if it fits.
|
||||
Rect node = wasteMap.Insert(width, height, true, GuillotineBinPack::RectBestShortSideFit,
|
||||
GuillotineBinPack::SplitMaximizeArea);
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(node));
|
||||
#endif
|
||||
|
||||
if (node.height != 0)
|
||||
{
|
||||
|
@ -113,8 +117,8 @@ Rect SkylineBinPack::Insert(int width, int height)
|
|||
newNode.width = node.width;
|
||||
newNode.height = node.height;
|
||||
usedSurfaceArea += width * height;
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
disjointRects.Add(newNode);
|
||||
#endif
|
||||
return newNode;
|
||||
|
@ -190,7 +194,9 @@ void SkylineBinPack::AddWasteMapArea(int skylineNodeIndex, int width, int height
|
|||
waste.width = rightSide - leftSide;
|
||||
waste.height = y - skyLine[skylineNodeIndex].y;
|
||||
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(waste));
|
||||
#endif
|
||||
wasteMap.GetFreeRectangles().Push(waste);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +270,9 @@ Rect SkylineBinPack::InsertBottomLeft(int width, int height)
|
|||
|
||||
if (bestIndex != -1)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
#endif
|
||||
// Perform the actual packing.
|
||||
AddSkylineLevel(bestIndex, newNode);
|
||||
|
||||
|
@ -300,7 +308,9 @@ Rect SkylineBinPack::FindPositionForNewNodeBottomLeft(int width, int height, int
|
|||
newNode.y = y;
|
||||
newNode.width = width;
|
||||
newNode.height = height;
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* if (RectangleFits(i, height, width, y))
|
||||
|
@ -331,7 +341,9 @@ Rect SkylineBinPack::InsertMinWaste(int width, int height)
|
|||
|
||||
if (bestIndex != -1)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
#endif
|
||||
// Perform the actual packing.
|
||||
AddSkylineLevel(bestIndex, newNode);
|
||||
|
||||
|
@ -369,7 +381,9 @@ Rect SkylineBinPack::FindPositionForNewNodeMinWaste(int width, int height, int &
|
|||
newNode.y = y;
|
||||
newNode.width = width;
|
||||
newNode.height = height;
|
||||
#ifdef _DEBUG
|
||||
assert(disjointRects.Disjoint(newNode));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* if (RectangleFits(i, height, width, y, wastedArea))
|
||||
|
|
Loading…
Reference in a new issue