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

Most recently added current Camera2D takes precedence #50112

Merged
merged 1 commit into from
Jul 22, 2021

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Jul 3, 2021

The situation when multiple current Camera2Ds were in the scene was not dealt with. This could leave several cameras with their current bool set, and each competing to update the viewport scroll, in a random / accidental fashion.

This PR standardises the rule that the most recent current Camera2D added to the scene tree takes over the current status, and sets all other current cameras in the scene tree to non-current. This makes the bools correct, and also prevents the competition over viewport scroll.

Fixes #50091

Notes

  • This is made on the assumption that we want precedence to go to the most recently added current Camera2D
  • The _update_scroll is removed because it is called as part of make_current if the camera is current (if not current, the _update_scroll would be a noop anyway.
  • _set_current does also call update(). I'm not clear on whether this is absolutely necessary (i.e. we could call make_current directly), but I'm erring on the side of having as much updated as possible when entering the tree, which should be a rare event.
  • I can make PR for 4.x as well if we agree on this approach.
  • This is potentially a breaking change .. however the current behaviour is likely to be semi-random which isn't ideal.

The situation when multiple current Camera2Ds were in the scene was not dealt with. This could leave several cameras with their current bool set, and each competing to update the viewport scroll, in a random / accidental fashion.

This PR standardises the rule that the most recent current Camera2D added to the scene tree takes over the current status, and sets all other current cameras in the scene tree to non-current. This makes the bools correct, and also prevents the competition over viewport scroll.
@lawnjelly lawnjelly requested a review from a team as a code owner July 3, 2021 08:06
@Calinou Calinou added this to the 3.4 milestone Jul 3, 2021
@akien-mga akien-mga merged commit e3c5456 into godotengine:3.x Jul 22, 2021
@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
Development

Successfully merging this pull request may close these issues.

3 participants