move some Visibility stuff to bevy_camera::visibility (#19954)
# Objective - Make bevy_light possible ## Solution - Move some stuff it needs out of somewhere it cant depend on. Plus it makes sense, visibility stuff goes in visibility. ## Testing - 3d_scene runs Note: no breaking changes thanks to re-exports
This commit is contained in:
parent
29779e1e18
commit
bfbc6c3d11
@ -3,7 +3,7 @@ mod render_layers;
|
|||||||
|
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
|
|
||||||
use bevy_ecs::entity::EntityHashSet;
|
use bevy_ecs::entity::{EntityHashMap, EntityHashSet};
|
||||||
use bevy_ecs::lifecycle::HookContext;
|
use bevy_ecs::lifecycle::HookContext;
|
||||||
use bevy_ecs::world::DeferredWorld;
|
use bevy_ecs::world::DeferredWorld;
|
||||||
use derive_more::derive::{Deref, DerefMut};
|
use derive_more::derive::{Deref, DerefMut};
|
||||||
@ -267,6 +267,50 @@ impl VisibleEntities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Collection of mesh entities visible for 3D lighting.
|
||||||
|
///
|
||||||
|
/// This component contains all mesh entities visible from the current light view.
|
||||||
|
/// The collection is updated automatically by `bevy_pbr::SimulationLightSystems`.
|
||||||
|
#[derive(Component, Clone, Debug, Default, Reflect, Deref, DerefMut)]
|
||||||
|
#[reflect(Component, Debug, Default, Clone)]
|
||||||
|
pub struct VisibleMeshEntities {
|
||||||
|
#[reflect(ignore, clone)]
|
||||||
|
pub entities: Vec<Entity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||||
|
#[reflect(Component, Debug, Default, Clone)]
|
||||||
|
pub struct CubemapVisibleEntities {
|
||||||
|
#[reflect(ignore, clone)]
|
||||||
|
data: [VisibleMeshEntities; 6],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CubemapVisibleEntities {
|
||||||
|
pub fn get(&self, i: usize) -> &VisibleMeshEntities {
|
||||||
|
&self.data[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_mut(&mut self, i: usize) -> &mut VisibleMeshEntities {
|
||||||
|
&mut self.data[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &VisibleMeshEntities> {
|
||||||
|
self.data.iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut VisibleMeshEntities> {
|
||||||
|
self.data.iter_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||||
|
#[reflect(Component, Default, Clone)]
|
||||||
|
pub struct CascadesVisibleEntities {
|
||||||
|
/// Map of view entity to the visible entities for each cascade frustum.
|
||||||
|
#[reflect(ignore, clone)]
|
||||||
|
pub entities: EntityHashMap<Vec<VisibleMeshEntities>>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||||
pub enum VisibilitySystems {
|
pub enum VisibilitySystems {
|
||||||
/// Label for the [`calculate_bounds`], `calculate_bounds_2d` and `calculate_bounds_text2d` systems,
|
/// Label for the [`calculate_bounds`], `calculate_bounds_2d` and `calculate_bounds_text2d` systems,
|
||||||
@ -303,6 +347,9 @@ impl Plugin for VisibilityPlugin {
|
|||||||
.register_type::<RenderLayers>()
|
.register_type::<RenderLayers>()
|
||||||
.register_type::<Visibility>()
|
.register_type::<Visibility>()
|
||||||
.register_type::<VisibleEntities>()
|
.register_type::<VisibleEntities>()
|
||||||
|
.register_type::<CascadesVisibleEntities>()
|
||||||
|
.register_type::<VisibleMeshEntities>()
|
||||||
|
.register_type::<CubemapVisibleEntities>()
|
||||||
.register_required_components::<Mesh3d, Visibility>()
|
.register_required_components::<Mesh3d, Visibility>()
|
||||||
.register_required_components::<Mesh3d, VisibilityClass>()
|
.register_required_components::<Mesh3d, VisibilityClass>()
|
||||||
.register_required_components::<Mesh2d, Visibility>()
|
.register_required_components::<Mesh2d, Visibility>()
|
||||||
|
@ -44,6 +44,7 @@ bevy_image = { path = "../bevy_image", version = "0.17.0-dev" }
|
|||||||
bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
|
bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
|
||||||
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }
|
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }
|
||||||
bevy_render = { path = "../bevy_render", version = "0.17.0-dev" }
|
bevy_render = { path = "../bevy_render", version = "0.17.0-dev" }
|
||||||
|
bevy_camera = { path = "../bevy_camera", version = "0.17.0-dev" }
|
||||||
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", optional = true }
|
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", optional = true }
|
||||||
bevy_transform = { path = "../bevy_transform", version = "0.17.0-dev" }
|
bevy_transform = { path = "../bevy_transform", version = "0.17.0-dev" }
|
||||||
bevy_utils = { path = "../bevy_utils", version = "0.17.0-dev" }
|
bevy_utils = { path = "../bevy_utils", version = "0.17.0-dev" }
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
|
pub use bevy_camera::visibility::{
|
||||||
|
CascadesVisibleEntities, CubemapVisibleEntities, VisibleMeshEntities,
|
||||||
|
};
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_ecs::component::Component;
|
use bevy_ecs::component::Component;
|
||||||
use bevy_ecs::entity::{Entity, EntityHashMap};
|
use bevy_ecs::entity::{Entity, EntityHashMap};
|
||||||
use bevy_ecs::reflect::ReflectComponent;
|
use bevy_ecs::reflect::ReflectComponent;
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
use bevy_render::sync_world::MainEntity;
|
use bevy_render::sync_world::MainEntity;
|
||||||
/// Collection of mesh entities visible for 3D lighting.
|
|
||||||
///
|
|
||||||
/// This component contains all mesh entities visible from the current light view.
|
|
||||||
/// The collection is updated automatically by [`crate::SimulationLightSystems`].
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect, Deref, DerefMut)]
|
|
||||||
#[reflect(Component, Debug, Default, Clone)]
|
|
||||||
pub struct VisibleMeshEntities {
|
|
||||||
#[reflect(ignore, clone)]
|
|
||||||
pub entities: Vec<Entity>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect, Deref, DerefMut)]
|
#[derive(Component, Clone, Debug, Default, Reflect, Deref, DerefMut)]
|
||||||
#[reflect(Component, Debug, Default, Clone)]
|
#[reflect(Component, Debug, Default, Clone)]
|
||||||
@ -22,31 +15,6 @@ pub struct RenderVisibleMeshEntities {
|
|||||||
pub entities: Vec<(Entity, MainEntity)>,
|
pub entities: Vec<(Entity, MainEntity)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
|
||||||
#[reflect(Component, Debug, Default, Clone)]
|
|
||||||
pub struct CubemapVisibleEntities {
|
|
||||||
#[reflect(ignore, clone)]
|
|
||||||
data: [VisibleMeshEntities; 6],
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CubemapVisibleEntities {
|
|
||||||
pub fn get(&self, i: usize) -> &VisibleMeshEntities {
|
|
||||||
&self.data[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_mut(&mut self, i: usize) -> &mut VisibleMeshEntities {
|
|
||||||
&mut self.data[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &VisibleMeshEntities> {
|
|
||||||
self.data.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut VisibleMeshEntities> {
|
|
||||||
self.data.iter_mut()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||||
#[reflect(Component, Debug, Default, Clone)]
|
#[reflect(Component, Debug, Default, Clone)]
|
||||||
pub struct RenderCubemapVisibleEntities {
|
pub struct RenderCubemapVisibleEntities {
|
||||||
@ -72,14 +40,6 @@ impl RenderCubemapVisibleEntities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
|
||||||
#[reflect(Component, Default, Clone)]
|
|
||||||
pub struct CascadesVisibleEntities {
|
|
||||||
/// Map of view entity to the visible entities for each cascade frustum.
|
|
||||||
#[reflect(ignore, clone)]
|
|
||||||
pub entities: EntityHashMap<Vec<VisibleMeshEntities>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||||
#[reflect(Component, Default, Clone)]
|
#[reflect(Component, Default, Clone)]
|
||||||
pub struct RenderCascadesVisibleEntities {
|
pub struct RenderCascadesVisibleEntities {
|
||||||
|
@ -208,10 +208,7 @@ impl Plugin for PbrPlugin {
|
|||||||
.register_type::<AmbientLight>()
|
.register_type::<AmbientLight>()
|
||||||
.register_type::<CascadeShadowConfig>()
|
.register_type::<CascadeShadowConfig>()
|
||||||
.register_type::<Cascades>()
|
.register_type::<Cascades>()
|
||||||
.register_type::<CascadesVisibleEntities>()
|
|
||||||
.register_type::<VisibleMeshEntities>()
|
|
||||||
.register_type::<ClusterConfig>()
|
.register_type::<ClusterConfig>()
|
||||||
.register_type::<CubemapVisibleEntities>()
|
|
||||||
.register_type::<DirectionalLight>()
|
.register_type::<DirectionalLight>()
|
||||||
.register_type::<DirectionalLightShadowMap>()
|
.register_type::<DirectionalLightShadowMap>()
|
||||||
.register_type::<NotShadowCaster>()
|
.register_type::<NotShadowCaster>()
|
||||||
|
Loading…
Reference in New Issue
Block a user