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);
// 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()

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

View file

@ -76,7 +76,8 @@ angle_t FNodeBuilder::PointToAngle (fixed_t x, fixed_t y)
#else // !__APPLE__ || __llvm__
double ang = atan2 (double(y), double(x));
#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)