Fix Atlas Merge Tool crash#101407
Conversation
|
Any chance this fix could be backported to 4.3? |
groud
left a comment
There was a problem hiding this comment.
Thanks! Aside from my small comment it looks good.
| Vector2i separation = atlas_source->get_tile_animation_separation(tile_id); | ||
| // Because `separation` is just the space between, | ||
| // the vector is off by 1 in one(or both) component(s). | ||
| separation.x += (separation.x) ? 1 : 0; |
There was a problem hiding this comment.
Those two lines look a bit weird to me. I think the rationale is kind ok but I don't understand why there's a check on whether or not separation.x or separation.y are 0. Wouldn't be seperation += Vector2i(1,1) be enough?
There was a problem hiding this comment.
We only need to add 1 to the animation frame movements that are intended. For example, if there is 0 separation for the y component then we aren't selecting any frames to the left and right at all, so adding 1 to it would alter that behavior and not be what we want.
As I was writing the above I realize I hadn't checked the 0 separation case's result in the editor, and I should probably have done that. Sure enough, it fails. I haven't been reasoning about this properly. I am leaving my crossed out comment there to hopefully explain my original train of thought. I should have remembered to test the normal cases as well.
The use of x, y, and combined with column count isn't my normal mental model for animation sequences. However, always adding (1,1) to separation doesn't quite work either. It results in the destination position moving in a diagonal - which does match my original intuitions.
I am working out how to take the src_rect's position, adjusting it to be tile coords and then multiplying it to align with the new atlas size.
Something like this:
Rect2i src_rect = atlas_source->get_tile_texture_region(tile_id, frame);
Size2i src_size = src_rect.get_size();
Vector2i new_position = Vector2i(
src_rect.position.x / src_size.width * new_texture_region_size.width,
src_rect.position.y / src_size.height * new_texture_region_size.height
);
But that isn't quite working right yet either - though I think I am on the right trail. It leaves worrying about the frame(and separation) to the get_tile_texture_region() call.
If it weren't for the fact that the two merging atlases could use different sized tiles it would be a simple 1 to 1 copy.
There was a problem hiding this comment.
I was not on the right trail with my last comment. This time I took heavy inspiration from get_tile_texture_region() and realized a few areas where I was mistaken before.
With that said, unfortunately I just found a new issue in my last round of checks where it fails to properly merge 4 of my larger tilesets. I will have to look deeper into it tomorrow.
There was a problem hiding this comment.
I just found a new issue in my last round of checks where it fails to properly merge 4 of my larger tilesets.
This issue has now been fixed. It wasn't properly enlarging the merged atlas vertical size when a tileset had vertical animation sequences. This has now been addressed.
There was a problem hiding this comment.
@groud You were right that the the conditional addition to separation was weird. I was nearly completely off with how I understood things to work. Thank you for catching that. I believe I have the right solution now.
The addition of (1,1) could now be thought of as being handled by the size_in_atlas variable in this line
I've made the changes requested(as much as they apply after several realizations) and marked it as resolved from my end. Is there anything else I need to do? |
|
Could you rebase your PR & squash your commits? See our pull request guidelines for more information |
My experience with git is quite limited. I am using github desktop. It was giving me a bunch of guff but I think I managed to get it to cooperate in the end. I've been waiting so long for someone to reach back on this I've completely brain dumped everything regarding it. |
|
The branch is still not squashed, you probably didn't force push your branch at the end with |
fcec71d to
53b5b47
Compare
That seems to have done it. Thank you! |
Repiteo
left a comment
There was a problem hiding this comment.
Great job! All that you need to do now is change the commit message to the GitHub title, as we want to avoid directly listing issue/PR links in them (they'll cause unwanted messages otherwise)
This comment was marked as resolved.
This comment was marked as resolved.
c021225 to
264d35d
Compare
This comment was marked as resolved.
This comment was marked as resolved.
264d35d to
2cbdffe
Compare
|
@groud do you still have reservations about this? Can you approve otherwise? |
|
Thanks! Congratulations on your first merged contribution! 🎉 |
Thanks! I appreciate all the help through my fumbling with this. |
|
Cherry-picked for 4.5.2. |
Fixes #101132
The fix exposed broken merging logic of atlases with animations.
Merging now properly copies animation frame locations
as well as correct sizing from input atlases to the merged atlas.