From ff7e39ed272aac89c3e455d635fe9e09cd8a1f09 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 8 Mar 2024 22:48:06 +0300 Subject: [PATCH] fix --- src/maths/LMPacker.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/maths/LMPacker.cpp b/src/maths/LMPacker.cpp index c23ac2f6..804bd0be 100644 --- a/src/maths/LMPacker.cpp +++ b/src/maths/LMPacker.cpp @@ -19,15 +19,16 @@ LMPacker::LMPacker(const uint32_t sizes[], size_t length) { } LMPacker::~LMPacker() { + cleanup(); +} + +void LMPacker::cleanup() { if (matrix) { for (unsigned int y = 0; y < (height >> mbit); y++) { delete[] matrix[y]; } delete[] matrix; } -} - -void LMPacker::cleanup() { placed.clear(); } @@ -41,6 +42,7 @@ bool LMPacker::build(uint32_t width, uint32_t height, const unsigned int mwidth = width >> mbit; const unsigned int mheight = height >> mbit; + matrix = new rectangle**[mheight]; for (unsigned int y = 0; y < mheight; y++) { matrix[y] = new rectangle*[mwidth]; @@ -48,6 +50,7 @@ bool LMPacker::build(uint32_t width, uint32_t height, matrix[y][x] = nullptr; } } + for (unsigned int i = 0; i < rects.size(); i++) { rectangle& rect = rects[i]; rect = rectangle(rect.idx, 0, 0, rect.width, rect.height);