This commit is contained in:
Christoph Oelckers 2016-01-19 01:11:13 +01:00
commit c02d922014
3 changed files with 28 additions and 4 deletions

View file

@ -144,7 +144,9 @@ void GuillotineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst, bool
usedRectangles.Push(newNode); usedRectangles.Push(newNode);
// Check that we're really producing correct packings here. // Check that we're really producing correct packings here.
#ifdef _DEBUG
assert(disjointRects.Add(newNode) == true); assert(disjointRects.Add(newNode) == true);
#endif
} }
} }
@ -355,8 +357,9 @@ Rect GuillotineBinPack::Insert(int width, int height, bool merge, FreeRectChoice
usedRectangles.Push(newRect); usedRectangles.Push(newRect);
// Check that we're really producing correct packings here. // Check that we're really producing correct packings here.
#ifdef _DEBUG
assert(disjointRects.Add(newRect) == true); assert(disjointRects.Add(newRect) == true);
#endif
return newRect; return newRect;
} }
@ -442,7 +445,9 @@ Rect GuillotineBinPack::FindPositionForNewNode(int width, int height, FreeRectCh
bestNode.height = height; bestNode.height = height;
bestScore = INT_MIN; bestScore = INT_MIN;
*nodeIndex = i; *nodeIndex = i;
#ifdef _DEBUG
assert(disjointRects.Disjoint(bestNode)); assert(disjointRects.Disjoint(bestNode));
#endif
break; break;
} }
// If this is a perfect fit sideways, choose it. // If this is a perfect fit sideways, choose it.
@ -470,7 +475,9 @@ Rect GuillotineBinPack::FindPositionForNewNode(int width, int height, FreeRectCh
bestNode.height = height; bestNode.height = height;
bestScore = score; bestScore = score;
*nodeIndex = i; *nodeIndex = i;
#ifdef _DEBUG
assert(disjointRects.Disjoint(bestNode)); assert(disjointRects.Disjoint(bestNode));
#endif
} }
} }
// Does the rectangle fit sideways? // Does the rectangle fit sideways?
@ -575,8 +582,10 @@ void GuillotineBinPack::SplitFreeRectAlongAxis(const Rect &freeRect, const Rect
if (right.width > 0 && right.height > 0) if (right.width > 0 && right.height > 0)
freeRectangles.Push(right); freeRectangles.Push(right);
#ifdef _DEBUG
assert(disjointRects.Disjoint(bottom)); assert(disjointRects.Disjoint(bottom));
assert(disjointRects.Disjoint(right)); assert(disjointRects.Disjoint(right));
#endif
} }
void GuillotineBinPack::MergeFreeList() void GuillotineBinPack::MergeFreeList()

View file

@ -69,7 +69,9 @@ void SkylineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst)
int score2; int score2;
int index; int index;
newNode = FindPositionForNewNodeMinWaste(rects[i].width, rects[i].height, score2, score1, index); newNode = FindPositionForNewNodeMinWaste(rects[i].width, rects[i].height, score2, score1, index);
#ifdef _DEBUG
assert(disjointRects.Disjoint(newNode)); assert(disjointRects.Disjoint(newNode));
#endif
if (newNode.height != 0) if (newNode.height != 0)
{ {
if (score1 < bestScore1 || (score1 == bestScore1 && score2 < bestScore2)) if (score1 < bestScore1 || (score1 == bestScore1 && score2 < bestScore2))
@ -87,8 +89,8 @@ void SkylineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst)
return; return;
// Perform the actual packing. // Perform the actual packing.
assert(disjointRects.Disjoint(bestNode));
#ifdef _DEBUG #ifdef _DEBUG
assert(disjointRects.Disjoint(bestNode));
disjointRects.Add(bestNode); disjointRects.Add(bestNode);
#endif #endif
AddSkylineLevel(bestSkylineIndex, bestNode); 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. // First try to pack this rectangle into the waste map, if it fits.
Rect node = wasteMap.Insert(width, height, true, GuillotineBinPack::RectBestShortSideFit, Rect node = wasteMap.Insert(width, height, true, GuillotineBinPack::RectBestShortSideFit,
GuillotineBinPack::SplitMaximizeArea); GuillotineBinPack::SplitMaximizeArea);
#ifdef _DEBUG
assert(disjointRects.Disjoint(node)); assert(disjointRects.Disjoint(node));
#endif
if (node.height != 0) if (node.height != 0)
{ {
@ -113,8 +117,8 @@ Rect SkylineBinPack::Insert(int width, int height)
newNode.width = node.width; newNode.width = node.width;
newNode.height = node.height; newNode.height = node.height;
usedSurfaceArea += width * height; usedSurfaceArea += width * height;
assert(disjointRects.Disjoint(newNode));
#ifdef _DEBUG #ifdef _DEBUG
assert(disjointRects.Disjoint(newNode));
disjointRects.Add(newNode); disjointRects.Add(newNode);
#endif #endif
return newNode; return newNode;
@ -190,7 +194,9 @@ void SkylineBinPack::AddWasteMapArea(int skylineNodeIndex, int width, int height
waste.width = rightSide - leftSide; waste.width = rightSide - leftSide;
waste.height = y - skyLine[skylineNodeIndex].y; waste.height = y - skyLine[skylineNodeIndex].y;
#ifdef _DEBUG
assert(disjointRects.Disjoint(waste)); assert(disjointRects.Disjoint(waste));
#endif
wasteMap.GetFreeRectangles().Push(waste); wasteMap.GetFreeRectangles().Push(waste);
} }
} }
@ -264,7 +270,9 @@ Rect SkylineBinPack::InsertBottomLeft(int width, int height)
if (bestIndex != -1) if (bestIndex != -1)
{ {
#ifdef _DEBUG
assert(disjointRects.Disjoint(newNode)); assert(disjointRects.Disjoint(newNode));
#endif
// Perform the actual packing. // Perform the actual packing.
AddSkylineLevel(bestIndex, newNode); AddSkylineLevel(bestIndex, newNode);
@ -300,7 +308,9 @@ Rect SkylineBinPack::FindPositionForNewNodeBottomLeft(int width, int height, int
newNode.y = y; newNode.y = y;
newNode.width = width; newNode.width = width;
newNode.height = height; newNode.height = height;
#ifdef _DEBUG
assert(disjointRects.Disjoint(newNode)); assert(disjointRects.Disjoint(newNode));
#endif
} }
} }
/* if (RectangleFits(i, height, width, y)) /* if (RectangleFits(i, height, width, y))
@ -331,7 +341,9 @@ Rect SkylineBinPack::InsertMinWaste(int width, int height)
if (bestIndex != -1) if (bestIndex != -1)
{ {
#ifdef _DEBUG
assert(disjointRects.Disjoint(newNode)); assert(disjointRects.Disjoint(newNode));
#endif
// Perform the actual packing. // Perform the actual packing.
AddSkylineLevel(bestIndex, newNode); AddSkylineLevel(bestIndex, newNode);
@ -369,7 +381,9 @@ Rect SkylineBinPack::FindPositionForNewNodeMinWaste(int width, int height, int &
newNode.y = y; newNode.y = y;
newNode.width = width; newNode.width = width;
newNode.height = height; newNode.height = height;
#ifdef _DEBUG
assert(disjointRects.Disjoint(newNode)); assert(disjointRects.Disjoint(newNode));
#endif
} }
} }
/* if (RectangleFits(i, height, width, y, wastedArea)) /* if (RectangleFits(i, height, width, y, wastedArea))

View file

@ -76,7 +76,8 @@ angle_t FNodeBuilder::PointToAngle (fixed_t x, fixed_t y)
#else // !__APPLE__ || __llvm__ #else // !__APPLE__ || __llvm__
double ang = atan2 (double(y), double(x)); double ang = atan2 (double(y), double(x));
#endif // __APPLE__ && !__llvm__ #endif // __APPLE__ && !__llvm__
return angle_t(ang * rad2bam) << 1; // Convert to signed first since negative double to unsigned is undefined.
return angle_t(int(ang * rad2bam)) << 1;
} }
void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max) void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max)