Skip to main content

bevy_camera/visibility/
mod.rs

1//! Components that control the visibility of entities.
2//!
3//! ## What is the difference between visibility components
4//!
5//! There are three components that indicate various kinds
6//! of visibility modes of an entity:
7//! - [`Visibility`]
8//! - [`InheritedVisibility`]
9//! - [`ViewVisibility`]
10//!
11//! [`Visibility`] is the user-defined visibility.
12//! It is the only component that users should typically add to an entity[^1],
13//! the other two are then added automatically.
14//!
15//! [`InheritedVisibility`] is computed by propagation through the entity hierarchy.
16//! Entities with [`Visibility::Inherited`] copy the visibility
17//! of their parent entities. If they have no [`ChildOf`] component, they are visible.
18//! The propagation is done in `visibility_propagate_system`, which runs
19//! in the [`PostUpdate`] schedule.
20//!
21//! [`ViewVisibility`] indicates whether the entity should be
22//! extracted for rendering. This component is recomputed in every frame
23//! in the [`PostUpdate`] schedule.
24//!
25//! [^1]: If at all -- most components that go together with [`Visibility`]
26//! already [require](bevy_ecs::component::Component#required-components) it,
27//! so users only need to explicitly add it if they wish to override
28//! the default value of [`Visibility::Inherited`].
29
30mod range;
31mod render_layers;
32
33use core::any::TypeId;
34
35use bevy_ecs::entity::EntityHashMap;
36use bevy_ecs::lifecycle::HookContext;
37use bevy_ecs::world::DeferredWorld;
38use bevy_mesh::skinning::{
39    entity_aabb_from_skinned_mesh_bounds, SkinnedMesh, SkinnedMeshInverseBindposes,
40};
41use derive_more::derive::{Deref, DerefMut};
42pub use range::*;
43pub use render_layers::*;
44
45use bevy_app::{Plugin, PostUpdate, ValidateParentHasComponentPlugin};
46use bevy_asset::prelude::AssetChanged;
47use bevy_asset::{AssetEventSystems, Assets};
48use bevy_ecs::{prelude::*, VariantDefaults};
49use bevy_reflect::{std_traits::ReflectDefault, Reflect};
50use bevy_transform::{components::GlobalTransform, TransformSystems};
51use bevy_utils::{Parallel, TypeIdMap};
52use smallvec::SmallVec;
53
54use crate::{
55    camera::Camera,
56    primitives::{Aabb, Frustum, MeshAabb, Sphere},
57    Projection,
58};
59use bevy_mesh::{mark_3d_meshes_as_changed_if_their_assets_changed, Mesh, Mesh2d, Mesh3d};
60
61/// Use this component to opt-out of the built-in CPU frustum culling, see
62/// [`Frustum`]. This can be attached to a [`Camera`] or to individual entities.
63///
64/// It can be used for example:
65/// - disabling CPU culling completely for a [`Camera`], using only GPU culling.
66/// - when overwriting a [`Mesh`]'s transform on the GPU side (e.g. overwriting `MeshInputUniform`'s
67///   `world_from_local`), resulting in stale CPU-side positions.
68#[derive(impl bevy_ecs::component::Component for NoCpuCulling where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::default::Default for NoCpuCulling {
    #[inline]
    fn default() -> NoCpuCulling { NoCpuCulling {} }
}Default)]
69pub struct NoCpuCulling;
70
71/// User indication of whether an entity is visible. Propagates down the entity hierarchy.
72///
73/// If an entity is hidden in this way, all [`Children`] (and all of their children and so on) who
74/// are set to [`Inherited`](Self::Inherited) will also be hidden.
75///
76/// Users should set this component if they wish to change the visibility of an entity.
77///
78/// To read the visibility of an entity, query for its [`InheritedVisibility`] instead.
79/// For more information, see [module level documentation](self#what-is-the-difference-between-visibility-components).
80#[derive(#[doc =
"**Required Components**: [`InheritedVisibility`], [`ViewVisibility`]. \n\n A component's Required Components are inserted whenever it is inserted. Note that this will also insert the required components _of_ the required components, recursively, in depth-first order."]
impl bevy_ecs::component::Component for Visibility where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {
        required_components.register_required::<InheritedVisibility>(<InheritedVisibility
                as ::core::default::Default>::default);
        required_components.register_required::<ViewVisibility>(<ViewVisibility
                as ::core::default::Default>::default);
    }
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn map_entities<M: bevy_ecs::entity::EntityMapper>(this: &mut Self,
        mapper: &mut M) {
        use bevy_ecs::entity::MapEntities;
        match this {
            Self::Inherited { .. } => {}
            Self::Hidden { .. } => {}
            Self::Visible { .. } => {}
            _ => {}
        }
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::clone::Clone for Visibility {
    #[inline]
    fn clone(&self) -> Visibility { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Visibility { }Copy, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for Visibility where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for Visibility where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Enum(bevy_reflect::enums::EnumInfo::new::<Self>(&[bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Inherited")),
                                                bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Hidden")),
                                                bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Visible"))]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for Visibility where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::Visibility"
            }
            fn short_type_path() -> &'static str { "Visibility" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("Visibility")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for Visibility where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<Visibility
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::enums::Enum for Visibility where  {
            fn field(&self, __name_param: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, __index_param: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, __name_param: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, __index_param: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn index_of(&self, __name_param: &str)
                -> ::core::option::Option<usize> {
                match self { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, __index_param: usize)
                -> ::core::option::Option<&str> {
                match self { _ => ::core::option::Option::None, }
            }
            fn iter_fields(&self) -> bevy_reflect::enums::VariantFieldIter {
                bevy_reflect::enums::VariantFieldIter::new(self)
            }
            #[inline]
            fn field_len(&self) -> usize {
                match self {
                    Visibility::Inherited { .. } => 0usize,
                    Visibility::Hidden { .. } => 0usize,
                    Visibility::Visible { .. } => 0usize,
                    _ => 0,
                }
            }
            #[inline]
            fn variant_name(&self) -> &str {
                match self {
                    Visibility::Inherited { .. } => "Inherited",
                    Visibility::Hidden { .. } => "Hidden",
                    Visibility::Visible { .. } => "Visible",
                    _ =>
                        ::core::panicking::panic("internal error: entered unreachable code"),
                }
            }
            #[inline]
            fn variant_index(&self) -> usize {
                match self {
                    Visibility::Inherited { .. } => 0usize,
                    Visibility::Hidden { .. } => 1usize,
                    Visibility::Visible { .. } => 2usize,
                    _ =>
                        ::core::panicking::panic("internal error: entered unreachable code"),
                }
            }
            #[inline]
            fn variant_type(&self) -> bevy_reflect::enums::VariantType {
                match self {
                    Visibility::Inherited { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    Visibility::Hidden { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    Visibility::Visible { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    _ =>
                        ::core::panicking::panic("internal error: entered unreachable code"),
                }
            }
            fn to_dynamic_enum(&self) -> bevy_reflect::enums::DynamicEnum {
                bevy_reflect::enums::DynamicEnum::from_ref::<Self>(self)
            }
        }
        impl bevy_reflect::PartialReflect for Visibility where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self,
                __value_param: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Enum(__value_param) =
                        bevy_reflect::PartialReflect::reflect_ref(__value_param) {
                    if bevy_reflect::enums::Enum::variant_name(self) ==
                            bevy_reflect::enums::Enum::variant_name(__value_param) {
                        match bevy_reflect::enums::Enum::variant_type(__value_param)
                            {
                            bevy_reflect::enums::VariantType::Struct => {
                                for field in
                                    bevy_reflect::enums::Enum::iter_fields(__value_param) {
                                    let name = field.name().unwrap();
                                    if let ::core::option::Option::Some(v) =
                                            bevy_reflect::enums::Enum::field_mut(self, name) {
                                        bevy_reflect::PartialReflect::try_apply(v, field.value())?;
                                    }
                                }
                            }
                            bevy_reflect::enums::VariantType::Tuple => {
                                for (index, field) in
                                    ::core::iter::Iterator::enumerate(bevy_reflect::enums::Enum::iter_fields(__value_param))
                                    {
                                    if let ::core::option::Option::Some(v) =
                                            bevy_reflect::enums::Enum::field_at_mut(self, index) {
                                        bevy_reflect::PartialReflect::try_apply(v, field.value())?;
                                    }
                                }
                            }
                            _ => {}
                        }
                    } else {
                        match bevy_reflect::enums::Enum::variant_name(__value_param)
                            {
                            "Inherited" => { *self = Visibility::Inherited {} }
                            "Hidden" => { *self = Visibility::Hidden {} }
                            "Visible" => { *self = Visibility::Visible {} }
                            name => {
                                return ::core::result::Result::Err(bevy_reflect::ApplyError::UnknownVariant {
                                            enum_name: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(self)),
                                            variant_name: ::core::convert::Into::into(name),
                                        });
                            }
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(__value_param),
                                to_kind: bevy_reflect::ReflectKind::Enum,
                            });
                }
                ::core::result::Result::Ok(())
            }
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Enum
            }
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Enum(self)
            }
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Enum(self)
            }
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Enum(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_hash(&self) -> ::core::option::Option<u64> {
                (bevy_reflect::enums::enum_hash)(self)
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                let value =
                    <dyn bevy_reflect::PartialReflect>::try_downcast_ref::<Self>(value);
                if let ::core::option::Option::Some(value) = value {
                    ::core::option::Option::Some(::core::cmp::PartialEq::eq(self,
                            value))
                } else { ::core::option::Option::Some(false) }
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::enums::enum_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for Visibility where  {
            fn from_reflect(__param0: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Enum(__param0) =
                        bevy_reflect::PartialReflect::reflect_ref(__param0) {
                    match bevy_reflect::enums::Enum::variant_name(__param0) {
                        "Inherited" =>
                            ::core::option::Option::Some(Visibility::Inherited {}),
                        "Hidden" =>
                            ::core::option::Option::Some(Visibility::Hidden {}),
                        "Visible" =>
                            ::core::option::Option::Some(Visibility::Visible {}),
                        name => ::core::option::Option::None,
                    }
                } else { ::core::option::Option::None }
            }
        }
    };Reflect, #[automatically_derived]
impl ::core::fmt::Debug for Visibility {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Visibility::Inherited => "Inherited",
                Visibility::Hidden => "Hidden",
                Visibility::Visible => "Visible",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Visibility {
    #[inline]
    fn eq(&self, other: &Visibility) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Visibility {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::default::Default for Visibility {
    #[inline]
    fn default() -> Visibility { Self::Inherited }
}Default, impl Visibility {
    #[allow(missing_docs)]
    pub fn default_inherited() -> Self { Self::Inherited }
    #[allow(missing_docs)]
    pub fn default_hidden() -> Self { Self::Hidden }
    #[allow(missing_docs)]
    pub fn default_visible() -> Self { Self::Visible }
}VariantDefaults)]
81#[reflect(Component, Default, Debug, PartialEq, Clone)]
82#[require(InheritedVisibility, ViewVisibility)]
83pub enum Visibility {
84    /// An entity with `Visibility::Inherited` will inherit the Visibility of its [`ChildOf`] target.
85    ///
86    /// A root-level entity that is set to `Inherited` will be visible.
87    #[default]
88    Inherited,
89    /// An entity with `Visibility::Hidden` will be unconditionally hidden.
90    Hidden,
91    /// An entity with `Visibility::Visible` will be unconditionally visible.
92    ///
93    /// Note that an entity with `Visibility::Visible` will be visible regardless of whether the
94    /// [`ChildOf`] target entity is hidden.
95    Visible,
96}
97
98impl Visibility {
99    /// Toggles between `Visibility::Inherited` and `Visibility::Visible`.
100    /// If the value is `Visibility::Hidden`, it remains unaffected.
101    #[inline]
102    pub fn toggle_inherited_visible(&mut self) {
103        *self = match *self {
104            Visibility::Inherited => Visibility::Visible,
105            Visibility::Visible => Visibility::Inherited,
106            _ => *self,
107        };
108    }
109    /// Toggles between `Visibility::Inherited` and `Visibility::Hidden`.
110    /// If the value is `Visibility::Visible`, it remains unaffected.
111    #[inline]
112    pub fn toggle_inherited_hidden(&mut self) {
113        *self = match *self {
114            Visibility::Inherited => Visibility::Hidden,
115            Visibility::Hidden => Visibility::Inherited,
116            _ => *self,
117        };
118    }
119    /// Toggles between `Visibility::Visible` and `Visibility::Hidden`.
120    /// If the value is `Visibility::Inherited`, it remains unaffected.
121    #[inline]
122    pub fn toggle_visible_hidden(&mut self) {
123        *self = match *self {
124            Visibility::Visible => Visibility::Hidden,
125            Visibility::Hidden => Visibility::Visible,
126            _ => *self,
127        };
128    }
129}
130
131// Allows `&Visibility == Visibility`
132impl PartialEq<Visibility> for &Visibility {
133    #[inline]
134    fn eq(&self, other: &Visibility) -> bool {
135        // Use the base Visibility == Visibility implementation.
136        <Visibility as PartialEq<Visibility>>::eq(*self, other)
137    }
138}
139
140// Allows `Visibility == &Visibility`
141impl PartialEq<&Visibility> for Visibility {
142    #[inline]
143    fn eq(&self, other: &&Visibility) -> bool {
144        // Use the base Visibility == Visibility implementation.
145        <Visibility as PartialEq<Visibility>>::eq(self, *other)
146    }
147}
148
149/// Whether or not an entity is visible in the hierarchy.
150///
151/// This is a computed component that users should not change manually.
152/// To set the visibility of an entity, use [`Visibility`] instead.
153/// For more information, see [module level documentation](self#what-is-the-difference-between-visibility-components).
154///
155/// This property is updated in [`VisibilityPropagate`] in the [`PostUpdate`] schedule.
156/// Until then, it is not up to date with [`Visibility`] if it was changed
157/// in the same frame.
158///
159/// If this is false, then [`ViewVisibility`] should also be false.
160///
161/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
162#[derive(impl bevy_ecs::component::Component for InheritedVisibility where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[allow(deprecated)]
#[allow(unreachable_code)]
#[automatically_derived]
impl derive_more::with_trait::Deref for InheritedVisibility {
    type Target = bool;
    #[inline]
    fn deref(&self) -> &Self::Target { &self.0 }
}Deref, #[automatically_derived]
impl ::core::fmt::Debug for InheritedVisibility {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f,
            "InheritedVisibility", &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for InheritedVisibility {
    #[inline]
    fn default() -> InheritedVisibility {
        InheritedVisibility(::core::default::Default::default())
    }
}Default, #[automatically_derived]
impl ::core::clone::Clone for InheritedVisibility {
    #[inline]
    fn clone(&self) -> InheritedVisibility {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InheritedVisibility { }Copy, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for InheritedVisibility where
            {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <bool as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for InheritedVisibility where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::TupleStruct(bevy_reflect::tuple_struct::TupleStructInfo::new::<Self>(&[bevy_reflect::UnnamedField::new::<bool>(0usize)]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for InheritedVisibility where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::InheritedVisibility"
            }
            fn short_type_path() -> &'static str { "InheritedVisibility" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("InheritedVisibility")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for InheritedVisibility where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<InheritedVisibility
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::tuple_struct::TupleStruct for InheritedVisibility
            where  {
            fn field(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.0),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.0),
                    _ => ::core::option::Option::None,
                }
            }
            #[inline]
            fn field_len(&self) -> usize { 1usize }
            #[inline]
            fn iter_fields(&self)
                -> bevy_reflect::tuple_struct::TupleStructFieldIter {
                bevy_reflect::tuple_struct::TupleStructFieldIter::new(self)
            }
            fn to_dynamic_tuple_struct(&self)
                -> bevy_reflect::tuple_struct::DynamicTupleStruct {
                let mut dynamic:
                        bevy_reflect::tuple_struct::DynamicTupleStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed(bevy_reflect::PartialReflect::to_dynamic(&self.0));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for InheritedVisibility where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::TupleStruct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (i, value) in
                        ::core::iter::Iterator::enumerate(bevy_reflect::tuple_struct::TupleStruct::iter_fields(struct_value))
                        {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::tuple_struct::TupleStruct::field_mut(self, i)
                            {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::TupleStruct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::TupleStruct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::TupleStruct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::TupleStruct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::TupleStruct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                let value =
                    <dyn bevy_reflect::PartialReflect>::try_downcast_ref::<Self>(value);
                if let ::core::option::Option::Some(value) = value {
                    ::core::option::Option::Some(::core::cmp::PartialEq::eq(self,
                            value))
                } else { ::core::option::Option::Some(false) }
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::tuple_struct::tuple_struct_partial_cmp)(self,
                    value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for InheritedVisibility where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::TupleStruct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    if let ::core::option::Option::Some(__field) =
                            (||
                                        <bool as
                                                bevy_reflect::FromReflect>::from_reflect(bevy_reflect::tuple_struct::TupleStruct::field(__ref_struct,
                                                    0)?))() {
                        __this.0 = __field;
                    }
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect, #[automatically_derived]
impl ::core::cmp::PartialEq for InheritedVisibility {
    #[inline]
    fn eq(&self, other: &InheritedVisibility) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for InheritedVisibility {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
163#[reflect(Component, Default, Debug, PartialEq, Clone)]
164pub struct InheritedVisibility(bool);
165
166impl InheritedVisibility {
167    /// An entity that is invisible in the hierarchy.
168    pub const HIDDEN: Self = Self(false);
169    /// An entity that is visible in the hierarchy.
170    pub const VISIBLE: Self = Self(true);
171
172    /// Returns `true` if the entity is visible in the hierarchy.
173    /// Otherwise, returns `false`.
174    #[inline]
175    pub fn get(self) -> bool {
176        self.0
177    }
178}
179
180/// A bucket into which we group entities for the purposes of visibility.
181///
182/// Bevy's various rendering subsystems (3D, 2D, etc.) want to be able to
183/// quickly winnow the set of entities to only those that the subsystem is
184/// tasked with rendering, to avoid spending time examining irrelevant entities.
185/// At the same time, Bevy wants the [`check_visibility_cpu_culling`] system to
186/// determine all entities' visibilities at the same time, regardless of what
187/// rendering subsystem is responsible for drawing them. Additionally, your
188/// application may want to add more types of renderable objects that Bevy
189/// determines visibility for just as it does for Bevy's built-in objects.
190///
191/// The solution to this problem is *visibility classes*. A visibility class is
192/// a type, typically the type of a component, that represents the subsystem
193/// that renders it: for example, `Mesh3d`, `Mesh2d`, and `Sprite`. The
194/// [`VisibilityClass`] component stores the visibility class or classes that
195/// the entity belongs to. (Generally, an object will belong to only one
196/// visibility class, but in rare cases it may belong to multiple.)
197///
198/// When adding a new renderable component, you'll typically want to write an
199/// add-component hook that adds the type ID of that component to the
200/// [`VisibilityClass`] array. See `custom_phase_item` for an example.
201///
202/// `VisibilityClass` is automatically added by a hook on the `Mesh3d` and
203/// `Mesh2d` components. To avoid duplicating the `VisibilityClass` and
204/// causing issues when cloning, we use `#[component(clone_behavior=Ignore)]`
205//
206// Note: This can't be a `ComponentId` because the visibility classes are copied
207// into the render world, and component IDs are per-world.
208#[derive(#[automatically_derived]
impl ::core::clone::Clone for VisibilityClass {
    #[inline]
    fn clone(&self) -> VisibilityClass {
        VisibilityClass(::core::clone::Clone::clone(&self.0))
    }
}Clone, impl bevy_ecs::component::Component for VisibilityClass where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        bevy_ecs::component::ComponentCloneBehavior::Ignore
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::default::Default for VisibilityClass {
    #[inline]
    fn default() -> VisibilityClass {
        VisibilityClass(::core::default::Default::default())
    }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for VisibilityClass where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <SmallVec<[TypeId; 1]> as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for VisibilityClass where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::TupleStruct(bevy_reflect::tuple_struct::TupleStructInfo::new::<Self>(&[bevy_reflect::UnnamedField::new::<SmallVec<[TypeId; 1]>>(0usize)]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for VisibilityClass where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::VisibilityClass"
            }
            fn short_type_path() -> &'static str { "VisibilityClass" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("VisibilityClass")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for VisibilityClass where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<VisibilityClass
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::tuple_struct::TupleStruct for VisibilityClass where
             {
            fn field(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.0),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.0),
                    _ => ::core::option::Option::None,
                }
            }
            #[inline]
            fn field_len(&self) -> usize { 1usize }
            #[inline]
            fn iter_fields(&self)
                -> bevy_reflect::tuple_struct::TupleStructFieldIter {
                bevy_reflect::tuple_struct::TupleStructFieldIter::new(self)
            }
            fn to_dynamic_tuple_struct(&self)
                -> bevy_reflect::tuple_struct::DynamicTupleStruct {
                let mut dynamic:
                        bevy_reflect::tuple_struct::DynamicTupleStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed(bevy_reflect::PartialReflect::to_dynamic(&self.0));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for VisibilityClass where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::TupleStruct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (i, value) in
                        ::core::iter::Iterator::enumerate(bevy_reflect::tuple_struct::TupleStruct::iter_fields(struct_value))
                        {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::tuple_struct::TupleStruct::field_mut(self, i)
                            {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::TupleStruct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::TupleStruct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::TupleStruct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::TupleStruct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::TupleStruct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::tuple_struct::tuple_struct_partial_eq)(self,
                    value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::tuple_struct::tuple_struct_partial_cmp)(self,
                    value)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for VisibilityClass where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::TupleStruct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    if let ::core::option::Option::Some(__field) =
                            (||
                                        <SmallVec<[TypeId; 1]> as
                                                bevy_reflect::FromReflect>::from_reflect(bevy_reflect::tuple_struct::TupleStruct::field(__ref_struct,
                                                    0)?))() {
                        __this.0 = __field;
                    }
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect, #[allow(deprecated)]
#[allow(unreachable_code)]
#[automatically_derived]
impl derive_more::with_trait::Deref for VisibilityClass {
    type Target = SmallVec<[TypeId; 1]>;
    #[inline]
    fn deref(&self) -> &Self::Target { &self.0 }
}Deref, #[allow(deprecated)]
#[allow(unreachable_code)]
#[automatically_derived]
impl derive_more::with_trait::DerefMut for VisibilityClass {
    #[inline]
    fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}DerefMut)]
209#[reflect(Component, Default, Clone)]
210#[component(clone_behavior=Ignore)]
211pub struct VisibilityClass(pub SmallVec<[TypeId; 1]>);
212
213/// Algorithmically computed indication of whether an entity is visible and should be extracted for
214/// rendering.
215///
216/// Not to be confused with [`Visibility`] and [`InheritedVisibility`].
217/// For more information, see [module level documentation](self#what-is-the-difference-between-visibility-components).
218///
219/// If you wish to add a custom visibility system that sets this value, be sure to add it to the
220/// [`CheckVisibility`] set.
221///
222/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
223/// [`CheckVisibility`]: VisibilitySystems::CheckVisibility
224#[derive(impl bevy_ecs::component::Component for ViewVisibility where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::fmt::Debug for ViewVisibility {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "ViewVisibility",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for ViewVisibility {
    #[inline]
    fn default() -> ViewVisibility {
        ViewVisibility(::core::default::Default::default())
    }
}Default, #[automatically_derived]
impl ::core::clone::Clone for ViewVisibility {
    #[inline]
    fn clone(&self) -> ViewVisibility {
        let _: ::core::clone::AssertParamIsClone<u8>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ViewVisibility { }Copy, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for ViewVisibility where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <u8 as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for ViewVisibility where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::TupleStruct(bevy_reflect::tuple_struct::TupleStructInfo::new::<Self>(&[bevy_reflect::UnnamedField::new::<u8>(0usize)]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for ViewVisibility where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::ViewVisibility"
            }
            fn short_type_path() -> &'static str { "ViewVisibility" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("ViewVisibility")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for ViewVisibility where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<ViewVisibility
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::tuple_struct::TupleStruct for ViewVisibility where
            {
            fn field(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.0),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.0),
                    _ => ::core::option::Option::None,
                }
            }
            #[inline]
            fn field_len(&self) -> usize { 1usize }
            #[inline]
            fn iter_fields(&self)
                -> bevy_reflect::tuple_struct::TupleStructFieldIter {
                bevy_reflect::tuple_struct::TupleStructFieldIter::new(self)
            }
            fn to_dynamic_tuple_struct(&self)
                -> bevy_reflect::tuple_struct::DynamicTupleStruct {
                let mut dynamic:
                        bevy_reflect::tuple_struct::DynamicTupleStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed(bevy_reflect::PartialReflect::to_dynamic(&self.0));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for ViewVisibility where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::TupleStruct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (i, value) in
                        ::core::iter::Iterator::enumerate(bevy_reflect::tuple_struct::TupleStruct::iter_fields(struct_value))
                        {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::tuple_struct::TupleStruct::field_mut(self, i)
                            {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::TupleStruct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::TupleStruct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::TupleStruct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::TupleStruct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::TupleStruct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                let value =
                    <dyn bevy_reflect::PartialReflect>::try_downcast_ref::<Self>(value);
                if let ::core::option::Option::Some(value) = value {
                    ::core::option::Option::Some(::core::cmp::PartialEq::eq(self,
                            value))
                } else { ::core::option::Option::Some(false) }
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::tuple_struct::tuple_struct_partial_cmp)(self,
                    value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for ViewVisibility where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::TupleStruct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    if let ::core::option::Option::Some(__field) =
                            (||
                                        <u8 as
                                                bevy_reflect::FromReflect>::from_reflect(bevy_reflect::tuple_struct::TupleStruct::field(__ref_struct,
                                                    0)?))() {
                        __this.0 = __field;
                    }
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect, #[automatically_derived]
impl ::core::cmp::PartialEq for ViewVisibility {
    #[inline]
    fn eq(&self, other: &ViewVisibility) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ViewVisibility {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u8>;
    }
}Eq)]
225#[reflect(Component, Default, Debug, PartialEq, Clone)]
226pub struct ViewVisibility(
227    /// Bit packed booleans to track current and previous view visibility state.
228    ///
229    /// Previous visibility is used as a scratch space to ensure that [`ViewVisibility`] is only
230    /// mutated (triggering change detection) when necessary.
231    ///
232    /// This is needed because an entity might be seen by many views (cameras, lights that cast
233    /// shadows, etc.), so it is easy to know if an entity is visible to something, but hard to know
234    /// if it is *globally* non-visible to any view. To solve this, we track the visibility from the
235    /// previous frame. Then, during the [`VisibilitySystems::CheckVisibility`] system set, systems
236    /// call [`SetViewVisibility::set_visible`] to mark entities as visible.
237    ///
238    /// Finally, we can look for entities that were previously visible but are no longer visible
239    /// and set their current state to hidden, ensuring that we have only triggered change detection
240    /// when necessary.
241    u8,
242);
243
244impl ViewVisibility {
245    /// An entity that cannot be seen from any views.
246    pub const HIDDEN: Self = Self(0b00);
247
248    /// An entity that is visible and was visible last frame.
249    ///
250    /// Entities that have opted out of CPU culling, if not hidden due to
251    /// inherited visibility, will have their [`ViewVisibility`] set to this
252    /// value.
253    pub const VISIBLE: Self = Self(0b11);
254
255    /// Returns `true` if the entity is visible in any view.
256    /// Otherwise, returns `false`.
257    #[inline]
258    pub fn get(self) -> bool {
259        self.0 & 1 != 0
260    }
261
262    /// Returns `true` if this entity was visible in the previous frame but is now hidden.
263    #[inline]
264    fn was_visible_now_hidden(self) -> bool {
265        // The first bit is false (current), and the second bit is true (previous).
266        (self.0 & 0b11) == 0b10
267    }
268
269    #[inline]
270    fn update(&mut self) {
271        // Copy the first bit (current) to the second bit position (previous)
272        // and clear the first bit (current).
273        self.0 = (self.0 & 1) << 1;
274    }
275}
276
277pub trait SetViewVisibility {
278    /// Sets the visibility to `true` if not already visible, triggering change detection only when
279    /// needed. This should not be considered reversible for a given frame, as this component tracks
280    /// if the entity is visible in _any_ view.
281    ///
282    /// You should only manually set this if you are defining a custom visibility system,
283    /// in which case the system should be placed in the [`CheckVisibility`] set.
284    /// For normal user-defined entity visibility, see [`Visibility`].
285    ///
286    /// [`CheckVisibility`]: VisibilitySystems::CheckVisibility
287    fn set_visible(&mut self);
288}
289
290impl<'a> SetViewVisibility for Mut<'a, ViewVisibility> {
291    #[inline]
292    fn set_visible(&mut self) {
293        // Only update if it's not already visible.
294        // This is important because `set_visible` may be called multiple times per frame.
295        if self.0 & 1 == 0 {
296            if self.0 & 2 != 0 {
297                // If it was already visible last frame, we don't want to trigger change detection
298                // because it's still visible this frame.
299                self.bypass_change_detection().0 |= 1;
300            } else {
301                // If it was NOT visible last frame, this is a transition from hidden to visible.
302                // We want to trigger change detection here.
303                self.0 |= 1;
304            }
305        }
306    }
307}
308
309/// Use this component to opt-out of built-in frustum culling for entities, see
310/// [`Frustum`].
311///
312/// It can be used for example:
313/// - when a [`Mesh`] is updated but its [`Aabb`] is not, which might happen with animations,
314/// - when using some light effects, like wanting a [`Mesh`] out of the [`Frustum`]
315///   to appear in the reflection of a [`Mesh`] within.
316#[derive(#[automatically_derived]
impl ::core::fmt::Debug for NoFrustumCulling {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NoFrustumCulling")
    }
}Debug, impl bevy_ecs::component::Component for NoFrustumCulling where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::default::Default for NoFrustumCulling {
    #[inline]
    fn default() -> NoFrustumCulling { NoFrustumCulling {} }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for NoFrustumCulling where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for NoFrustumCulling where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for NoFrustumCulling where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::NoFrustumCulling"
            }
            fn short_type_path() -> &'static str { "NoFrustumCulling" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("NoFrustumCulling")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for NoFrustumCulling where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<NoFrustumCulling
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for NoFrustumCulling where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for NoFrustumCulling where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            #[allow(unreachable_code, reason =
            "Ignored fields without a `clone` attribute will early-return with an error")]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(Self {}))
            }
        }
        impl bevy_reflect::FromReflect for NoFrustumCulling where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect, #[automatically_derived]
impl ::core::clone::Clone for NoFrustumCulling {
    #[inline]
    fn clone(&self) -> NoFrustumCulling { NoFrustumCulling }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for NoFrustumCulling {
    #[inline]
    fn eq(&self, other: &NoFrustumCulling) -> bool { true }
}PartialEq)]
317#[reflect(Component, Default, Debug)]
318pub struct NoFrustumCulling;
319
320/// Use this component to enable dynamic skinned mesh bounds. The [`Aabb`]
321/// component of the skinned mesh will be automatically updated each frame based
322/// on the current joint transforms.
323///
324/// `DynamicSkinnedMeshBounds` depends on data from `Mesh::skinned_mesh_bounds`
325/// and `SkinnedMesh`. The resulting `Aabb` will reliably enclose meshes where
326/// vertex positions are only affected by skinning. But the `Aabb` may be larger
327/// than is optimal, and doesn't account for morph targets, vertex shaders, and
328/// anything else that modifies vertex positions.
329#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DynamicSkinnedMeshBounds {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "DynamicSkinnedMeshBounds")
    }
}Debug, impl bevy_ecs::component::Component for DynamicSkinnedMeshBounds where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::default::Default for DynamicSkinnedMeshBounds {
    #[inline]
    fn default() -> DynamicSkinnedMeshBounds { DynamicSkinnedMeshBounds {} }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for DynamicSkinnedMeshBounds
            where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for DynamicSkinnedMeshBounds where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for DynamicSkinnedMeshBounds where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::DynamicSkinnedMeshBounds"
            }
            fn short_type_path() -> &'static str {
                "DynamicSkinnedMeshBounds"
            }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("DynamicSkinnedMeshBounds")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for DynamicSkinnedMeshBounds where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<DynamicSkinnedMeshBounds
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for DynamicSkinnedMeshBounds where
            {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for DynamicSkinnedMeshBounds where
            {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            #[allow(unreachable_code, reason =
            "Ignored fields without a `clone` attribute will early-return with an error")]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(Self {}))
            }
        }
        impl bevy_reflect::FromReflect for DynamicSkinnedMeshBounds where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
330#[reflect(Component, Default, Debug)]
331pub struct DynamicSkinnedMeshBounds;
332
333/// Collection of entities visible from the current view.
334///
335/// This component contains all entities which are visible from the currently
336/// rendered view. The collection is updated automatically by the [`VisibilitySystems::CheckVisibility`]
337/// system set. Renderers can use the equivalent `RenderVisibleEntities` to optimize rendering of
338/// a particular view, to prevent drawing items not visible from that view.
339///
340/// This component is intended to be attached to the same entity as the [`Camera`] and
341/// the [`Frustum`] defining the view.
342#[derive(#[automatically_derived]
impl ::core::clone::Clone for VisibleEntities {
    #[inline]
    fn clone(&self) -> VisibleEntities {
        VisibleEntities {
            entities: ::core::clone::Clone::clone(&self.entities),
        }
    }
}Clone, impl bevy_ecs::component::Component for VisibleEntities where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::fmt::Debug for VisibleEntities {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "VisibleEntities", "entities", &&self.entities)
    }
}Debug, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for VisibleEntities where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for VisibleEntities where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for VisibleEntities where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::VisibleEntities"
            }
            fn short_type_path() -> &'static str { "VisibleEntities" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("VisibleEntities")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for VisibleEntities where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<VisibleEntities
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for VisibleEntities where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for VisibleEntities where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for VisibleEntities where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
343#[reflect(Component, Default, Debug, Clone)]
344pub struct VisibleEntities {
345    #[reflect(ignore, clone)]
346    pub entities: TypeIdMap<Vec<Entity>>,
347}
348
349impl Default for VisibleEntities {
350    fn default() -> VisibleEntities {
351        // Pre-populate with `Mesh3d`.
352        // Otherwise, if all meshes happen to be tagged with `NoCpuCulling`,
353        // then they won't appear at all, because the extraction systems won't
354        // see any `Mesh3d` entities.
355        // We could handle this case in the `DirtySpecializations` methods
356        // instead, but that would complicate what are already some very
357        // complicated method signatures. So it's simpler to just do this.
358        let mut entities = TypeIdMap::default();
359        entities.insert(TypeId::of::<Mesh3d>(), ::alloc::vec::Vec::new()vec![]);
360        VisibleEntities { entities }
361    }
362}
363
364impl VisibleEntities {
365    pub fn get(&self, type_id: TypeId) -> &[Entity] {
366        match self.entities.get(&type_id) {
367            Some(entities) => &entities[..],
368            None => &[],
369        }
370    }
371
372    pub fn get_mut(&mut self, type_id: TypeId) -> &mut Vec<Entity> {
373        self.entities.entry(type_id).or_default()
374    }
375
376    pub fn iter(&self, type_id: TypeId) -> impl DoubleEndedIterator<Item = &Entity> {
377        self.get(type_id).iter()
378    }
379
380    pub fn len(&self, type_id: TypeId) -> usize {
381        self.get(type_id).len()
382    }
383
384    pub fn is_empty(&self, type_id: TypeId) -> bool {
385        self.get(type_id).is_empty()
386    }
387
388    pub fn clear(&mut self, type_id: TypeId) {
389        self.get_mut(type_id).clear();
390    }
391
392    pub fn clear_all(&mut self) {
393        // Don't just nuke the hash table; we want to reuse allocations.
394        for entities in self.entities.values_mut() {
395            entities.clear();
396        }
397    }
398
399    pub fn push(&mut self, entity: Entity, type_id: TypeId) {
400        self.get_mut(type_id).push(entity);
401    }
402}
403
404/// Collection of mesh entities visible for 3D lighting.
405///
406/// This component contains all mesh entities visible from the current light view.
407/// The collection is updated automatically by `bevy_pbr::SimulationLightSystems`.
408#[derive(impl bevy_ecs::component::Component for VisibleMeshEntities where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::clone::Clone for VisibleMeshEntities {
    #[inline]
    fn clone(&self) -> VisibleMeshEntities {
        VisibleMeshEntities {
            entities: ::core::clone::Clone::clone(&self.entities),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for VisibleMeshEntities {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "VisibleMeshEntities", "entities", &&self.entities)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for VisibleMeshEntities {
    #[inline]
    fn default() -> VisibleMeshEntities {
        VisibleMeshEntities { entities: ::core::default::Default::default() }
    }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for VisibleMeshEntities where
            {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for VisibleMeshEntities where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for VisibleMeshEntities where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::VisibleMeshEntities"
            }
            fn short_type_path() -> &'static str { "VisibleMeshEntities" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("VisibleMeshEntities")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for VisibleMeshEntities where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<VisibleMeshEntities
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for VisibleMeshEntities where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for VisibleMeshEntities where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for VisibleMeshEntities where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
409#[reflect(Component, Debug, Default, Clone)]
410pub struct VisibleMeshEntities {
411    #[reflect(ignore, clone)]
412    pub entities: Vec<Entity>,
413}
414
415impl VisibleMeshEntities {
416    /// Resizes the entity vector so that its capacity isn't too much higher
417    /// than its size.
418    pub fn shrink(&mut self) {
419        // Check that visible entities capacity() is no more than two times greater than len()
420        let capacity = self.entities.capacity();
421        let reserved = capacity
422            .checked_div(self.entities.len())
423            .map_or(0, |reserve| {
424                if reserve > 2 {
425                    capacity / (reserve / 2)
426                } else {
427                    capacity
428                }
429            });
430
431        self.entities.shrink_to(reserved);
432    }
433}
434
435#[derive(impl bevy_ecs::component::Component for CubemapVisibleEntities where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::clone::Clone for CubemapVisibleEntities {
    #[inline]
    fn clone(&self) -> CubemapVisibleEntities {
        CubemapVisibleEntities {
            data: ::core::clone::Clone::clone(&self.data),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CubemapVisibleEntities {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CubemapVisibleEntities", "data", &&self.data)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for CubemapVisibleEntities {
    #[inline]
    fn default() -> CubemapVisibleEntities {
        CubemapVisibleEntities { data: ::core::default::Default::default() }
    }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for CubemapVisibleEntities
            where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for CubemapVisibleEntities where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for CubemapVisibleEntities where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::CubemapVisibleEntities"
            }
            fn short_type_path() -> &'static str { "CubemapVisibleEntities" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("CubemapVisibleEntities")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for CubemapVisibleEntities where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<CubemapVisibleEntities
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for CubemapVisibleEntities where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for CubemapVisibleEntities where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for CubemapVisibleEntities where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
436#[reflect(Component, Debug, Default, Clone)]
437pub struct CubemapVisibleEntities {
438    #[reflect(ignore, clone)]
439    data: [VisibleMeshEntities; 6],
440}
441
442impl CubemapVisibleEntities {
443    pub fn get(&self, i: usize) -> &VisibleMeshEntities {
444        &self.data[i]
445    }
446
447    pub fn get_mut(&mut self, i: usize) -> &mut VisibleMeshEntities {
448        &mut self.data[i]
449    }
450
451    pub fn iter(&self) -> impl DoubleEndedIterator<Item = &VisibleMeshEntities> {
452        self.data.iter()
453    }
454
455    pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut VisibleMeshEntities> {
456        self.data.iter_mut()
457    }
458}
459
460#[derive(impl bevy_ecs::component::Component for CascadesVisibleEntities where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::clone::Clone for CascadesVisibleEntities {
    #[inline]
    fn clone(&self) -> CascadesVisibleEntities {
        CascadesVisibleEntities {
            entities: ::core::clone::Clone::clone(&self.entities),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CascadesVisibleEntities {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CascadesVisibleEntities", "entities", &&self.entities)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for CascadesVisibleEntities {
    #[inline]
    fn default() -> CascadesVisibleEntities {
        CascadesVisibleEntities {
            entities: ::core::default::Default::default(),
        }
    }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for CascadesVisibleEntities
            where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration.register_type_data::<ReflectComponent, Self>();
                registration.register_type_data::<ReflectDefault, Self>();
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for CascadesVisibleEntities where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for CascadesVisibleEntities where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::CascadesVisibleEntities"
            }
            fn short_type_path() -> &'static str { "CascadesVisibleEntities" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("CascadesVisibleEntities")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for CascadesVisibleEntities where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<CascadesVisibleEntities
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for CascadesVisibleEntities where
            {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for CascadesVisibleEntities where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for CascadesVisibleEntities where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let mut __this =
                        <Self as ::core::default::Default>::default();
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
461#[reflect(Component, Default, Clone)]
462pub struct CascadesVisibleEntities {
463    /// Map of view entity to the visible entities for each cascade frustum.
464    #[reflect(ignore, clone)]
465    pub entities: EntityHashMap<Vec<VisibleMeshEntities>>,
466}
467
468#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VisibilitySystems {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                VisibilitySystems::CalculateBounds => "CalculateBounds",
                VisibilitySystems::UpdateFrusta => "UpdateFrusta",
                VisibilitySystems::VisibilityPropagate =>
                    "VisibilityPropagate",
                VisibilitySystems::CheckVisibility => "CheckVisibility",
                VisibilitySystems::MarkNewlyHiddenEntitiesInvisible =>
                    "MarkNewlyHiddenEntitiesInvisible",
            })
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for VisibilitySystems {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for VisibilitySystems {
    #[inline]
    fn eq(&self, other: &VisibilitySystems) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for VisibilitySystems {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::clone::Clone for VisibilitySystems {
    #[inline]
    fn clone(&self) -> VisibilitySystems {
        match self {
            VisibilitySystems::CalculateBounds =>
                VisibilitySystems::CalculateBounds,
            VisibilitySystems::UpdateFrusta =>
                VisibilitySystems::UpdateFrusta,
            VisibilitySystems::VisibilityPropagate =>
                VisibilitySystems::VisibilityPropagate,
            VisibilitySystems::CheckVisibility =>
                VisibilitySystems::CheckVisibility,
            VisibilitySystems::MarkNewlyHiddenEntitiesInvisible =>
                VisibilitySystems::MarkNewlyHiddenEntitiesInvisible,
        }
    }
}Clone, const _: () =
    {
        extern crate alloc;
        impl bevy_ecs::schedule::SystemSet for VisibilitySystems where
            Self: 'static + ::core::marker::Send + ::core::marker::Sync +
            ::core::clone::Clone + ::core::cmp::Eq + ::core::fmt::Debug +
            ::core::hash::Hash {
            fn dyn_clone(&self)
                -> alloc::boxed::Box<dyn bevy_ecs::schedule::SystemSet> {
                alloc::boxed::Box::new(::core::clone::Clone::clone(self))
            }
        }
    };SystemSet)]
469pub enum VisibilitySystems {
470    /// Label for the [`calculate_bounds`], `calculate_bounds_2d` and `calculate_bounds_text2d` systems,
471    /// calculating and inserting an [`Aabb`] to relevant entities.
472    CalculateBounds,
473    /// Label for [`update_frusta`] in [`CameraProjectionPlugin`](crate::CameraProjectionPlugin).
474    UpdateFrusta,
475    /// Label for the system propagating the [`InheritedVisibility`] in a
476    /// [`ChildOf`] / [`Children`] hierarchy.
477    VisibilityPropagate,
478    /// Label for the [`check_visibility_cpu_culling`] and
479    /// [`check_visibility_gpu_culling`] systems updating [`ViewVisibility`] of
480    /// each entity and the [`VisibleEntities`] of each view.
481    ///
482    /// System order ambiguities between systems in this set are ignored: the
483    /// order of systems within this set is irrelevant, as
484    /// [`check_visibility_cpu_culling`] assumes that its operations are
485    /// irreversible during the frame.
486    CheckVisibility,
487    /// Label for the `mark_newly_hidden_entities_invisible` system, which sets
488    /// [`ViewVisibility`] to [`ViewVisibility::HIDDEN`] for entities that no
489    /// view has marked as visible.
490    MarkNewlyHiddenEntitiesInvisible,
491}
492
493pub struct VisibilityPlugin;
494
495impl Plugin for VisibilityPlugin {
496    fn build(&self, app: &mut bevy_app::App) {
497        use VisibilitySystems::*;
498
499        app.add_plugins(ValidateParentHasComponentPlugin::<InheritedVisibility>::default())
500            .register_required_components::<Mesh3d, Visibility>()
501            .register_required_components::<Mesh3d, VisibilityClass>()
502            .register_required_components::<Mesh2d, Visibility>()
503            .register_required_components::<Mesh2d, VisibilityClass>()
504            .configure_sets(
505                PostUpdate,
506                (UpdateFrusta, VisibilityPropagate)
507                    .before(CheckVisibility)
508                    .after(TransformSystems::Propagate),
509            )
510            .configure_sets(
511                PostUpdate,
512                MarkNewlyHiddenEntitiesInvisible.after(CheckVisibility),
513            )
514            .configure_sets(
515                PostUpdate,
516                (CalculateBounds)
517                    .before(CheckVisibility)
518                    .after(TransformSystems::Propagate)
519                    .after(AssetEventSystems)
520                    .ambiguous_with(CalculateBounds)
521                    .ambiguous_with(mark_3d_meshes_as_changed_if_their_assets_changed),
522            )
523            .add_systems(
524                PostUpdate,
525                (
526                    (calculate_bounds, update_skinned_mesh_bounds)
527                        .chain()
528                        .in_set(CalculateBounds),
529                    (visibility_propagate_system, reset_view_visibility)
530                        .in_set(VisibilityPropagate),
531                    (check_visibility_cpu_culling, check_visibility_gpu_culling)
532                        .in_set(CheckVisibility),
533                    mark_newly_hidden_entities_invisible.in_set(MarkNewlyHiddenEntitiesInvisible),
534                ),
535            );
536        app.world_mut()
537            .register_component_hooks::<Mesh3d>()
538            .on_add(add_visibility_class::<Mesh3d>);
539        app.world_mut()
540            .register_component_hooks::<Mesh2d>()
541            .on_add(add_visibility_class::<Mesh2d>);
542    }
543}
544
545/// Add this component to an entity to prevent its `AABB` from being automatically recomputed.
546///
547/// This is useful if entities are already spawned with a correct `Aabb` component, or you have
548/// many entities and want to avoid the cost of table scans searching for entities that need to have
549/// their AABB recomputed.
550#[derive(impl bevy_ecs::component::Component for NoAutoAabb where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::Table;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {}
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, #[automatically_derived]
impl ::core::clone::Clone for NoAutoAabb {
    #[inline]
    fn clone(&self) -> NoAutoAabb { NoAutoAabb }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for NoAutoAabb {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NoAutoAabb")
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for NoAutoAabb {
    #[inline]
    fn default() -> NoAutoAabb { NoAutoAabb {} }
}Default, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for NoAutoAabb where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
                registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for NoAutoAabb where  {
            #[inline]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for NoAutoAabb where  {
            fn type_path() -> &'static str {
                "bevy_camera::visibility::NoAutoAabb"
            }
            fn short_type_path() -> &'static str { "NoAutoAabb" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("NoAutoAabb")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_camera::visibility")
            }
        }
        impl bevy_reflect::Reflect for NoAutoAabb where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<NoAutoAabb
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for NoAutoAabb where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index { _ => ::core::option::Option::None, }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name { _ => ::core::option::Option::None, }
            }
            fn field_len(&self) -> usize { 0usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                -> bevy_reflect::structs::DynamicStruct {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic
            }
        }
        impl bevy_reflect::PartialReflect for NoAutoAabb where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            #[inline]
            #[allow(unreachable_code, reason =
            "Ignored fields without a `clone` attribute will early-return with an error")]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(Self {}))
            }
        }
        impl bevy_reflect::FromReflect for NoAutoAabb where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let __this = Self {};
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
551pub struct NoAutoAabb;
552
553/// Computes and adds an [`Aabb`] component to entities with a
554/// [`Mesh3d`] component and without a [`NoFrustumCulling`] component.
555///
556/// This system is used in system set [`VisibilitySystems::CalculateBounds`].
557pub fn calculate_bounds(
558    mut commands: Commands,
559    meshes: Res<Assets<Mesh>>,
560    new_aabb: Query<
561        (Entity, &Mesh3d),
562        (
563            Without<Aabb>,
564            Without<NoFrustumCulling>,
565            Without<NoAutoAabb>,
566        ),
567    >,
568    mut update_aabb: Query<
569        (&Mesh3d, &mut Aabb),
570        (
571            Or<(AssetChanged<Mesh3d>, Changed<Mesh3d>)>,
572            Without<NoFrustumCulling>,
573            Without<NoAutoAabb>,
574        ),
575    >,
576) {
577    for (entity, mesh_handle) in &new_aabb {
578        if let Some(mesh) = meshes.get(mesh_handle)
579            && let Some(aabb) = mesh.compute_aabb()
580        {
581            commands.entity(entity).try_insert(aabb);
582        }
583    }
584
585    update_aabb
586        .par_iter_mut()
587        .for_each(|(mesh_handle, mut old_aabb)| {
588            if let Some(aabb) = meshes.get(mesh_handle).and_then(MeshAabb::compute_aabb) {
589                *old_aabb = aabb;
590            }
591        });
592}
593
594// Update the `Aabb` component of all skinned mesh entities with a `DynamicSkinnedMeshBounds`
595// component.
596fn update_skinned_mesh_bounds(
597    inverse_bindposes_assets: Res<Assets<SkinnedMeshInverseBindposes>>,
598    mesh_assets: Res<Assets<Mesh>>,
599    mut mesh_entities: Query<
600        (&mut Aabb, &Mesh3d, &SkinnedMesh, Option<&GlobalTransform>),
601        With<DynamicSkinnedMeshBounds>,
602    >,
603    joint_entities: Query<&GlobalTransform>,
604) {
605    mesh_entities
606        .par_iter_mut()
607        .for_each(|(mut aabb, mesh, skinned_mesh, world_from_entity)| {
608            if let Some(inverse_bindposes_asset) =
609                inverse_bindposes_assets.get(&skinned_mesh.inverse_bindposes)
610                && let Some(mesh_asset) = mesh_assets.get(mesh)
611                && let Ok(skinned_aabb) = entity_aabb_from_skinned_mesh_bounds(
612                    &joint_entities,
613                    mesh_asset,
614                    skinned_mesh,
615                    inverse_bindposes_asset,
616                    world_from_entity,
617                )
618            {
619                *aabb = skinned_aabb.into();
620            }
621        });
622}
623
624/// Updates [`Frustum`].
625///
626/// This system is used in [`CameraProjectionPlugin`](crate::CameraProjectionPlugin).
627pub fn update_frusta(
628    mut views: Query<
629        (&GlobalTransform, &Projection, &mut Frustum),
630        Or<(Changed<GlobalTransform>, Changed<Projection>)>,
631    >,
632) {
633    for (transform, projection, mut frustum) in &mut views {
634        *frustum = projection.compute_frustum(transform);
635    }
636}
637
638fn visibility_propagate_system(
639    changed: Query<
640        (Entity, &Visibility, Option<&ChildOf>, Option<&Children>),
641        (
642            With<InheritedVisibility>,
643            Or<(Changed<Visibility>, Changed<ChildOf>)>,
644        ),
645    >,
646    mut visibility_query: Query<(&Visibility, &mut InheritedVisibility)>,
647    children_query: Query<&Children, (With<Visibility>, With<InheritedVisibility>)>,
648    mut removed_child_of: RemovedComponents<ChildOf>,
649) {
650    for (entity, visibility, child_of, children) in &changed {
651        let is_visible = match visibility {
652            Visibility::Visible => true,
653            Visibility::Hidden => false,
654            // fall back to true if no parent is found or parent lacks components
655            Visibility::Inherited => child_of
656                .and_then(|c| visibility_query.get(c.parent()).ok())
657                .is_none_or(|(_, x)| x.get()),
658        };
659        let (_, mut inherited_visibility) = visibility_query
660            .get_mut(entity)
661            .expect("With<InheritedVisibility> ensures this query will return a value");
662
663        // Only update the visibility if it has changed.
664        // This will also prevent the visibility from propagating multiple times in the same frame
665        // if this entity's visibility has been updated recursively by its parent.
666        if inherited_visibility.get() != is_visible {
667            inherited_visibility.0 = is_visible;
668
669            // Recursively update the visibility of each child.
670            for &child in children.into_iter().flatten() {
671                let _ =
672                    propagate_recursive(is_visible, child, &mut visibility_query, &children_query);
673            }
674        }
675    }
676
677    // Previous loop did not consider entities who just had their ChildOf component removed.
678    for entity in removed_child_of.read() {
679        let Ok((visibility, mut inherited_visibility)) = visibility_query.get_mut(entity) else {
680            continue;
681        };
682
683        let is_visible = match visibility {
684            // If a entity has no parent, fall back to true
685            Visibility::Visible | Visibility::Inherited => true,
686            Visibility::Hidden => false,
687        };
688
689        if inherited_visibility.get() != is_visible {
690            inherited_visibility.0 = is_visible;
691
692            for &child in children_query.get(entity).ok().into_iter().flatten() {
693                let _ =
694                    propagate_recursive(is_visible, child, &mut visibility_query, &children_query);
695            }
696        }
697    }
698}
699
700fn propagate_recursive(
701    parent_is_visible: bool,
702    entity: Entity,
703    visibility_query: &mut Query<(&Visibility, &mut InheritedVisibility)>,
704    children_query: &Query<&Children, (With<Visibility>, With<InheritedVisibility>)>,
705    // BLOCKED: https://github.com/rust-lang/rust/issues/31436
706    // We use a result here to use the `?` operator. Ideally we'd use a try block instead
707) -> Result<(), ()> {
708    // Get the visibility components for the current entity.
709    // If the entity does not have the required components, just return early.
710    let (visibility, mut inherited_visibility) = visibility_query.get_mut(entity).map_err(drop)?;
711
712    let is_visible = match visibility {
713        Visibility::Visible => true,
714        Visibility::Hidden => false,
715        Visibility::Inherited => parent_is_visible,
716    };
717
718    // Only update the visibility if it has changed.
719    if inherited_visibility.get() != is_visible {
720        inherited_visibility.0 = is_visible;
721
722        // Recursively update the visibility of each child.
723        for &child in children_query.get(entity).ok().into_iter().flatten() {
724            let _ = propagate_recursive(is_visible, child, visibility_query, children_query);
725        }
726    }
727
728    Ok(())
729}
730
731/// Track entities that were visible last frame, used to granularly update
732/// [`ViewVisibility`] this frame without spurious `Change` detecation.
733fn reset_view_visibility(mut reset_query: Query<&mut ViewVisibility, Without<NoCpuCulling>>) {
734    reset_query.par_iter_mut().for_each(|mut view_visibility| {
735        view_visibility.bypass_change_detection().update();
736    });
737}
738
739/// System updating the visibility of entities, other than those that have opted
740/// out of CPU culling, each frame.
741///
742/// The system is part of the [`VisibilitySystems::CheckVisibility`] set. Each
743/// frame, it updates the [`ViewVisibility`] of all entities, and for each view
744/// also compute the [`VisibleEntities`] for that view.
745///
746/// To ensure that an entity is checked for visibility, make sure that it has a
747/// [`VisibilityClass`] component and that that component is nonempty.
748pub fn check_visibility_cpu_culling(
749    mut thread_queues: Local<Parallel<TypeIdMap<Vec<Entity>>>>,
750    mut view_query: Query<(
751        Entity,
752        &mut VisibleEntities,
753        &Frustum,
754        Option<&RenderLayers>,
755        &Camera,
756        Has<NoCpuCulling>,
757    )>,
758    mut visible_aabb_query: Query<
759        (
760            Entity,
761            &InheritedVisibility,
762            &mut ViewVisibility,
763            Option<&VisibilityClass>,
764            Option<&RenderLayers>,
765            Option<&Aabb>,
766            Option<&Sphere>,
767            &GlobalTransform,
768            Has<NoFrustumCulling>,
769            Has<VisibilityRange>,
770        ),
771        Without<NoCpuCulling>,
772    >,
773    visible_entity_ranges: Option<Res<VisibleEntityRanges>>,
774) {
775    let visible_entity_ranges = visible_entity_ranges.as_deref();
776
777    for (view, mut visible_entities, frustum, maybe_view_mask, camera, no_cpu_culling_camera) in
778        &mut view_query
779    {
780        if !camera.is_active {
781            continue;
782        }
783
784        let view_mask = maybe_view_mask.unwrap_or_default();
785
786        visible_aabb_query.par_iter_mut().for_each_init(
787            || thread_queues.borrow_local_mut(),
788            |queue, query_item| {
789                let (
790                    entity,
791                    inherited_visibility,
792                    mut view_visibility,
793                    visibility_class,
794                    maybe_entity_mask,
795                    maybe_model_aabb,
796                    maybe_model_sphere,
797                    transform,
798                    no_frustum_culling,
799                    has_visibility_range,
800                ) = query_item;
801
802                // Skip computing visibility for entities that are configured to be hidden.
803                // ViewVisibility has already been reset in `reset_view_visibility`.
804                if !inherited_visibility.get() {
805                    return;
806                }
807
808                let entity_mask = maybe_entity_mask.unwrap_or_default();
809                if !view_mask.intersects(entity_mask) {
810                    return;
811                }
812
813                // If outside of the visibility range, cull.
814                if has_visibility_range
815                    && visible_entity_ranges.is_some_and(|visible_entity_ranges| {
816                        !visible_entity_ranges.entity_is_in_range_of_view(entity, view)
817                    })
818                {
819                    return;
820                }
821
822                // If we have an aabb or a bounding sphere, do frustum culling
823                if !no_frustum_culling && !no_cpu_culling_camera {
824                    if let Some(model_aabb) = maybe_model_aabb {
825                        let world_from_local = transform.affine();
826                        let model_sphere = Sphere {
827                            center: world_from_local.transform_point3a(model_aabb.center),
828                            radius: transform.radius_vec3a(model_aabb.half_extents),
829                        };
830                        // Do quick sphere-based frustum culling
831                        if !frustum.intersects_sphere(&model_sphere, false) {
832                            return;
833                        }
834                        // Do aabb-based frustum culling
835                        if !frustum.intersects_obb(model_aabb, &world_from_local, true, false) {
836                            return;
837                        }
838                    } else if let Some(model_sphere) = maybe_model_sphere
839                        && !frustum.intersects_sphere(model_sphere, false)
840                    {
841                        // Do sphere-based frustum culling in this case
842                        return;
843                    }
844                }
845
846                view_visibility.set_visible();
847
848                // The visibility class may be None here because AABB gizmos can be enabled via
849                // config without a renderable component being added to the entity. This workaround
850                // allows view visibility to be set for entities without a renderable component, but
851                // still need to render gizmos.
852                if let Some(visibility_class) = visibility_class {
853                    // Add the entity to the queue for all visibility classes the entity is in.
854                    for visibility_class_id in visibility_class.iter() {
855                        queue.entry(*visibility_class_id).or_default().push(entity);
856                    }
857                }
858            },
859        );
860
861        visible_entities.clear_all();
862
863        // Drain all the thread queues into the `visible_entities` list.
864        for class_queues in thread_queues.iter_mut() {
865            for (class, entities) in class_queues {
866                visible_entities.get_mut(*class).append(entities);
867            }
868        }
869
870        // The list must be sorted in order for the O(n) diffing algorithm that
871        // visibility determination uses to work, so do that now.
872        for visible_entities in visible_entities.entities.values_mut() {
873            visible_entities.sort_unstable();
874        }
875    }
876}
877
878/// Updates the visibility of entities marked with [`NoCpuCulling`].
879///
880/// In this case, the [`ViewVisibility`] of each such mesh simply becomes equal
881/// to its [`InheritedVisibility`], as the CPU has been instructed to perform no
882/// other checks. For performance, we avoid examining any entity that hasn't
883/// changed its inherited visibility.
884pub fn check_visibility_gpu_culling(
885    mut query: Query<
886        (&mut ViewVisibility, &InheritedVisibility),
887        (
888            With<NoCpuCulling>,
889            Or<(Changed<InheritedVisibility>, Added<NoCpuCulling>)>,
890        ),
891    >,
892) {
893    query
894        .par_iter_mut()
895        .for_each(|(mut view_visibility, inherited_visibility)| {
896            let new_view_visibility = if inherited_visibility.0 {
897                ViewVisibility::VISIBLE
898            } else {
899                ViewVisibility::HIDDEN
900            };
901            view_visibility.set_if_neq(new_view_visibility);
902        });
903}
904
905/// The last step in the visibility pipeline. Looks at entities that were visible last frame but not
906/// marked as visible this frame and marks them as hidden by setting the [`ViewVisibility`]. This
907/// process is needed to ensure we only trigger change detection on [`ViewVisibility`] when needed.
908fn mark_newly_hidden_entities_invisible(
909    mut view_visibilities: Query<&mut ViewVisibility, Without<NoCpuCulling>>,
910) {
911    view_visibilities
912        .par_iter_mut()
913        .for_each(|mut view_visibility| {
914            if view_visibility.as_ref().was_visible_now_hidden() {
915                *view_visibility = ViewVisibility::HIDDEN;
916            }
917        });
918}
919
920/// A generic component add hook that automatically adds the appropriate
921/// [`VisibilityClass`] to an entity.
922///
923/// This can be handy when creating custom renderable components. To use this
924/// hook, add it to your renderable component like this:
925///
926/// ```ignore
927/// #[derive(Component)]
928/// #[component(on_add = add_visibility_class::<MyComponent>)]
929/// struct MyComponent {
930///     ...
931/// }
932/// ```
933pub fn add_visibility_class<C>(
934    mut world: DeferredWorld<'_>,
935    HookContext { entity, .. }: HookContext,
936) where
937    C: 'static,
938{
939    if let Some(mut visibility_class) = world.get_mut::<VisibilityClass>(entity) {
940        visibility_class.push(TypeId::of::<C>());
941    }
942}
943
944#[cfg(test)]
945mod test {
946    use super::*;
947    use bevy_app::prelude::*;
948
949    #[test]
950    fn visibility_propagation() {
951        let mut app = App::new();
952        app.add_systems(Update, visibility_propagate_system);
953
954        let root1 = app.world_mut().spawn(Visibility::Hidden).id();
955        let root1_child1 = app.world_mut().spawn(Visibility::default()).id();
956        let root1_child2 = app.world_mut().spawn(Visibility::Hidden).id();
957        let root1_child1_grandchild1 = app.world_mut().spawn(Visibility::default()).id();
958        let root1_child2_grandchild1 = app.world_mut().spawn(Visibility::default()).id();
959
960        app.world_mut()
961            .entity_mut(root1)
962            .add_children(&[root1_child1, root1_child2]);
963        app.world_mut()
964            .entity_mut(root1_child1)
965            .add_children(&[root1_child1_grandchild1]);
966        app.world_mut()
967            .entity_mut(root1_child2)
968            .add_children(&[root1_child2_grandchild1]);
969
970        let root2 = app.world_mut().spawn(Visibility::default()).id();
971        let root2_child1 = app.world_mut().spawn(Visibility::default()).id();
972        let root2_child2 = app.world_mut().spawn(Visibility::Hidden).id();
973        let root2_child1_grandchild1 = app.world_mut().spawn(Visibility::default()).id();
974        let root2_child2_grandchild1 = app.world_mut().spawn(Visibility::default()).id();
975
976        app.world_mut()
977            .entity_mut(root2)
978            .add_children(&[root2_child1, root2_child2]);
979        app.world_mut()
980            .entity_mut(root2_child1)
981            .add_children(&[root2_child1_grandchild1]);
982        app.world_mut()
983            .entity_mut(root2_child2)
984            .add_children(&[root2_child2_grandchild1]);
985
986        app.update();
987
988        let is_visible = |e: Entity| {
989            app.world()
990                .entity(e)
991                .get::<InheritedVisibility>()
992                .unwrap()
993                .get()
994        };
995        assert!(
996            !is_visible(root1),
997            "invisibility propagates down tree from root"
998        );
999        assert!(
1000            !is_visible(root1_child1),
1001            "invisibility propagates down tree from root"
1002        );
1003        assert!(
1004            !is_visible(root1_child2),
1005            "invisibility propagates down tree from root"
1006        );
1007        assert!(
1008            !is_visible(root1_child1_grandchild1),
1009            "invisibility propagates down tree from root"
1010        );
1011        assert!(
1012            !is_visible(root1_child2_grandchild1),
1013            "invisibility propagates down tree from root"
1014        );
1015
1016        assert!(
1017            is_visible(root2),
1018            "visibility propagates down tree from root"
1019        );
1020        assert!(
1021            is_visible(root2_child1),
1022            "visibility propagates down tree from root"
1023        );
1024        assert!(
1025            !is_visible(root2_child2),
1026            "visibility propagates down tree from root, but local invisibility is preserved"
1027        );
1028        assert!(
1029            is_visible(root2_child1_grandchild1),
1030            "visibility propagates down tree from root"
1031        );
1032        assert!(
1033            !is_visible(root2_child2_grandchild1),
1034            "child's invisibility propagates down to grandchild"
1035        );
1036    }
1037
1038    #[test]
1039    fn test_visibility_propagation_on_parent_change() {
1040        // Setup the world and schedule
1041        let mut app = App::new();
1042
1043        app.add_systems(Update, visibility_propagate_system);
1044
1045        // Create entities with visibility and hierarchy
1046        let parent1 = app.world_mut().spawn((Visibility::Hidden,)).id();
1047        let parent2 = app.world_mut().spawn((Visibility::Visible,)).id();
1048        let child1 = app.world_mut().spawn((Visibility::Inherited,)).id();
1049        let child2 = app.world_mut().spawn((Visibility::Inherited,)).id();
1050
1051        // Build hierarchy
1052        app.world_mut()
1053            .entity_mut(parent1)
1054            .add_children(&[child1, child2]);
1055
1056        // Run the system initially to set up visibility
1057        app.update();
1058
1059        // Change parent visibility to Hidden
1060        app.world_mut()
1061            .entity_mut(parent2)
1062            .insert(Visibility::Visible);
1063        // Simulate a change in the parent component
1064        app.world_mut().entity_mut(child2).insert(ChildOf(parent2)); // example of changing parent
1065
1066        // Run the system again to propagate changes
1067        app.update();
1068
1069        let is_visible = |e: Entity| {
1070            app.world()
1071                .entity(e)
1072                .get::<InheritedVisibility>()
1073                .unwrap()
1074                .get()
1075        };
1076
1077        // Retrieve and assert visibility
1078
1079        assert!(
1080            !is_visible(child1),
1081            "Child1 should inherit visibility from parent"
1082        );
1083
1084        assert!(
1085            is_visible(child2),
1086            "Child2 should inherit visibility from parent"
1087        );
1088    }
1089
1090    #[test]
1091    fn test_visibility_propagation_on_parent_removed() {
1092        // Setup the world and schedule
1093        let mut app = App::new();
1094
1095        app.add_systems(Update, visibility_propagate_system);
1096
1097        // Create entities with visibility and hierarchy
1098        let parent = app.world_mut().spawn((Visibility::Hidden,)).id();
1099        let child = app.world_mut().spawn((Visibility::Inherited,)).id();
1100
1101        // Build hierarchy
1102        app.world_mut().entity_mut(parent).add_children(&[child]);
1103
1104        // Run the system initially to set up visibility
1105        app.update();
1106
1107        let is_visible = |app: &App, e: Entity| {
1108            app.world()
1109                .entity(e)
1110                .get::<InheritedVisibility>()
1111                .unwrap()
1112                .get()
1113        };
1114
1115        assert!(
1116            !is_visible(&app, child),
1117            "Child should inherit visibility from parent"
1118        );
1119
1120        // Detach a child from the invisible parent
1121        app.world_mut().entity_mut(child).remove::<ChildOf>(); // example of changing parent
1122
1123        // Run the system again to propagate changes
1124        app.update();
1125
1126        // The child should now be visible as there is not parent to inherit
1127        // invisibility from.
1128        assert!(is_visible(&app, child), "Child should have become visible");
1129    }
1130
1131    #[test]
1132    fn visibility_propagation_unconditional_visible() {
1133        use Visibility::{Hidden, Inherited, Visible};
1134
1135        let mut app = App::new();
1136        app.add_systems(Update, visibility_propagate_system);
1137
1138        let root1 = app.world_mut().spawn(Visible).id();
1139        let root1_child1 = app.world_mut().spawn(Inherited).id();
1140        let root1_child2 = app.world_mut().spawn(Hidden).id();
1141        let root1_child1_grandchild1 = app.world_mut().spawn(Visible).id();
1142        let root1_child2_grandchild1 = app.world_mut().spawn(Visible).id();
1143
1144        let root2 = app.world_mut().spawn(Inherited).id();
1145        let root3 = app.world_mut().spawn(Hidden).id();
1146
1147        app.world_mut()
1148            .entity_mut(root1)
1149            .add_children(&[root1_child1, root1_child2]);
1150        app.world_mut()
1151            .entity_mut(root1_child1)
1152            .add_children(&[root1_child1_grandchild1]);
1153        app.world_mut()
1154            .entity_mut(root1_child2)
1155            .add_children(&[root1_child2_grandchild1]);
1156
1157        app.update();
1158
1159        let is_visible = |e: Entity| {
1160            app.world()
1161                .entity(e)
1162                .get::<InheritedVisibility>()
1163                .unwrap()
1164                .get()
1165        };
1166        assert!(
1167            is_visible(root1),
1168            "an unconditionally visible root is visible"
1169        );
1170        assert!(
1171            is_visible(root1_child1),
1172            "an inheriting child of an unconditionally visible parent is visible"
1173        );
1174        assert!(
1175            !is_visible(root1_child2),
1176            "a hidden child on an unconditionally visible parent is hidden"
1177        );
1178        assert!(
1179            is_visible(root1_child1_grandchild1),
1180            "an unconditionally visible child of an inheriting parent is visible"
1181        );
1182        assert!(
1183            is_visible(root1_child2_grandchild1),
1184            "an unconditionally visible child of a hidden parent is visible"
1185        );
1186        assert!(is_visible(root2), "an inheriting root is visible");
1187        assert!(!is_visible(root3), "a hidden root is hidden");
1188    }
1189
1190    #[test]
1191    fn visibility_propagation_change_detection() {
1192        let mut world = World::new();
1193        let mut schedule = Schedule::default();
1194        schedule.add_systems(visibility_propagate_system);
1195
1196        // Set up an entity hierarchy.
1197
1198        let id1 = world.spawn(Visibility::default()).id();
1199
1200        let id2 = world.spawn(Visibility::default()).id();
1201        world.entity_mut(id1).add_children(&[id2]);
1202
1203        let id3 = world.spawn(Visibility::Hidden).id();
1204        world.entity_mut(id2).add_children(&[id3]);
1205
1206        let id4 = world.spawn(Visibility::default()).id();
1207        world.entity_mut(id3).add_children(&[id4]);
1208
1209        // Test the hierarchy.
1210
1211        // Make sure the hierarchy is up-to-date.
1212        schedule.run(&mut world);
1213        world.clear_trackers();
1214
1215        let mut q = world.query::<Ref<InheritedVisibility>>();
1216
1217        assert!(!q.get(&world, id1).unwrap().is_changed());
1218        assert!(!q.get(&world, id2).unwrap().is_changed());
1219        assert!(!q.get(&world, id3).unwrap().is_changed());
1220        assert!(!q.get(&world, id4).unwrap().is_changed());
1221
1222        world.clear_trackers();
1223        world.entity_mut(id1).insert(Visibility::Hidden);
1224        schedule.run(&mut world);
1225
1226        assert!(q.get(&world, id1).unwrap().is_changed());
1227        assert!(q.get(&world, id2).unwrap().is_changed());
1228        assert!(!q.get(&world, id3).unwrap().is_changed());
1229        assert!(!q.get(&world, id4).unwrap().is_changed());
1230
1231        world.clear_trackers();
1232        schedule.run(&mut world);
1233
1234        assert!(!q.get(&world, id1).unwrap().is_changed());
1235        assert!(!q.get(&world, id2).unwrap().is_changed());
1236        assert!(!q.get(&world, id3).unwrap().is_changed());
1237        assert!(!q.get(&world, id4).unwrap().is_changed());
1238
1239        world.clear_trackers();
1240        world.entity_mut(id3).insert(Visibility::Inherited);
1241        schedule.run(&mut world);
1242
1243        assert!(!q.get(&world, id1).unwrap().is_changed());
1244        assert!(!q.get(&world, id2).unwrap().is_changed());
1245        assert!(!q.get(&world, id3).unwrap().is_changed());
1246        assert!(!q.get(&world, id4).unwrap().is_changed());
1247
1248        world.clear_trackers();
1249        world.entity_mut(id2).insert(Visibility::Visible);
1250        schedule.run(&mut world);
1251
1252        assert!(!q.get(&world, id1).unwrap().is_changed());
1253        assert!(q.get(&world, id2).unwrap().is_changed());
1254        assert!(q.get(&world, id3).unwrap().is_changed());
1255        assert!(q.get(&world, id4).unwrap().is_changed());
1256
1257        world.clear_trackers();
1258        schedule.run(&mut world);
1259
1260        assert!(!q.get(&world, id1).unwrap().is_changed());
1261        assert!(!q.get(&world, id2).unwrap().is_changed());
1262        assert!(!q.get(&world, id3).unwrap().is_changed());
1263        assert!(!q.get(&world, id4).unwrap().is_changed());
1264    }
1265
1266    #[test]
1267    fn visibility_propagation_with_invalid_parent() {
1268        let mut world = World::new();
1269        let mut schedule = Schedule::default();
1270        schedule.add_systems(visibility_propagate_system);
1271
1272        let parent = world.spawn(()).id();
1273        let child = world.spawn(Visibility::default()).id();
1274        world.entity_mut(parent).add_children(&[child]);
1275
1276        schedule.run(&mut world);
1277        world.clear_trackers();
1278
1279        let child_visible = world.entity(child).get::<InheritedVisibility>().unwrap().0;
1280        // defaults to same behavior of parent not found: visible = true
1281        assert!(child_visible);
1282    }
1283
1284    #[test]
1285    fn ensure_visibility_enum_size() {
1286        assert_eq!(1, size_of::<Visibility>());
1287        assert_eq!(1, size_of::<Option<Visibility>>());
1288    }
1289
1290    #[derive(Component, Default, Clone, Reflect)]
1291    #[require(VisibilityClass)]
1292    #[reflect(Component, Default, Clone)]
1293    #[component(on_add = add_visibility_class::<Self>)]
1294    struct TestVisibilityClassHook;
1295
1296    #[test]
1297    fn test_add_visibility_class_hook() {
1298        let mut world = World::new();
1299        let entity = world.spawn(TestVisibilityClassHook).id();
1300        let entity_clone = world.spawn_empty().id();
1301        world
1302            .entity_mut(entity)
1303            .clone_with_opt_out(entity_clone, |_| {});
1304
1305        let entity_visibility_class = world.entity(entity).get::<VisibilityClass>().unwrap();
1306        assert_eq!(entity_visibility_class.len(), 1);
1307
1308        let entity_clone_visibility_class =
1309            world.entity(entity_clone).get::<VisibilityClass>().unwrap();
1310        assert_eq!(entity_clone_visibility_class.len(), 1);
1311    }
1312
1313    #[test]
1314    fn view_visibility_lifecycle() {
1315        let mut app = App::new();
1316        app.add_plugins((
1317            TaskPoolPlugin::default(),
1318            bevy_asset::AssetPlugin::default(),
1319            bevy_mesh::MeshPlugin,
1320            bevy_transform::TransformPlugin,
1321            VisibilityPlugin,
1322        ));
1323
1324        #[derive(Resource, Default)]
1325        struct ManualMark(bool);
1326        #[derive(Resource, Default)]
1327        struct ObservedChanged(bool);
1328        app.init_resource::<ManualMark>();
1329        app.init_resource::<ObservedChanged>();
1330
1331        app.add_systems(
1332            PostUpdate,
1333            (
1334                (|mut q: Query<&mut ViewVisibility>, mark: Res<ManualMark>| {
1335                    if mark.0 {
1336                        for mut v in &mut q {
1337                            v.set_visible();
1338                        }
1339                    }
1340                })
1341                .in_set(VisibilitySystems::CheckVisibility),
1342                (|q: Query<(), Changed<ViewVisibility>>, mut observed: ResMut<ObservedChanged>| {
1343                    if !q.is_empty() {
1344                        observed.0 = true;
1345                    }
1346                })
1347                .after(VisibilitySystems::MarkNewlyHiddenEntitiesInvisible),
1348            ),
1349        );
1350
1351        let entity = app.world_mut().spawn(ViewVisibility::HIDDEN).id();
1352
1353        // Advance system ticks and clear spawn change
1354        app.update();
1355        app.world_mut().resource_mut::<ObservedChanged>().0 = false;
1356
1357        // Frame 1: do nothing
1358        app.update();
1359        {
1360            assert!(
1361                !app.world()
1362                    .entity(entity)
1363                    .get::<ViewVisibility>()
1364                    .unwrap()
1365                    .get(),
1366                "Frame 1: should be hidden"
1367            );
1368            assert!(
1369                !app.world().resource::<ObservedChanged>().0,
1370                "Frame 1: should not be changed"
1371            );
1372        }
1373
1374        // Frame 2: set entity as visible
1375        app.world_mut().resource_mut::<ManualMark>().0 = true;
1376        app.update();
1377        {
1378            assert!(
1379                app.world()
1380                    .entity(entity)
1381                    .get::<ViewVisibility>()
1382                    .unwrap()
1383                    .get(),
1384                "Frame 2: should be visible"
1385            );
1386            assert!(
1387                app.world().resource::<ObservedChanged>().0,
1388                "Frame 2: should be changed"
1389            );
1390        }
1391
1392        // Frame 3: still visible
1393        app.world_mut().resource_mut::<ManualMark>().0 = true;
1394        app.world_mut().resource_mut::<ObservedChanged>().0 = false;
1395        app.update();
1396        {
1397            assert!(
1398                app.world()
1399                    .entity(entity)
1400                    .get::<ViewVisibility>()
1401                    .unwrap()
1402                    .get(),
1403                "Frame 3: should be visible"
1404            );
1405            assert!(
1406                !app.world().resource::<ObservedChanged>().0,
1407                "Frame 3: should NOT be changed"
1408            );
1409        }
1410
1411        // Frame 4: do nothing (becomes hidden)
1412        app.world_mut().resource_mut::<ManualMark>().0 = false;
1413        app.world_mut().resource_mut::<ObservedChanged>().0 = false;
1414        app.update();
1415        {
1416            assert!(
1417                !app.world()
1418                    .entity(entity)
1419                    .get::<ViewVisibility>()
1420                    .unwrap()
1421                    .get(),
1422                "Frame 4: should be hidden"
1423            );
1424            assert!(
1425                app.world().resource::<ObservedChanged>().0,
1426                "Frame 4: should be changed"
1427            );
1428        }
1429
1430        // Frame 5: do nothing
1431        app.world_mut().resource_mut::<ManualMark>().0 = false;
1432        app.world_mut().resource_mut::<ObservedChanged>().0 = false;
1433        app.update();
1434        {
1435            assert!(
1436                !app.world()
1437                    .entity(entity)
1438                    .get::<ViewVisibility>()
1439                    .unwrap()
1440                    .get(),
1441                "Frame 5: should be hidden"
1442            );
1443            assert!(
1444                !app.world().resource::<ObservedChanged>().0,
1445                "Frame 5: should NOT be changed"
1446            );
1447        }
1448    }
1449}