X Tutup
Skip to content

Don't redraw Sprite3D/AnimatedSprite3D outside the tree#112593

Merged
akien-mga merged 1 commit intogodotengine:masterfrom
kleonc:sprite3d_no_redrawing_outside_tree
Nov 26, 2025
Merged

Don't redraw Sprite3D/AnimatedSprite3D outside the tree#112593
akien-mga merged 1 commit intogodotengine:masterfrom
kleonc:sprite3d_no_redrawing_outside_tree

Conversation

@kleonc
Copy link
Member

@kleonc kleonc commented Nov 9, 2025

Fixes #112566.

Ensures SpriteBase3D::parent_sprite is set on NOTIFICATION_PARENTED/NOTIFICATION_UNPARENTED instead of on NOTIFICATION_ENTER_TREE/NOTIFICATION_EXIT_TREE. This was already enough to fix #112566 as the bug happened because SpriteBase3D::_draw() was called before the sprites entered the tree:

  • the redraw was queued when outside the tree, during scene instantiation when setting stored color/texture,
  • the MessageQueue was flushed before entering the tree, during physics processing (it's irrelevant where exactly),
  • the child sprite's dirty-marked color was updated as if it had no parent, and was marked as not dirty anymore with such incorrect cumulated-color,
  • scene was changed "at the end of a frame" (scene changes are deferred on their own, independent of MessageQueue/call_deffered calls).

Moreover, after the above there was another redraw triggered, as on NOTIFICATION_ENTER_TREE it would update/redraw immediately in case no redraw is enqueued, which was the case when reloading the scene (the another redraw would use wrong cumulated-color for the child sprite).

Redrawing being triggered when outside the tree seems pointless to me. 🤔
Hence I've made it not update when outside the tree, and update immediately on entering the tree. This makes e.g. on reloading the scene as in the MRP from #112566 the SpriteBase3D::_draw() be called only once per Sprite3D (instead of twice, including the first one outside the tree).

@kleonc kleonc added this to the 4.6 milestone Nov 9, 2025
@kleonc kleonc requested a review from a team as a code owner November 9, 2025 18:35
@kleonc kleonc added bug cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:3d cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release labels Nov 9, 2025
@kleonc kleonc force-pushed the sprite3d_no_redrawing_outside_tree branch from da51142 to 96332f1 Compare November 26, 2025 00:43
@kleonc kleonc changed the title Fix Sprite3D/AnimatedSprite3D redrawing when not inside the tree Don't redraw Sprite3D/AnimatedSprite3D outside the tree Nov 26, 2025
@akien-mga akien-mga merged commit 381473b into godotengine:master Nov 26, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 4.5.2.

@akien-mga akien-mga removed the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Jan 16, 2026
@kleonc kleonc deleted the sprite3d_no_redrawing_outside_tree branch January 16, 2026 14:02
@kleonc
Copy link
Member Author

kleonc commented Jan 16, 2026

If cherry-picking to 3.x, be sure to include #115037 as well (just tested #115036 in v3.6.2.stable.official [3cd3caa], it's bugged in there too).

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

Labels

bug cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:3d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sprite3D Modulated Children Reset Color Upon Reloading

2 participants

X Tutup