Improved GuillotineBinPack
Added explicit copy/move constructor/operator Added Expand method Added Insert overloads (you are now able to query which rectangles were inserted) Made occupancy computation more precise Overloaded methods taking a unsigned int pair with Vector2ui Former-commit-id: f063c04a1aea0d26594db642c2466264fe139450
This commit is contained in:
@@ -40,10 +40,16 @@ class NAZARA_API NzGuillotineBinPack
|
||||
|
||||
NzGuillotineBinPack();
|
||||
NzGuillotineBinPack(unsigned int width, unsigned int height);
|
||||
NzGuillotineBinPack(const NzVector2ui& size);
|
||||
NzGuillotineBinPack(const NzGuillotineBinPack&) = default;
|
||||
NzGuillotineBinPack(NzGuillotineBinPack&&) = default;
|
||||
~NzGuillotineBinPack() = default;
|
||||
|
||||
void Clear();
|
||||
|
||||
void Expand(unsigned int newWidth, unsigned newHeight);
|
||||
void Expand(const NzVector2ui& newSize);
|
||||
|
||||
void FreeRectangle(const NzRectui& rect);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
@@ -51,12 +57,18 @@ class NAZARA_API NzGuillotineBinPack
|
||||
NzVector2ui GetSize() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool Insert(NzRectui* rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(NzRectui* rects, bool* flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(NzRectui* rects, bool* flipped, bool* inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
|
||||
bool MergeFreeRectangles();
|
||||
|
||||
void Reset();
|
||||
void Reset(unsigned int width, unsigned int height);
|
||||
void Reset(const NzVector2ui& size);
|
||||
|
||||
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
|
||||
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
|
||||
|
||||
private:
|
||||
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
|
||||
@@ -65,8 +77,8 @@ class NAZARA_API NzGuillotineBinPack
|
||||
static int ScoreByHeuristic(int width, int height, const NzRectui& freeRect, FreeRectChoiceHeuristic rectChoice);
|
||||
|
||||
std::vector<NzRectui> m_freeRectangles;
|
||||
float m_occupancy;
|
||||
unsigned int m_height;
|
||||
unsigned int m_usedArea;
|
||||
unsigned int m_width;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user