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 AtlasTexture::draw_rect flipping for non-zero margin #93828

Merged

Conversation

kleonc
Copy link
Member

@kleonc kleonc commented Jul 1, 2024

AtlasTexture::draw_rect was incorrectly handling flipping an AtlasTexture with non-zero margins (flipping is done by passing a destination rect with negative width/height).
This was noticable e.g. in TextureRect (which included incorrect workaround for that) when stretch_mode != STRETCH_KEEP_ASPECT_COVERED as that's when it uses CanvasItem::draw_texture_rect (which ends up calling AtlasTexture::draw_rect).

This PR makes AtlasTexture::draw_rect use AtlasTexture::get_rect_region to handle flipping logic etc. the same way as in AtlasTexture::draw_rect_region.

Properly fixes #37526 (#37615 was incorrect, it only made the issue hardly noticable for the test case reported in there specifically because of almost equal top/bottom margins; see the red/green discrepancy in the image below).

Modified MRP from #37526 with the examples below: Testing-AtlasTextureFlip4x.zip

  • TextureRect incorrectly flipping AtlasTexture with non-equal top/bottom margins (TestScene.tscn):
Before
(v4.3.beta2.official [b75f048])
After
(this PR)
Godot_v4 3-beta2_win64_vaIC5W3pzx godot windows editor dev x86_64_zBcu4z2BjY

Setup:

TyxBmLYhEm Godot_v4 3-beta2_win64_hEvhJsY6Px
  • Animating the margin, also comparing with Sprite2D (TestSceneWithAnim.tscn):
Before
(v4.3.beta2.official [b75f048])
After
(this PR)
nnLhZSL9Es MAqzaBMVTp

@kleonc kleonc added this to the 4.3 milestone Jul 1, 2024
@kleonc kleonc requested a review from a team as a code owner July 1, 2024 19:36
@akien-mga akien-mga merged commit 9425535 into godotengine:master Jul 1, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

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