-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Reverse Camera2D zoom #55731
Reverse Camera2D zoom #55731
Conversation
The documentation should be updated too. godot/doc/classes/Camera2D.xml Lines 157 to 159 in e53e357
|
Point2 old_smoothed_camera_pos = smoothed_camera_pos; | ||
_update_scroll(); | ||
smoothed_camera_pos = old_smoothed_camera_pos; | ||
}; | ||
|
||
Vector2 Camera2D::get_zoom() const { | ||
return zoom; | ||
return Vector2(1, 1) / zoom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if zoom == Vector2(0, 0)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't, unless you somehow set it outside setter.
Point2 old_smoothed_camera_pos = smoothed_camera_pos; | ||
_update_scroll(); | ||
smoothed_camera_pos = old_smoothed_camera_pos; | ||
}; | ||
|
||
Vector2 Camera2D::get_zoom() const { | ||
return zoom; | ||
return Vector2(1, 1) / zoom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this cause a rounding error?
Vector2(1, 1) / (Vector2(1, 1) / zoom)
does not always equal to zoom
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. You PR is probably better then.
Closing in favor of #57392 |
Bugsquad edit: Implements and closes godotengine/godot-proposals#3888
This PR changes how
zoom
property of Camera2D works, so e.g. "zoom = 2" is now "zoom-in 2x", which is much more intuitive (previously it would zoom out).Alternatively we could rename the property to
view_rect_scale
or similar, because that's what it actually does right now.