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

fix spacing being added to atlas size #301

Conversation

antoinePaulinB7
Copy link
Contributor

If you want the proper count of the number of tiles / columns, the atlas size should be taken as is.

@antoinePaulinB7
Copy link
Contributor Author

@StarArawn I noticed that you mentioned this bit of code is contentious, so I thought what better to do than jump into as well.

@bzm3r
Copy link
Collaborator

bzm3r commented Oct 3, 2022

@antoinePaulinB7 Thanks for this PR! We just merged in some changes that are causing a conflict with your branch. Would you mind merging main back into your branch, to resolve the conflict?

@antoinePaulinB7
Copy link
Contributor Author

@bzm3r done :)

Copy link
Collaborator

@bzm3r bzm3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me at first glance, but I really think we need to put together a proper test for it. @antoinePaulinB7 Can you put in an asset and an example that clearly shows why this works, and the old method would not?

(texture_size.x + tile_spacing.x) / (tile_size.x + tile_spacing.x);
let tile_count_y =
(texture_size.y + tile_spacing.y) / (tile_size.y + tile_spacing.y);
let tile_count_x = (texture_size.x) / (tile_size.x + tile_spacing.x);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this making the assumption that every tile, including the last one in the atlas will have padding? Is that the right assumption here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed the assumption.

If we wanted to get rid of this assumption, I propose that we take inspiration from bevy's own bevy_sprite from_grid_with_padding.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antoinePaulinB7 I have been thinking about it, and I think it's a fine assumption, because it provides a lot of regularity and eliminates special cases. Perhaps it is something we can document, so users know that this is what we expect. I will create a separate issue for it if this PR gets merged, to work on documenting that.

@antoinePaulinB7
Copy link
Contributor Author

@bzm3r Hopefully, I'll have time to put together a test before the end of the week.

@bzm3r
Copy link
Collaborator

bzm3r commented Oct 8, 2022

@StarArawn Can you also review this PR, and see if it makes sense to you? It looks good to me!

@StarArawn StarArawn mentioned this pull request Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants