Skip to content
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

Packing result is worse when rotation allowed #14

Closed
JoHuang opened this issue Dec 23, 2019 · 10 comments
Closed

Packing result is worse when rotation allowed #14

JoHuang opened this issue Dec 23, 2019 · 10 comments
Labels
bug Something isn't working

Comments

@JoHuang
Copy link
Contributor

JoHuang commented Dec 23, 2019

This PR #6 fixed options not passing through.
However, after allowing rotation, my packing result needs more area. (Can't fit in original constraint size)

I have to manually disable rotation to ensure my result the same as before.

Is this a normal case?

@odrick
Copy link
Owner

odrick commented Dec 23, 2019

I don't think so...

Could you please give me you test assets and pack options?

@odrick odrick added the bug Something isn't working label Dec 23, 2019
@kane-mason
Copy link

I'm also seeing this, not always but often. Using MaxRectsPacker and Smart method. Can supply assets if needed privately

@JoHuang
Copy link
Contributor Author

JoHuang commented Jan 6, 2020

@odrick Sorry I can't supply assets because it's private assets, and currently have no time to give a minimal test case.

@kane-mason
Copy link

kane-mason commented Jan 6, 2020

Here is one example of the gitlab diff for such a case:

image

Tagging @qtiki to see if he may be able to shed any light.

@kane-mason
Copy link

i've emailed source assets

@odrick
Copy link
Owner

odrick commented Jan 24, 2020

Thanks. I will investigate this problem next week.

@kane-mason
Copy link

Any update here?

@odrick
Copy link
Owner

odrick commented Feb 28, 2020

Ok, this is a maxrects-packer bug. Reported: soimy/maxrects-packer#14

@qtiki
Copy link
Contributor

qtiki commented Feb 28, 2020

Sorry guys for the radio silence, I've been quite busy with other stuff.

I don't think this is a bug as such. The way that these packing algorithms work is that they sort the bins based on some arbitrary rules and then try to guess the best fit locally (first-fit) to any given area. The problem is that while the guess might be a good thing locally it might cause problems later on in the packing. If the algorithm were to try all the possible combinations to find the "perfect" match it would become exponentially slower. If you're interested in more details I recommend reading the Wikipedia page Bin packing problem.

In regards to the free-tex-packer I think the best option would be to extend the OptimalPacker to try all the packing methods with and without rotation allowed (for those that support rotation that is). That would make the packing a bit slower again but will at least give the same results as manually trying to tweak every parameter. In the end the more variations we test the better the result will be, however trying to reach a "perfect" outcome is not really feasible. This is basically why I implemented the OptimalPacker that tries all the combinations instead of trying to make an exact method that solves this problem perfectly for all cases.

odrick added a commit that referenced this issue Mar 3, 2020
@odrick
Copy link
Owner

odrick commented Mar 3, 2020

Ok. OptimalPacker now check all combos with/without rotation.

@odrick odrick closed this as completed Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants