Skip to content

Boxes with small areas perform worse than larger boxes #13

Description

@DomenicoBruzzese

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:

Image

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 }));
Image

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions