X Tutup
Skip to content

FTI - Camera2D accepts resets only after entering tree#112810

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
lawnjelly:fti_camera2d_accept_resets
Nov 25, 2025
Merged

FTI - Camera2D accepts resets only after entering tree#112810
Repiteo merged 1 commit intogodotengine:masterfrom
lawnjelly:fti_camera2d_accept_resets

Conversation

@lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Nov 15, 2025

Fixes #112689

#111384 introduced a warning when calling Camera2D::get_camera_transform() before the camera viewports had been set up in NOTIFICATION_ENTER_TREE.

This flagged a benign warning when using physics interpolation on Camera2D, because it inherits a standard reset from CanvasItem which is called before Camera2D NOTIFICATION_ENTER_TREE.

Here we use a simple approach to fix the warning, by adding a state flag of whether to accept resets, and set to true after setup, and set to false when exiting the tree.

Notes

  • There's a number of ways of fixing this - we could alternatively just not spam the warning introduced in Fix incorrect transform calculation in Camera2D when using a custom viewport #111384. Although it's fairly easy to workaround here, and it is possible the warning might catch bugs.
  • The post-warning and the previous version both work fine, as there is a secondary manual reset performed in Camera2D at the end of NOTIFICATION_ENTER_TREE (and a comment to that effect), so this warning is purely cosmetic.
  • Not necessary in 3.x as we don't have the warning.

Discussion

As noted in the issue, this is caused by the CanvasItem NOTIFICATION_ENTER_TREE being called before the Camera2D, so the resets can't depend on any state set up in derived classes, which isn't ideal, but thus far this hasn't been a significant problem - most classes xforms are up to date by this point.

An alternative we sometimes use is to defer resets, but this has the potential to cause knock on bugs particularly with moving and standing starts with manual resets from script, so on balance it would be nice to avoid this bug potential and keep a local solution, at least for now. If we get any later similar issues we can re-evaluate this.

@lawnjelly lawnjelly added the bug label Nov 15, 2025
@lawnjelly lawnjelly requested a review from a team as a code owner November 15, 2025 12:16
@AThousandShips AThousandShips added this to the 4.6 milestone Nov 17, 2025
@Repiteo Repiteo merged commit 4dbac6e into godotengine:master Nov 25, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 25, 2025

Thanks!

@lawnjelly lawnjelly deleted the fti_camera2d_accept_resets branch November 25, 2025 19:58
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.

Error with Camera2D and physics_interpolation

4 participants

X Tutup