-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Remove OrthographicProjection.scale #11022
Conversation
ce10529
to
51db5b3
Compare
I usually set |
This could easily be fixed by implementing |
If this is merged, we should merge #11030 with it. |
I believe this may lead to an ergonomics loss for users who want to implement zoom via |
@DanielJin21 there's an issue with redundant parameters and API complexity. I proposed three answers. Which would you prefer? |
I would personally prefer option 3 (improve documentation) the most. Even better, if they can be accompanied by an explanation of zoom being a possible use case for |
I prefer this PR's solution: the values in |
Alternative to #11022. (Also remove "in world units", it is probably a mistake.)
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.
I've seen users run into confusion around scale
vs ScalingMode
before, and it makes sense to me to direct them towards the better representation, even if it comes with a bit more complexity.
PR has merge conflicts. |
I've adopted this PR over at #15075. |
# Objective Hello! I am adopting #11022 to resolve conflicts with `main`. tldr: this removes `scale` in favour of `scaling_mode`. Please see the original PR for explanation/discussion. Also relates to #2580. ## Migration Guide Replace all uses of `scale` with `scaling_mode`, keeping in mind that `scale` is (was) a multiplier. For example, replace ```rust scale: 2.0, scaling_mode: ScalingMode::FixedHorizontal(4.0), ``` with ```rust scaling_mode: ScalingMode::FixedHorizontal(8.0), ``` --------- Co-authored-by: Stepan Koltsov <stepan.koltsov@gmail.com>
# Objective Fixes #15791. As raised in #11022, scaling orthographic cameras is confusing! In Bevy 0.14, there were multiple completely redundant ways to do this, and no clear guidance on which to use. As a result, #15075 removed the `scale` field from `OrthographicProjection` completely, solving the redundancy issue. However, this resulted in an unintuitive API and a painful migration, as discussed in #15791. Users simply want to change a single parameter to zoom, rather than deal with the irrelevant details of how the camera is being scaled. ## Solution This PR reverts #15075, and takes an alternate, more nuanced approach to the redundancy problem. `ScalingMode::WindowSize` was by far the biggest offender. This was the default variant, and stored a float that was *fully* redundant to setting `scale`. All of the other variants contained meaningful semantic information and had an intuitive scale. I could have made these unitless, storing an aspect ratio, but this would have been a worse API and resulted in a pointlessly painful migration. In the course of this work I've also: - improved the documentation to explain that you should just set `scale` to zoom cameras - swapped to named fields for all of the variants in `ScalingMode` for more clarity about the parameter meanings - substantially improved the `projection_zoom` example - removed the footgunny `Mul` and `Div` impls for `ScalingMode`, especially since these no longer have the intended effect on `ScalingMode::WindowSize`. - removed a rounding step because this is now redundant 🎉 ## Testing I've tested these changes as part of my work in the `projection_zoom` example, and things seem to work fine. ## Migration Guide `ScalingMode` has been refactored for clarity, especially on how to zoom orthographic cameras and their projections: - `ScalingMode::WindowSize` no longer stores a float, and acts as if its value was 1. Divide your camera's scale by any previous value to achieve identical results. - `ScalingMode::FixedVertical` and `FixedHorizontal` now use named fields. --------- Co-authored-by: MiniaczQ <xnetroidpl@gmail.com>
While trying to set up orthographic projection, I spent some time figuring out what these parameters do. Examples like this:
bevy/examples/3d/orthographic.rs
Lines 20 to 24 in 05b0026
do not help much.
Apparently
OrthographicProjection.scale
andScalingMode.xxx
are redundant: one is multiplied by the other. So having to learn about them is overhead.Not sure why
.scale
exists. Is it useful?I have three alternatives:
.scale
field (implemented by this PR)ScalingMode
, e.g. remove parameter fromScalingMode::FixedVertical
, but keepScalingMode::Fixed
bevy/crates/bevy_render/src/camera/projection.rs
Lines 210 to 215 in 05b0026
.scale
parameter is redundant (Explain OrthographicProjection.scale #11023)Three modified examples look the same after this PR.