Boxes with small areas perform worse than larger boxes
When preparing box-areas for a custom uv-unwrapping algorithm, I end up with small boxes that combined together will fit a total area around 1 unit large, e.g.:
[
{ w: 0.05, h: 0.037 },
{ w: 0.015, h: 0.0087 },
{ w: 0.009, h: 0.013 },
...
]
when packing these boxes potpack will perform poorly, by laying the boxes mostly horizontally:
However pre-processing my boxes such that they're scaled up by a factor of 100+, will improve results dramatically:
const boxScale = 200;
rects = rects.map(r => ({ w: r.w * boxScale, h: r.h * boxScale }));
const res = potpack(rects);
rects = rects.map(r => ({ w: r.w / boxScale, h: r.h / boxScale, x: r.x / boxScale, y: r.y / boxScale }));
In case this is expected behavior, it would be nice if the documentation reflected this edge case since someone else might incorrectly assume that the algorithm doesn't work when in reality scaling up the boxes might fix the issue
Yeah, I think potpack assumes an integer grid for sizes since we're laying them out on a pixel grid. Worth adding a note in the readme docs.