Skip to content

Commit

Permalink
Update defaults for OrthographicProjection (bevyengine#9537)
Browse files Browse the repository at this point in the history
# 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`.
  • Loading branch information
rdrpenguin04 committed Aug 28, 2023
1 parent aa20565 commit 5012a0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/bevy_render/src/camera/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,16 @@ pub enum ScalingMode {
///
/// 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.
///
/// Note also that the view frustum is centered at the origin.
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
pub struct OrthographicProjection {
/// The distance of the near clipping plane in world units.
///
/// Objects closer than this will not be rendered.
///
/// Defaults to `0.0`
/// Defaults to `-1000.0`
pub near: f32,
/// The distance of the far clipping plane in world units.
///
Expand Down Expand Up @@ -315,7 +317,7 @@ impl Default for OrthographicProjection {
fn default() -> Self {
OrthographicProjection {
scale: 1.0,
near: 0.0,
near: -1000.0,
far: 1000.0,
viewport_origin: Vec2::new(0.5, 0.5),
scaling_mode: ScalingMode::WindowSize(1.0),
Expand Down

0 comments on commit 5012a0f

Please sign in to comment.