Skip to content

Commit 59d98de

Browse files
authored
naming coherence for cameras (#995)
naming coherence for cameras
1 parent 7699f8b commit 59d98de

File tree

15 files changed

+40
-38
lines changed

15 files changed

+40
-38
lines changed

crates/bevy_gltf/src/loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fn load_node(
239239
};
240240

241241
node.with(Camera {
242-
name: Some(base::camera::CAMERA2D.to_owned()),
242+
name: Some(base::camera::CAMERA_2D.to_owned()),
243243
projection_matrix: orthographic_projection.get_projection_matrix(),
244244
..Default::default()
245245
});
@@ -258,7 +258,7 @@ fn load_node(
258258
perspective_projection.aspect_ratio = aspect_ratio;
259259
}
260260
node.with(Camera {
261-
name: Some(base::camera::CAMERA3D.to_owned()),
261+
name: Some(base::camera::CAMERA_3D.to_owned()),
262262
projection_matrix: perspective_projection.get_projection_matrix(),
263263
..Default::default()
264264
});

crates/bevy_render/src/entity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Default for Camera3dBundle {
3535
fn default() -> Self {
3636
Camera3dBundle {
3737
camera: Camera {
38-
name: Some(base::camera::CAMERA3D.to_string()),
38+
name: Some(base::camera::CAMERA_3D.to_string()),
3939
..Default::default()
4040
},
4141
perspective_projection: Default::default(),
@@ -63,7 +63,7 @@ impl Default for Camera2dBundle {
6363
let far = 1000.0;
6464
Camera2dBundle {
6565
camera: Camera {
66-
name: Some(base::camera::CAMERA2D.to_string()),
66+
name: Some(base::camera::CAMERA_2D.to_string()),
6767
..Default::default()
6868
},
6969
orthographic_projection: OrthographicProjection {

crates/bevy_render/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ impl Plugin for RenderPlugin {
154154
render_graph.add_base_graph(config, &msaa);
155155
let mut active_cameras = resources.get_mut::<ActiveCameras>().unwrap();
156156
if config.add_3d_camera {
157-
active_cameras.add(base::camera::CAMERA3D);
157+
active_cameras.add(base::camera::CAMERA_3D);
158158
}
159159

160160
if config.add_2d_camera {
161-
active_cameras.add(base::camera::CAMERA2D);
161+
active_cameras.add(base::camera::CAMERA_2D);
162162
}
163163
}
164164
}

crates/bevy_render/src/render_graph/base.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ pub struct BaseRenderGraphConfig {
6363

6464
pub mod node {
6565
pub const PRIMARY_SWAP_CHAIN: &str = "swapchain";
66-
pub const CAMERA3D: &str = "camera3d";
67-
pub const CAMERA2D: &str = "camera2d";
66+
pub const CAMERA_3D: &str = "camera_3d";
67+
pub const CAMERA_2D: &str = "camera_2d";
6868
pub const TEXTURE_COPY: &str = "texture_copy";
6969
pub const MAIN_DEPTH_TEXTURE: &str = "main_pass_depth_texture";
7070
pub const MAIN_SAMPLED_COLOR_ATTACHMENT: &str = "main_pass_sampled_color_attachment";
@@ -73,8 +73,8 @@ pub mod node {
7373
}
7474

7575
pub mod camera {
76-
pub const CAMERA3D: &str = "Camera3d";
77-
pub const CAMERA2D: &str = "Camera2d";
76+
pub const CAMERA_3D: &str = "Camera3d";
77+
pub const CAMERA_2D: &str = "Camera2d";
7878
}
7979

8080
impl Default for BaseRenderGraphConfig {
@@ -100,11 +100,11 @@ impl BaseRenderGraphBuilder for RenderGraph {
100100
fn add_base_graph(&mut self, config: &BaseRenderGraphConfig, msaa: &Msaa) -> &mut Self {
101101
self.add_node(node::TEXTURE_COPY, TextureCopyNode::default());
102102
if config.add_3d_camera {
103-
self.add_system_node(node::CAMERA3D, CameraNode::new(camera::CAMERA3D));
103+
self.add_system_node(node::CAMERA_3D, CameraNode::new(camera::CAMERA_3D));
104104
}
105105

106106
if config.add_2d_camera {
107-
self.add_system_node(node::CAMERA2D, CameraNode::new(camera::CAMERA2D));
107+
self.add_system_node(node::CAMERA_2D, CameraNode::new(camera::CAMERA_2D));
108108
}
109109

110110
self.add_node(node::SHARED_BUFFERS, SharedBuffersNode::default());
@@ -153,11 +153,11 @@ impl BaseRenderGraphBuilder for RenderGraph {
153153
main_pass_node.use_default_clear_color(0);
154154

155155
if config.add_3d_camera {
156-
main_pass_node.add_camera(camera::CAMERA3D);
156+
main_pass_node.add_camera(camera::CAMERA_3D);
157157
}
158158

159159
if config.add_2d_camera {
160-
main_pass_node.add_camera(camera::CAMERA2D);
160+
main_pass_node.add_camera(camera::CAMERA_2D);
161161
}
162162

163163
self.add_node(node::MAIN_PASS, main_pass_node);
@@ -168,11 +168,13 @@ impl BaseRenderGraphBuilder for RenderGraph {
168168
.unwrap();
169169

170170
if config.add_3d_camera {
171-
self.add_node_edge(node::CAMERA3D, node::MAIN_PASS).unwrap();
171+
self.add_node_edge(node::CAMERA_3D, node::MAIN_PASS)
172+
.unwrap();
172173
}
173174

174175
if config.add_2d_camera {
175-
self.add_node_edge(node::CAMERA2D, node::MAIN_PASS).unwrap();
176+
self.add_node_edge(node::CAMERA_2D, node::MAIN_PASS)
177+
.unwrap();
176178
}
177179
}
178180

crates/bevy_ui/src/entity.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,22 @@ impl Default for ButtonBundle {
144144
}
145145

146146
#[derive(Bundle, Debug)]
147-
pub struct UiCameraBundle {
147+
pub struct CameraUiBundle {
148148
pub camera: Camera,
149149
pub orthographic_projection: OrthographicProjection,
150150
pub visible_entities: VisibleEntities,
151151
pub transform: Transform,
152152
pub global_transform: GlobalTransform,
153153
}
154154

155-
impl Default for UiCameraBundle {
155+
impl Default for CameraUiBundle {
156156
fn default() -> Self {
157157
// we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset
158158
// the camera's translation by far and use a right handed coordinate system
159159
let far = 1000.0;
160-
UiCameraBundle {
160+
CameraUiBundle {
161161
camera: Camera {
162-
name: Some(crate::camera::UI_CAMERA.to_string()),
162+
name: Some(crate::camera::CAMERA_UI.to_string()),
163163
..Default::default()
164164
},
165165
orthographic_projection: OrthographicProjection {

crates/bevy_ui/src/render/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ pub fn build_ui_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor {
7070
}
7171

7272
pub mod node {
73-
pub const UI_CAMERA: &str = "ui_camera";
73+
pub const CAMERA_UI: &str = "camera_ui";
7474
pub const NODE: &str = "node";
7575
pub const UI_PASS: &str = "ui_pass";
7676
}
7777

7878
pub mod camera {
79-
pub const UI_CAMERA: &str = "UiCamera";
79+
pub const CAMERA_UI: &str = "CameraUi";
8080
}
8181

8282
pub trait UiRenderGraphBuilder {
@@ -110,7 +110,7 @@ impl UiRenderGraphBuilder for RenderGraph {
110110
sample_count: msaa.samples,
111111
});
112112

113-
ui_pass_node.add_camera(camera::UI_CAMERA);
113+
ui_pass_node.add_camera(camera::CAMERA_UI);
114114
self.add_node(node::UI_PASS, ui_pass_node);
115115

116116
self.add_slot_edge(
@@ -148,12 +148,12 @@ impl UiRenderGraphBuilder for RenderGraph {
148148
.unwrap();
149149

150150
// setup ui camera
151-
self.add_system_node(node::UI_CAMERA, CameraNode::new(camera::UI_CAMERA));
152-
self.add_node_edge(node::UI_CAMERA, node::UI_PASS).unwrap();
151+
self.add_system_node(node::CAMERA_UI, CameraNode::new(camera::CAMERA_UI));
152+
self.add_node_edge(node::CAMERA_UI, node::UI_PASS).unwrap();
153153
self.add_system_node(node::NODE, RenderResourcesNode::<Node>::new(true));
154154
self.add_node_edge(node::NODE, node::UI_PASS).unwrap();
155155
let mut active_cameras = resources.get_mut::<ActiveCameras>().unwrap();
156-
active_cameras.add(camera::UI_CAMERA);
156+
active_cameras.add(camera::CAMERA_UI);
157157
self
158158
}
159159
}

examples/2d/contributors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn setup(
5656

5757
commands
5858
.spawn(Camera2dBundle::default())
59-
.spawn(UiCameraBundle::default());
59+
.spawn(CameraUiBundle::default());
6060

6161
let mut sel = ContributorSelection {
6262
order: vec![],

examples/game/breakout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn setup(
4545
commands
4646
// cameras
4747
.spawn(Camera2dBundle::default())
48-
.spawn(UiCameraBundle::default())
48+
.spawn(CameraUiBundle::default())
4949
// paddle
5050
.spawn(SpriteBundle {
5151
material: materials.add(Color::rgb(0.5, 0.5, 1.0).into()),

examples/scene/scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn save_scene_system(_world: &mut World, resources: &mut Resources) {
9797

9898
// This is only necessary for the info message in the UI. See examples/ui/text.rs for a standalone text example.
9999
fn infotext_system(commands: &mut Commands, asset_server: Res<AssetServer>) {
100-
commands.spawn(UiCameraBundle::default()).spawn(TextBundle {
100+
commands.spawn(CameraUiBundle::default()).spawn(TextBundle {
101101
style: Style {
102102
align_self: AlignSelf::FlexEnd,
103103
..Default::default()

examples/tools/bevymark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() {
5151
fn setup(commands: &mut Commands, asset_server: Res<AssetServer>) {
5252
commands
5353
.spawn(Camera2dBundle::default())
54-
.spawn(UiCameraBundle::default())
54+
.spawn(CameraUiBundle::default())
5555
.spawn(TextBundle {
5656
text: Text {
5757
font: asset_server.load("fonts/FiraSans-Bold.ttf"),

0 commit comments

Comments
 (0)