Skip to content

Commit

Permalink
Physical camera render layers
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Jul 25, 2024
1 parent 4ee7629 commit f9896c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
9 changes: 5 additions & 4 deletions rmf_site_editor/src/interaction/camera_controls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ pub const MODEL_PREVIEW_LAYER: u8 = 6;

// Creates all the layers visible in the main camera view (excluding, for example
// the model preview which is on a separate view). The main lights will affect these.
fn main_view_render_layers() -> RenderLayers {
pub fn main_view_render_layers() -> RenderLayers {
RenderLayers::from_layers(&[
GENERAL_RENDER_LAYER,
PHYSICAL_RENDER_LAYER,
VISUAL_CUE_RENDER_LAYER,
SELECTED_OUTLINE_LAYER,
HOVERED_OUTLINE_LAYER,
XRAY_RENDER_LAYER
XRAY_RENDER_LAYER,
])
}

Expand Down Expand Up @@ -407,8 +407,9 @@ impl FromWorld for CameraControls {
.push_children(&orthographic_child_cameras)
.id();

let mut ambient_light = world.get_resource_mut::<AmbientLight>().expect(
"Make sure bevy's PbrPlugin is initialized before the cameras");
let mut ambient_light = world
.get_resource_mut::<AmbientLight>()
.expect("Make sure bevy's PbrPlugin is initialized before the cameras");

ambient_light.brightness = 2.0;

Expand Down
9 changes: 7 additions & 2 deletions rmf_site_editor/src/interaction/model_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use bevy::{
core_pipeline::tonemapping::Tonemapping,
ecs::system::SystemState,
prelude::*,
render::{camera::{Exposure, RenderTarget}, view::RenderLayers},
render::{
camera::{Exposure, RenderTarget},
view::RenderLayers,
},
};
use bevy_egui::{egui::TextureId, EguiContexts};

Expand Down Expand Up @@ -75,7 +78,9 @@ impl FromWorld for ModelPreviewCamera {
..default()
},
tonemapping: Tonemapping::ReinhardLuminance,
exposure: Exposure { ev100: DEFAULT_CAMERA_EV100 },
exposure: Exposure {
ev100: DEFAULT_CAMERA_EV100,
},
..default()
})
.insert(RenderLayers::from_layers(&[MODEL_PREVIEW_LAYER]))
Expand Down
4 changes: 3 additions & 1 deletion rmf_site_editor/src/interaction/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ fn create_camera_window(
is_active: true,
..default()
})
.insert(Exposure {ev100: DEFAULT_CAMERA_EV100 })
.insert(Exposure {
ev100: DEFAULT_CAMERA_EV100,
})
.insert(RenderLayers::layer(0));
window_id
}
Expand Down
6 changes: 3 additions & 3 deletions rmf_site_editor/src/site/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

use crate::site::CurrentLevel;
use crate::{interaction::main_view_render_layers, site::CurrentLevel};
use bevy::{
pbr::CubemapVisibleEntities,
prelude::{
Expand All @@ -24,7 +24,7 @@ use bevy::{
},
render::{
primitives::{CubemapFrusta, Frustum},
view::{RenderLayers, VisibleEntities},
view::VisibleEntities,
},
};
use rmf_site_format::{Category, Light, LightKind, NameInSite, Pose};
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn add_physical_lights(
.insert(VisibleEntities::default())
.insert(CubemapFrusta::default())
.insert(CubemapVisibleEntities::default())
.insert(RenderLayers::all())
.insert(main_view_render_layers())
.insert(Category::Light);

if parent.is_none() {
Expand Down

0 comments on commit f9896c7

Please sign in to comment.