Update defaults for OrthographicProjection (#9537)

# Objective

These new defaults match what is used by `Camera2dBundle::default()`,
removing a potential footgun from overriding a field in the projection
component of the bundle.

## Solution

Adjusted the near clipping plane of `OrthographicProjection::default()`
to `-1000.`.

---

## Changelog

Changed: `OrthographicProjection::default()` now matches the value used
in `Camera2dBundle::default()`

## Migration Guide

Workarounds used to keep the projection consistent with the bundle
defaults are no longer required. Meanwhile, uses of
`OrthographicProjection` in 2D scenes may need to be adjusted; the
`near` clipping plane default was changed from `0.0` to `-1000.0`.
This commit is contained in:
Ray Redondo 2023-08-28 12:31:56 -05:00 committed by GitHub
parent aa20565f75
commit 5012a0fd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -197,6 +197,8 @@ pub enum ScalingMode {
/// ///
/// Note that the scale of the projection and the apparent size of objects are inversely proportional. /// Note that the scale of the projection and the apparent size of objects are inversely proportional.
/// As the size of the projection increases, the size of objects decreases. /// As the size of the projection increases, the size of objects decreases.
///
/// Note also that the view frustum is centered at the origin.
#[derive(Component, Debug, Clone, Reflect)] #[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)] #[reflect(Component, Default)]
pub struct OrthographicProjection { pub struct OrthographicProjection {
@ -204,7 +206,7 @@ pub struct OrthographicProjection {
/// ///
/// Objects closer than this will not be rendered. /// Objects closer than this will not be rendered.
/// ///
/// Defaults to `0.0` /// Defaults to `-1000.0`
pub near: f32, pub near: f32,
/// The distance of the far clipping plane in world units. /// The distance of the far clipping plane in world units.
/// ///
@ -315,7 +317,7 @@ impl Default for OrthographicProjection {
fn default() -> Self { fn default() -> Self {
OrthographicProjection { OrthographicProjection {
scale: 1.0, scale: 1.0,
near: 0.0, near: -1000.0,
far: 1000.0, far: 1000.0,
viewport_origin: Vec2::new(0.5, 0.5), viewport_origin: Vec2::new(0.5, 0.5),
scaling_mode: ScalingMode::WindowSize(1.0), scaling_mode: ScalingMode::WindowSize(1.0),