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

Limit the editor zoom and freelook speed based on camera settings #39743

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Jun 22, 2020

Just for fun, I recently decided to zoom out as far as Godot would allow me to. After zooming out such that the indicator says about 4 quadrillion, Godot started using gigabytes of RAM and my Linux computer froze due to running out of memory. So, I set out to add some limits to the zooming to prevent this, but I realized we could do much better than just limiting to a quadrillion or so, we could actually set some sensible and dynamic limits.

This PR sets a limit for zoom and freelook speed based on the camera's near and far clipping planes, while also having some hard-coded limits (10 thousand for single precision, which allows fitting the usable area in the whole screen with some margin, and 1 trillion for double precision, which is slightly smaller than double's usable area).

With this PR, the focused point is guaranteed(*) to be inside of the camera's clipping area, while previously it was super easy to zoom in a way that made the object invisible.

Also, since there is now both a minimum and maximum, the bars now have an accurate top and bottom end. Previously, zooming out would just exponentially get closer to the bottom of the bar.

I requested a review from @Calinou and @Zylann since they have touched this code before.

(* technically it can get out of the clipping area if the near and far planes are extremely close together but that's not normal usage of the editor camera and at that point you'll have a hard time fitting anything into the clipping area anyway)

This fixes #37034, fixes #40014, fixes #43467.

3.2 version: https://github.com/aaronfranke/godot/tree/3.2-limit-zoom

@aaronfranke aaronfranke added this to the 4.0 milestone Jun 22, 2020
@aaronfranke aaronfranke changed the title Limit the zoom and freelook speed based on camera settings Limit the editor zoom and freelook speed based on camera settings Jun 22, 2020
@akien-mga akien-mga removed their request for review June 22, 2020 06:26
@aaronfranke aaronfranke requested a review from groud August 27, 2020 05:45
@aaronfranke aaronfranke added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 17, 2020
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as intended.

@akien-mga akien-mga merged commit fbbbd9f into godotengine:master Dec 2, 2020
@akien-mga
Copy link
Member

Thanks!

@aaronfranke aaronfranke deleted the limit-zoom branch December 2, 2020 12:36
@akien-mga
Copy link
Member

Cherry-picked for 3.2.4.

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