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

SpriteFramesEditor: preserve source texture margins when creating frames from AtlasTexture #51030

Conversation

kleonc
Copy link
Member

@kleonc kleonc commented Jul 29, 2021

When creating frame from AtlasTexture its margin was ignored which can result in incorrect rendering.

Tested with MRP from #42806.
Source AtlasTexture:
VIQdxnyiTU

Created frames:

  • 3.3.2-stable:
    Godot_v3 3 2-stable_win64_0ja0b8fGyZ
[sub_resource type="AtlasTexture" id=1]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 4, 132, 16, 16 )

[sub_resource type="AtlasTexture" id=2]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 20, 132, 16, 16 )

[sub_resource type="AtlasTexture" id=3]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 36, 132, 16, 16 )

[sub_resource type="AtlasTexture" id=4]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 52, 132, 16, 16 )
  • This PR:
    godot windows tools 64_9cCqQulHbU
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 4, 132, 15, 16 )
margin = Rect2( 1, 0, 1, 0 )

[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 19, 132, 16, 16 )

[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 35, 132, 16, 16 )

[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 51, 132, 14, 16 )
margin = Rect2( 0, 0, 2, 0 )

@Calinou Calinou added bug topic:editor cherrypick:3.3 cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jul 29, 2021
@Calinou Calinou added this to the 4.0 milestone Jul 29, 2021
@Calinou Calinou removed cherrypick:3.3 cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jul 29, 2021
@akien-mga akien-mga merged commit 3e7a545 into godotengine:master Aug 16, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Does this fix #42806?

@kleonc
Copy link
Member Author

kleonc commented Aug 16, 2021

Does this fix #42806?

No, this PR only fixes preserving margins when creating frames from an AtlasTexture. Issue in #42806 happens when you:

  1. Create SpriteFrames with a source being a non-AtlasTexture texture. Frame regions won't have any margins because source texture has no margins.
  2. Then change import settings of that source texture so it will be imported as an AtlasTexture (combining it with other textures into spritesheet). Resulting AtlasTexture the SpriteFrames is referencing can now have some margins added because of packing optimization (transparent borders aren't stored directly in the generated spritesheet) but the frame regions in SpriteFrames are still unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants