*BinPack fixes -- disjointRects only defined #ifdef _DEBUG

This commit is contained in:
Kyle Evans 2016-01-18 14:45:23 -06:00
commit 7358817975
2 changed files with 26 additions and 3 deletions

View file

@ -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))