Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/bevy_gizmos/src/pipeline_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ use bevy_ecs::{
};
use bevy_image::BevyDefault as _;
use bevy_math::FloatOrd;
use bevy_render::sync_world::MainEntity;
use bevy_render::{sync_world::MainEntity, view::InheritedVisibleLayers};
use bevy_render::{
render_asset::{prepare_assets, RenderAssets},
render_phase::{
AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline,
ViewSortedRenderPhases,
},
render_resource::*,
view::{ExtractedView, Msaa, RenderLayers, ViewTarget},
view::{ExtractedView, Msaa, ViewTarget},
Render, RenderApp, RenderSet,
};
use bevy_sprite::{Mesh2dPipeline, Mesh2dPipelineKey, SetMesh2dViewBindGroup};
Expand Down Expand Up @@ -297,7 +297,7 @@ fn queue_line_gizmos_2d(
line_gizmos: Query<(Entity, &MainEntity, &GizmoMeshConfig)>,
line_gizmo_assets: Res<RenderAssets<GpuLineGizmo>>,
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent2d>>,
mut views: Query<(&ExtractedView, &Msaa, Option<&RenderLayers>)>,
mut views: Query<(&ExtractedView, &Msaa, Option<&InheritedVisibleLayers>)>,
) {
let draw_function = draw_functions.read().get_id::<DrawLineGizmo2d>().unwrap();
let draw_function_strip = draw_functions
Expand Down Expand Up @@ -376,7 +376,7 @@ fn queue_line_joint_gizmos_2d(
line_gizmos: Query<(Entity, &MainEntity, &GizmoMeshConfig)>,
line_gizmo_assets: Res<RenderAssets<GpuLineGizmo>>,
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent2d>>,
mut views: Query<(&ExtractedView, &Msaa, Option<&RenderLayers>)>,
mut views: Query<(&ExtractedView, &Msaa, Option<&InheritedVisibleLayers>)>,
) {
let draw_function = draw_functions
.read()
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_gizmos/src/pipeline_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ use bevy_ecs::{
};
use bevy_image::BevyDefault as _;
use bevy_pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup};
use bevy_render::sync_world::MainEntity;
use bevy_render::{sync_world::MainEntity, view::InheritedVisibleLayers};
use bevy_render::{
render_asset::{prepare_assets, RenderAssets},
render_phase::{
AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline,
ViewSortedRenderPhases,
},
render_resource::*,
view::{ExtractedView, Msaa, RenderLayers, ViewTarget},
view::{ExtractedView, Msaa, ViewTarget},
Render, RenderApp, RenderSet,
};
use tracing::error;
Expand Down Expand Up @@ -295,7 +295,7 @@ fn queue_line_gizmos_3d(
views: Query<(
&ExtractedView,
&Msaa,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
(
Has<NormalPrepass>,
Has<DepthPrepass>,
Expand Down Expand Up @@ -410,7 +410,7 @@ fn queue_line_joint_gizmos_3d(
views: Query<(
&ExtractedView,
&Msaa,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
(
Has<NormalPrepass>,
Has<DepthPrepass>,
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_gizmos/src/retained.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use {
entity::Entity,
system::{Commands, Local, Query},
},
bevy_render::{view::RenderLayers, Extract},
bevy_render::{view::InheritedVisibleLayers, Extract},
bevy_transform::components::GlobalTransform,
};

Expand Down Expand Up @@ -102,7 +102,7 @@ pub struct Gizmo {
pub(crate) fn extract_linegizmos(
mut commands: Commands,
mut previous_len: Local<usize>,
query: Extract<Query<(Entity, &Gizmo, &GlobalTransform, Option<&RenderLayers>)>>,
query: Extract<Query<(Entity, &Gizmo, &GlobalTransform, Option<&InheritedVisibleLayers>)>>,
) {
use bevy_math::Affine3;
use bevy_render::sync_world::{MainEntity, TemporaryRenderEntity};
Expand Down Expand Up @@ -151,7 +151,7 @@ pub(crate) fn extract_linegizmos(
line_perspective: gizmo.line_config.perspective,
line_style: gizmo.line_config.style,
line_joints: gizmo.line_config.joints,
render_layers: render_layers.cloned().unwrap_or_default(),
render_layers: render_layers.cloned().unwrap_or_default().0,
handle: gizmo.handle.clone_weak(),
},
MainEntity::from(entity),
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_pbr/src/cluster/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use bevy_render::{
primitives::{Aabb, Frustum, HalfSpace, Sphere},
render_resource::BufferBindingType,
renderer::{RenderAdapter, RenderDevice},
view::{RenderLayers, ViewVisibility},
view::{InheritedVisibleLayers, RenderLayers, ViewVisibility},
};
use bevy_transform::components::GlobalTransform;
use bevy_utils::prelude::default;
Expand Down Expand Up @@ -153,22 +153,22 @@ pub(crate) fn assign_objects_to_clusters(
&Frustum,
&ClusterConfig,
&mut Clusters,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&mut VisibleClusterableObjects>,
)>,
point_lights_query: Query<(
Entity,
&GlobalTransform,
&PointLight,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&VolumetricLight>,
&ViewVisibility,
)>,
spot_lights_query: Query<(
Entity,
&GlobalTransform,
&SpotLight,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&VolumetricLight>,
&ViewVisibility,
)>,
Expand Down Expand Up @@ -203,7 +203,7 @@ pub(crate) fn assign_objects_to_clusters(
shadows_enabled: point_light.shadows_enabled,
volumetric: volumetric.is_some(),
},
render_layers: maybe_layers.unwrap_or_default().clone(),
render_layers: maybe_layers.unwrap_or_default().0.clone(),
}
},
),
Expand All @@ -223,7 +223,7 @@ pub(crate) fn assign_objects_to_clusters(
shadows_enabled: spot_light.shadows_enabled,
volumetric: volumetric.is_some(),
},
render_layers: maybe_layers.unwrap_or_default().clone(),
render_layers: maybe_layers.unwrap_or_default().0.clone(),
}
},
),
Expand Down
13 changes: 6 additions & 7 deletions crates/bevy_pbr/src/light/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use bevy_render::{
mesh::Mesh3d,
primitives::{Aabb, CascadesFrusta, CubemapFrusta, Frustum, Sphere},
view::{
InheritedVisibility, NoFrustumCulling, PreviousVisibleEntities, RenderLayers,
ViewVisibility, VisibilityClass, VisibilityRange, VisibleEntityRanges,
InheritedVisibleLayers, InheritedVisibility, NoFrustumCulling, PreviousVisibleEntities, ViewVisibility, VisibilityClass, VisibilityRange, VisibleEntityRanges
},
};
use bevy_transform::components::{GlobalTransform, Transform};
Expand Down Expand Up @@ -667,7 +666,7 @@ pub fn check_dir_light_mesh_visibility(
&DirectionalLight,
&CascadesFrusta,
&mut CascadesVisibleEntities,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
&ViewVisibility,
),
Without<SpotLight>,
Expand All @@ -676,7 +675,7 @@ pub fn check_dir_light_mesh_visibility(
(
Entity,
&InheritedVisibility,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&Aabb>,
Option<&GlobalTransform>,
Has<VisibilityRange>,
Expand Down Expand Up @@ -841,21 +840,21 @@ pub fn check_point_light_mesh_visibility(
&GlobalTransform,
&CubemapFrusta,
&mut CubemapVisibleEntities,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
)>,
mut spot_lights: Query<(
&SpotLight,
&GlobalTransform,
&Frustum,
&mut VisibleMeshEntities,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
)>,
mut visible_entity_query: Query<
(
Entity,
&InheritedVisibility,
&mut ViewVisibility,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&Aabb>,
Option<&GlobalTransform>,
Has<VisibilityRange>,
Expand Down
7 changes: 4 additions & 3 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use bevy_render::experimental::occlusion_culling::{
OcclusionCulling, OcclusionCullingSubview, OcclusionCullingSubviewEntities,
};
use bevy_render::sync_world::MainEntityHashMap;
use bevy_render::view::InheritedVisibleLayers;
use bevy_render::{
batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport},
camera::SortedCameras,
Expand Down Expand Up @@ -257,7 +258,7 @@ pub fn extract_lights(
&CascadesFrusta,
&GlobalTransform,
&ViewVisibility,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&VolumetricLight>,
Has<OcclusionCulling>,
),
Expand Down Expand Up @@ -489,7 +490,7 @@ pub fn extract_lights(
cascade_shadow_config: cascade_config.clone(),
cascades: extracted_cascades,
frusta: extracted_frusta,
render_layers: maybe_layers.unwrap_or_default().clone(),
render_layers: maybe_layers.unwrap_or_default().0.clone(),
occlusion_culling,
},
RenderCascadesVisibleEntities {
Expand Down Expand Up @@ -727,7 +728,7 @@ pub fn prepare_lights(
MainEntity,
&ExtractedView,
&ExtractedClusterConfig,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Has<NoIndirectDrawing>,
Option<&AmbientLight>,
),
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_picking/src/mesh_picking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;
use bevy_reflect::prelude::*;
use bevy_render::{prelude::*, view::RenderLayers};
use bevy_render::{prelude::*, view::InheritedVisibleLayers};
use ray_cast::{MeshRayCast, MeshRayCastSettings, RayCastVisibility, SimplifiedMesh};

/// Runtime settings for the [`MeshPickingPlugin`].
Expand Down Expand Up @@ -76,10 +76,10 @@ impl Plugin for MeshPickingPlugin {
pub fn update_hits(
backend_settings: Res<MeshPickingSettings>,
ray_map: Res<RayMap>,
picking_cameras: Query<(&Camera, Option<&RayCastPickable>, Option<&RenderLayers>)>,
picking_cameras: Query<(&Camera, Option<&RayCastPickable>, Option<&InheritedVisibleLayers>)>,
pickables: Query<&Pickable>,
marked_targets: Query<&RayCastPickable>,
layers: Query<&RenderLayers>,
layers: Query<&InheritedVisibleLayers>,
mut ray_cast: MeshRayCast,
mut output: EventWriter<PointerHits>,
) {
Expand All @@ -100,7 +100,7 @@ pub fn update_hits(
!backend_settings.require_markers || marked_targets.get(entity).is_ok();

// Other entities missing render layers are on the default layer 0
let entity_layers = layers.get(entity).cloned().unwrap_or_default();
let entity_layers = layers.get(entity).cloned().unwrap_or_default().0;
let render_layers_match = cam_layers.intersects(&entity_layers);

let is_pickable = pickables.get(entity).ok().is_none_or(|p| p.is_hoverable);
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use crate::{
sync_world::{RenderEntity, SyncToRenderWorld},
texture::GpuImage,
view::{
ColorGrading, ExtractedView, ExtractedWindows, Msaa, NoIndirectDrawing, RenderLayers,
RenderVisibleEntities, RetainedViewEntity, ViewUniformOffset, Visibility, VisibleEntities,
ColorGrading, InheritedVisibleLayers, ExtractedView, ExtractedWindows, Msaa, NoIndirectDrawing, RenderVisibleEntities, RetainedViewEntity, ViewUniformOffset, Visibility, VisibleEntities, VisibleLayers
},
Extract,
};
Expand Down Expand Up @@ -1056,7 +1055,7 @@ pub fn extract_cameras(
Option<&ColorGrading>,
Option<&Exposure>,
Option<&TemporalJitter>,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&Projection>,
Has<NoIndirectDrawing>,
)>,
Expand Down Expand Up @@ -1088,7 +1087,8 @@ pub fn extract_cameras(
ExtractedView,
RenderVisibleEntities,
TemporalJitter,
RenderLayers,
VisibleLayers,
InheritedVisibleLayers,
Projection,
NoIndirectDrawing,
ViewUniformOffset,
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_render/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ impl Plugin for ViewPlugin {
.register_type::<Msaa>()
.register_type::<NoFrustumCulling>()
.register_type::<RenderLayers>()
.register_type::<VisibleLayers>()
.register_type::<InheritedVisibleLayers>()
.register_type::<Visibility>()
.register_type::<VisibleEntities>()
.register_type::<ColorGrading>()
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_render/src/view/visibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::{
/// `Visibility` to set the values of each entity's [`InheritedVisibility`] component.
#[derive(Component, Clone, Copy, Reflect, Debug, PartialEq, Eq, Default)]
#[reflect(Component, Default, Debug, PartialEq)]
#[require(InheritedVisibility, ViewVisibility)]
#[require(InheritedVisibility, ViewVisibility, VisibleLayers)]
pub enum Visibility {
/// An entity with `Visibility::Inherited` will inherit the Visibility of its [`ChildOf`] target.
///
Expand Down Expand Up @@ -315,7 +315,7 @@ pub enum VisibilitySystems {
CalculateBounds,
/// Label for [`update_frusta`] in [`CameraProjectionPlugin`](crate::camera::CameraProjectionPlugin).
UpdateFrusta,
/// Label for the system propagating the [`InheritedVisibility`] in a
/// Label for the systems propagating [`InheritedVisibility`] and [`InheritedVisibleLayers`] in the
/// [`ChildOf`] / [`Children`] hierarchy.
VisibilityPropagate,
/// Label for the [`check_visibility`] system updating [`ViewVisibility`]
Expand Down Expand Up @@ -353,7 +353,7 @@ impl Plugin for VisibilityPlugin {
PostUpdate,
(
calculate_bounds.in_set(CalculateBounds),
(visibility_propagate_system, reset_view_visibility)
(visibility_propagate_system, visible_layers_propagate_system, reset_view_visibility)
.in_set(VisibilityPropagate),
check_visibility.in_set(CheckVisibility),
mark_newly_hidden_entities_invisible.in_set(MarkNewlyHiddenEntitiesInvisible),
Expand Down Expand Up @@ -503,7 +503,7 @@ pub fn check_visibility(
Entity,
&mut VisibleEntities,
&Frustum,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
&Camera,
Has<NoCpuCulling>,
)>,
Expand All @@ -512,7 +512,7 @@ pub fn check_visibility(
&InheritedVisibility,
&mut ViewVisibility,
&VisibilityClass,
Option<&RenderLayers>,
Option<&InheritedVisibleLayers>,
Option<&Aabb>,
&GlobalTransform,
Has<NoFrustumCulling>,
Expand Down
Loading
Loading