Skip to content

Commit 37914aa

Browse files
committed
Rename camera "priority" to "order" (#6908)
# Objective The documentation for camera priority is very confusing at the moment, it requires a bit of "double negative" kind of thinking. # Solution Flipping the wording on the documentation to reflect more common usecases like having an overlay camera and also renaming it to "order", since priority implies that it will override the other camera rather than have both run.
1 parent e4292ff commit 37914aa

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

crates/bevy_render/src/camera/camera.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ pub struct ComputedCameraValues {
8686
pub struct Camera {
8787
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
8888
pub viewport: Option<Viewport>,
89-
/// Cameras with a lower priority will be rendered before cameras with a higher priority.
90-
pub priority: isize,
89+
/// Cameras with a higher order are rendered later, and thus on top of lower order cameras.
90+
pub order: isize,
9191
/// If this is set to `true`, this camera will be rendered to its specified [`RenderTarget`]. If `false`, this
9292
/// camera will not be rendered.
9393
pub is_active: bool,
@@ -109,7 +109,7 @@ impl Default for Camera {
109109
fn default() -> Self {
110110
Self {
111111
is_active: true,
112-
priority: 0,
112+
order: 0,
113113
viewport: None,
114114
computed: Default::default(),
115115
target: Default::default(),
@@ -477,7 +477,7 @@ pub struct ExtractedCamera {
477477
pub physical_target_size: Option<UVec2>,
478478
pub viewport: Option<Viewport>,
479479
pub render_graph: Cow<'static, str>,
480-
pub priority: isize,
480+
pub order: isize,
481481
}
482482

483483
pub fn extract_cameras(
@@ -511,7 +511,7 @@ pub fn extract_cameras(
511511
physical_viewport_size: Some(viewport_size),
512512
physical_target_size: Some(target_size),
513513
render_graph: camera_render_graph.0.clone(),
514-
priority: camera.priority,
514+
order: camera.order,
515515
},
516516
ExtractedView {
517517
projection: camera.projection_matrix(),

crates/bevy_render/src/camera/camera_driver_node.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@ impl Node for CameraDriverNode {
3333
let mut sorted_cameras = self
3434
.cameras
3535
.iter_manual(world)
36-
.map(|(e, c)| (e, c.priority, c.target.clone()))
36+
.map(|(e, c)| (e, c.order, c.target.clone()))
3737
.collect::<Vec<_>>();
38-
// sort by priority and ensure within a priority, RenderTargets of the same type are packed together
38+
// sort by order and ensure within an order, RenderTargets of the same type are packed together
3939
sorted_cameras.sort_by(|(_, p1, t1), (_, p2, t2)| match p1.cmp(p2) {
4040
std::cmp::Ordering::Equal => t1.cmp(t2),
4141
ord => ord,
4242
});
4343
let mut camera_windows = HashSet::new();
44-
let mut previous_priority_target = None;
44+
let mut previous_order_target = None;
4545
let mut ambiguities = HashSet::new();
46-
for (entity, priority, target) in sorted_cameras {
47-
let new_priority_target = (priority, target);
48-
if let Some(previous_priority_target) = previous_priority_target {
49-
if previous_priority_target == new_priority_target {
50-
ambiguities.insert(new_priority_target.clone());
46+
for (entity, order, target) in sorted_cameras {
47+
let new_order_target = (order, target);
48+
if let Some(previous_order_target) = previous_order_target {
49+
if previous_order_target == new_order_target {
50+
ambiguities.insert(new_order_target.clone());
5151
}
5252
}
53-
previous_priority_target = Some(new_priority_target);
53+
previous_order_target = Some(new_order_target);
5454
if let Ok((_, camera)) = self.cameras.get_manual(world, entity) {
5555
if let RenderTarget::Window(id) = camera.target {
5656
camera_windows.insert(id);
@@ -62,8 +62,8 @@ impl Node for CameraDriverNode {
6262

6363
if !ambiguities.is_empty() {
6464
warn!(
65-
"Camera priority ambiguities detected for active cameras with the following priorities: {:?}. \
66-
To fix this, ensure there is exactly one Camera entity spawned with a given priority for a given RenderTarget. \
65+
"Camera order ambiguities detected for active cameras with the following priorities: {:?}. \
66+
To fix this, ensure there is exactly one Camera entity spawned with a given order for a given RenderTarget. \
6767
Ambiguities should be resolved because either (1) multiple active cameras were spawned accidentally, which will \
6868
result in rendering multiple instances of the scene or (2) for cases where multiple active cameras is intentional, \
6969
ambiguities could result in unpredictable render results.",

examples/3d/render_to_texture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn setup(
102102
},
103103
camera: Camera {
104104
// render before the "main pass" camera
105-
priority: -1,
105+
order: -1,
106106
target: RenderTarget::Image(image_handle.clone()),
107107
..default()
108108
},

examples/3d/split_screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn setup(
6161
transform: Transform::from_xyz(100.0, 100., 150.0).looking_at(Vec3::ZERO, Vec3::Y),
6262
camera: Camera {
6363
// Renders the right camera after the left camera, which has a default priority of 0
64-
priority: 1,
64+
order: 1,
6565
..default()
6666
},
6767
camera_3d: Camera3d {

examples/3d/two_passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn setup(
5353
},
5454
camera: Camera {
5555
// renders after / on top of the main camera
56-
priority: 1,
56+
order: 1,
5757
..default()
5858
},
5959
..default()

examples/shader/post_processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn setup(
146146
Camera2dBundle {
147147
camera: Camera {
148148
// renders after the first main camera which has default value: 0.
149-
priority: 1,
149+
order: 1,
150150
..default()
151151
},
152152
..Camera2dBundle::default()

tests/window/minimising.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn setup_2d(mut commands: Commands) {
6868
commands.spawn(Camera2dBundle {
6969
camera: Camera {
7070
// render the 2d camera after the 3d camera
71-
priority: 1,
71+
order: 1,
7272
..default()
7373
},
7474
camera_2d: Camera2d {

tests/window/resizing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn setup_2d(mut commands: Commands) {
148148
commands.spawn(Camera2dBundle {
149149
camera: Camera {
150150
// render the 2d camera after the 3d camera
151-
priority: 1,
151+
order: 1,
152152
..default()
153153
},
154154
camera_2d: Camera2d {

0 commit comments

Comments
 (0)