-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gravity #245
Comments
Hello @giozecc What you're seeing is currently "by design" - the algorithm works by building "layers". Once each layer is built, the next layer on top is built assuming a flat horizontal surface (i.e. it doesn't know what came before). This means that the calculated position of a box does indeed sometimes "float". I'm currently of the belief that adjusting this to take account of space in the layer(s) beneath to more accurately model reality would probably be too computationally expensive to be worthwhile, but I haven't ruled it out completely for the future - there might be some tricks that e.g. game engines use for calculating bounds that could be adapted. Relevant code starts at https://github.com/dvdoug/BoxPacker/blob/3.x/src/VolumePacker.php#L205 if you're interested. |
Hi dvdoug,
and thank you for this wonderful tool. Very fast, very smart.
My question is about packing in the vertical direction. It seems that your algorithm allows producing very compact layers, but it does not create a compact stack.
This can happen when, in a bottom layer, there is a box higher than the others, like in the picture
Is there anything that I'm forgetting to do?
Here you can find the test
$packer = new Packer();
$packer->addBox(new TestBox('EPAL', 1200, 800, 3000, 1000, 1200, 800, 3000, 1800000));
$packer->addItem(new TestItem('Item 1', 250, 250, 200, 28000, false), 20);
$packer->addItem(new TestItem('Item 2', 150, 250, 200, 12000, false), 20);
$packer->addItem(new TestItem('Item 4', 125, 200, 100, 7000, false), 20);
$packer->addItem(new TestItem('Item 3', 250, 200, 200, 24000, false), 20);
$packedBoxes = $packer->pack();
Thank you
The text was updated successfully, but these errors were encountered: