bevy/crates/bevy_render/src
xgbwei 09cb590c57 Improve OrthographicCamera consistency and usability (#6201)
# 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 #5818 
- Fixes #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)`
2023-02-08 21:34:33 +00:00
..
camera Improve OrthographicCamera consistency and usability (#6201) 2023-02-08 21:34:33 +00:00
color Add LCH(ab) color space to bevy_render::color::Color (#7483) 2023-02-06 17:51:40 +00:00
mesh Update Box vertices comment (#7055) 2022-12-29 23:45:07 +00:00
primitives Derive Copy for Aabb (#7401) 2023-01-30 18:27:58 +00:00
render_graph fix clippy (#7302) 2023-01-20 14:25:25 +00:00
render_phase Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
render_resource Added buffer usage field to buffers (#7423) 2023-02-06 21:41:14 +00:00
renderer Wgpu 0.15 (#7356) 2023-01-29 20:27:30 +00:00
texture Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
view use better set inheritance in render systems (#7524) 2023-02-06 21:57:59 +00:00
extract_component.rs Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
extract_param.rs Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
extract_resource.rs Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
globals.rs Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
lib.rs Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
pipelined_rendering.rs Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
render_asset.rs use better set inheritance in render systems (#7524) 2023-02-06 21:57:59 +00:00
settings.rs add OpenGL and DX11 backends (#7481) 2023-02-04 23:20:20 +00:00
spatial_bundle.rs enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00