-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
OrthographicProjection
's public fields are misleading
#6190
Comments
Just looking for some input here. I can merge this into #6177 (or create a new PR? whatever the conventions is) if it's deemed an issue. |
I'm on board with all of these changes. I think a second PR is better; smaller PRs are much easier to review and merge. Your call on which solution you prefer; both seem reasonable to me. The latter is a bit nicer, but less consistent with other camera types. |
@xgbwei Thanks so much for looking into this ❤️ Working with About this solution:
If you make it scale the entire projection regardless of |
The |
Oh, I see! That's important to document then. The view frustrum really provides an "image" which is then stretched into the window. |
# Objective - Terminology used in field names and docs aren't accurate - `window_origin` doesn't have any effect when `scaling_mode` is `ScalingMode::None` - `left`, `right`, `bottom`, and `top` are set automatically unless `scaling_mode` is `None`. Fields that only sometimes give feedback are confusing. - `ScalingMode::WindowSize` has no arguments, which is inconsistent with other `ScalingMode`s. 1 pixel = 1 world unit is also typically way too wide. - `OrthographicProjection` feels generally less streamlined than its `PerspectiveProjection` counterpart - Fixes bevyengine#5818 - Fixes bevyengine#6190 ## Solution - Improve consistency in `OrthographicProjection`'s public fields (they should either always give feedback or never give feedback). - Improve consistency in `ScalingMode`'s arguments - General usability improvements - Improve accuracy of terminology: - "Window" should refer to the physical window on the desktop - "Viewport" should refer to the component in the window that images are drawn on (typically all of it) - "View frustum" should refer to the volume captured by the projection --- ## Changelog ### Added - Added argument to `ScalingMode::WindowSize` that specifies the number of pixels that equals one world unit. - Added documentation for fields and enums ### Changed - Renamed `window_origin` to `viewport_origin`, which now: - Affects all `ScalingMode`s - Takes a fraction of the viewport's width and height instead of an enum - Removed `WindowOrigin` enum as it's obsolete - Renamed `ScalingMode::None` to `ScalingMode::Fixed`, which now: - Takes arguments to specify the projection size - Replaced `left`, `right`, `bottom`, and `top` fields with a single `area: Rect` - `scale` is now applied before updating `area`. Reading from it will take `scale` into account. - Documentation changes to make terminology more accurate and consistent ## Migration Guide - Change `window_origin` to `viewport_origin`; replace `WindowOrigin::Center` with `Vec2::new(0.5, 0.5)` and `WindowOrigin::BottomLeft` with `Vec2::new(0.0, 0.0)` - For shadow projections and such, replace `left`, `right`, `bottom`, and `top` with `area: Rect::new(left, bottom, right, top)` - For camera projections, remove l/r/b/t values from `OrthographicProjection` instantiations, as they no longer have any effect in any `ScalingMode` - Change `ScalingMode::None` to `ScalingMode::Fixed` - Replace manual changes of l/r/b/t with: - Arguments in `ScalingMode::Fixed` to specify size - `viewport_origin` to specify offset - Change `ScalingMode::WindowSize` to `ScalingMode::WindowSize(1.0)`
# Objective - Terminology used in field names and docs aren't accurate - `window_origin` doesn't have any effect when `scaling_mode` is `ScalingMode::None` - `left`, `right`, `bottom`, and `top` are set automatically unless `scaling_mode` is `None`. Fields that only sometimes give feedback are confusing. - `ScalingMode::WindowSize` has no arguments, which is inconsistent with other `ScalingMode`s. 1 pixel = 1 world unit is also typically way too wide. - `OrthographicProjection` feels generally less streamlined than its `PerspectiveProjection` counterpart - Fixes bevyengine#5818 - Fixes bevyengine#6190 ## Solution - Improve consistency in `OrthographicProjection`'s public fields (they should either always give feedback or never give feedback). - Improve consistency in `ScalingMode`'s arguments - General usability improvements - Improve accuracy of terminology: - "Window" should refer to the physical window on the desktop - "Viewport" should refer to the component in the window that images are drawn on (typically all of it) - "View frustum" should refer to the volume captured by the projection --- ## Changelog ### Added - Added argument to `ScalingMode::WindowSize` that specifies the number of pixels that equals one world unit. - Added documentation for fields and enums ### Changed - Renamed `window_origin` to `viewport_origin`, which now: - Affects all `ScalingMode`s - Takes a fraction of the viewport's width and height instead of an enum - Removed `WindowOrigin` enum as it's obsolete - Renamed `ScalingMode::None` to `ScalingMode::Fixed`, which now: - Takes arguments to specify the projection size - Replaced `left`, `right`, `bottom`, and `top` fields with a single `area: Rect` - `scale` is now applied before updating `area`. Reading from it will take `scale` into account. - Documentation changes to make terminology more accurate and consistent ## Migration Guide - Change `window_origin` to `viewport_origin`; replace `WindowOrigin::Center` with `Vec2::new(0.5, 0.5)` and `WindowOrigin::BottomLeft` with `Vec2::new(0.0, 0.0)` - For shadow projections and such, replace `left`, `right`, `bottom`, and `top` with `area: Rect::new(left, bottom, right, top)` - For camera projections, remove l/r/b/t values from `OrthographicProjection` instantiations, as they no longer have any effect in any `ScalingMode` - Change `ScalingMode::None` to `ScalingMode::Fixed` - Replace manual changes of l/r/b/t with: - Arguments in `ScalingMode::Fixed` to specify size - `viewport_origin` to specify offset - Change `ScalingMode::WindowSize` to `ScalingMode::WindowSize(1.0)`
# Objective - Terminology used in field names and docs aren't accurate - `window_origin` doesn't have any effect when `scaling_mode` is `ScalingMode::None` - `left`, `right`, `bottom`, and `top` are set automatically unless `scaling_mode` is `None`. Fields that only sometimes give feedback are confusing. - `ScalingMode::WindowSize` has no arguments, which is inconsistent with other `ScalingMode`s. 1 pixel = 1 world unit is also typically way too wide. - `OrthographicProjection` feels generally less streamlined than its `PerspectiveProjection` counterpart - Fixes bevyengine#5818 - Fixes bevyengine#6190 ## Solution - Improve consistency in `OrthographicProjection`'s public fields (they should either always give feedback or never give feedback). - Improve consistency in `ScalingMode`'s arguments - General usability improvements - Improve accuracy of terminology: - "Window" should refer to the physical window on the desktop - "Viewport" should refer to the component in the window that images are drawn on (typically all of it) - "View frustum" should refer to the volume captured by the projection --- ## Changelog ### Added - Added argument to `ScalingMode::WindowSize` that specifies the number of pixels that equals one world unit. - Added documentation for fields and enums ### Changed - Renamed `window_origin` to `viewport_origin`, which now: - Affects all `ScalingMode`s - Takes a fraction of the viewport's width and height instead of an enum - Removed `WindowOrigin` enum as it's obsolete - Renamed `ScalingMode::None` to `ScalingMode::Fixed`, which now: - Takes arguments to specify the projection size - Replaced `left`, `right`, `bottom`, and `top` fields with a single `area: Rect` - `scale` is now applied before updating `area`. Reading from it will take `scale` into account. - Documentation changes to make terminology more accurate and consistent ## Migration Guide - Change `window_origin` to `viewport_origin`; replace `WindowOrigin::Center` with `Vec2::new(0.5, 0.5)` and `WindowOrigin::BottomLeft` with `Vec2::new(0.0, 0.0)` - For shadow projections and such, replace `left`, `right`, `bottom`, and `top` with `area: Rect::new(left, bottom, right, top)` - For camera projections, remove l/r/b/t values from `OrthographicProjection` instantiations, as they no longer have any effect in any `ScalingMode` - Change `ScalingMode::None` to `ScalingMode::Fixed` - Replace manual changes of l/r/b/t with: - Arguments in `ScalingMode::Fixed` to specify size - `viewport_origin` to specify offset - Change `ScalingMode::WindowSize` to `ScalingMode::WindowSize(1.0)`
What problem does this solve or what need does it fill?
While working on #6177, I noticed some problems with
OrthographicProjection
's public fields:left
,right
,bottom
, andtop
, which are used to set the borders of the projection, are public, even though they'll be set automatically ifscaling_mode
is anything other thanScalingMode::None
.window_origin
affects the origin of the scaling, which means it doesn't have any effect ifscaling_mode
isScalingMode::None
.What solution would you like?
left
,right
,bottom
, andtop
should be private with public getters. Maybe they can be set throughScalingMode::None
's fields; this might make it a bit difficult to update though.window_origin
should be renamed toscaling_origin
or something similar.What alternative(s) have you considered?
Replace
scale
with separate width and height values, which will scale the entire projection whetherscaling_mode
is enabled or not. Then makewindow_origin
(scaling_origin
) more flexible with a fractional value of the width and height instead of justWindowOrigin::BottomLeft
andWindowOrigin::Center
. This will improve usability overall.The text was updated successfully, but these errors were encountered: