Adjusted Godot Atlas exporter to take margins into account#85
Open
jdbhartley wants to merge 3 commits intoodrick:masterfrom
Open
Adjusted Godot Atlas exporter to take margins into account#85jdbhartley wants to merge 3 commits intoodrick:masterfrom
jdbhartley wants to merge 3 commits intoodrick:masterfrom
Conversation
Gerfalerf
reviewed
Oct 10, 2023
| let sourceSize = {w: item.sourceSize.w, h: item.sourceSize.h}; | ||
|
|
||
| //Used when importing to Godot Atlas to retain the original sprite size | ||
| let margin = {x: (sourceSize.w - spriteSourceSize.w)/2, y: (sourceSize.h - spriteSourceSize.h)/2, h: sourceSize.h - spriteSourceSize.h, w: sourceSize.w - spriteSourceSize.w} |
There was a problem hiding this comment.
I think rather than splitting the difference of spriteSourceSize and sourceSize, margin.x and margin.y here should simply be set to spriteSourceSize.x and spriteSourceSize.y. Weird that spriteSourceSize is called a "size" when it has an offset like a rect, but those x/y values appear to be the actual offset of the sprite's subregion that was copied into the atlas.
Otherwise, change looks great. Just ran into this issue myself.
|
I also needed this fix, but I ended up creating a custom template based on built-in godot template that also takes margins into account. I replaced the End result: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the tool as an alternative to Texture Packer in Godot 4 I noticed that the margins were all set to 0 resulting in either a lot of fixing by hand or being left with sprites unusable for animation.