Skip to content
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

Change orthographic projection near default to -1000 #12621

Closed
wants to merge 1 commit into from

Conversation

lkolbly
Copy link
Contributor

@lkolbly lkolbly commented Mar 21, 2024

Objective

Fix an issue where Camera2dBundle and OrthographicProjection have different defaults for the projection's near value. This causes confusion when a user starts with:

commands.spawn(Camera2dBundle {
   ..default()
});

and decides they need to modify just one field of the projection:

commands.spawn(Camera2dBundle {
   projection: OrthographicProjection {
      scaling_mode: my_scaling_mode,
      ..default()
   },
   ..default()
});

Since the user never mentioned the near field, it is surprising that the near field changes (from -1000. to 0.).

This issue was the inspiration for #11115.

Fixes #12267

Solution

This behaviour was introduced in #9310, which changed Camera2dBundle::default() to cover the region z=-1000. to z=1000. (so that sprites with negative Z are visible) and place the camera at the origin. This PR changes OrthographicProjection to have the same defaults as Camera2dBundle.

At the time, Camera2dBundle::new_with_far was not touched, since that would be a breaking change for that function, since that function is fairly explicit about the near/far range. This PR keeps near=0 in that function.


Changelog

  • Changed default value for near plane for OrthographicProjection.

@lkolbly
Copy link
Contributor Author

lkolbly commented Mar 21, 2024

The CI failures seem unrelated to this change? It's complaining about:

error: field `0` is never read
   --> crates/bevy_asset/src/server/loaders.rs:311:14
     |
311 |     struct A(usize);
    |            - ^^^^^
    |            |
    |            field in this struct

@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR A-Rendering Drawing game state to the screen labels Mar 21, 2024
@alice-i-cecile
Copy link
Member

Yep, those are unrelated. See #12620.

@alice-i-cecile alice-i-cecile added X-Contentious There are nontrivial implications that should be thought through and removed X-Controversial There is active debate or serious implications around merging this PR labels Aug 16, 2024
@alice-i-cecile
Copy link
Member

Solved by #15073 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Contentious There are nontrivial implications that should be thought through
Projects
Status: Done
2 participants