Skip to main content

bevy_mesh/
components.rs

1use crate::mesh::Mesh;
2use bevy_asset::{AsAssetId, AssetEvent, AssetId, Handle};
3use bevy_derive::{Deref, DerefMut};
4use bevy_ecs::{
5    change_detection::DetectChangesMut, component::Component, message::MessageReader,
6    reflect::ReflectComponent, system::Query, template::FromTemplate,
7};
8use bevy_platform::{collections::HashSet, hash::FixedHasher};
9use bevy_reflect::{std_traits::ReflectDefault, Reflect};
10use bevy_transform::components::Transform;
11use core::any::TypeId;
12use derive_more::derive::From;
13
14/// A component for 2D meshes. Requires a [`MeshMaterial2d`] to be rendered, commonly using a [`ColorMaterial`].
15///
16/// [`MeshMaterial2d`]: <https://docs.rs/bevy/latest/bevy/prelude/struct.MeshMaterial2d.html>
17/// [`ColorMaterial`]: <https://docs.rs/bevy/latest/bevy/prelude/struct.ColorMaterial.html>
18///
19/// # Example
20///
21/// ```ignore
22/// # use bevy_sprite::{ColorMaterial, MeshMaterial2d};
23/// # use bevy_ecs::prelude::*;
24/// # use bevy_mesh::{Mesh, Mesh2d};
25/// # use bevy_color::palettes::basic::RED;
26/// # use bevy_asset::Assets;
27/// # use bevy_shape::Circle;
28/// #
29/// // Spawn an entity with a mesh using `ColorMaterial`.
30/// fn setup(
31///     mut commands: Commands,
32///     mut meshes: ResMut<Assets<Mesh>>,
33///     mut materials: ResMut<Assets<ColorMaterial>>,
34/// ) {
35///     commands.spawn((
36///         Mesh2d(meshes.add(Circle::new(50.0))),
37///         MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))),
38///     ));
39/// }
40/// ```
41#[derive(
42    #[doc =
"**Required Components**: [`Transform`]. \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 Mesh2d 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::<Transform>(<Transform 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 relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, impl bevy_ecs::template::FromTemplate for Mesh2d {
    type Template = Mesh2dTemplate;
}
impl ::core::marker::Unpin for Mesh2d where
    for<'a> [()]: bevy_ecs::template::SpecializeFromTemplate {}
#[allow(missing_docs)]
pub struct Mesh2dTemplate(pub <Handle<Mesh> as
    bevy_ecs::template::FromTemplate>::Template);
impl bevy_ecs::template::Template for Mesh2dTemplate {
    type Output = Mesh2d;
    fn build_template(&self,
        context: &mut bevy_ecs::template::TemplateContext)
        -> bevy_ecs::error::Result<Self::Output> {
        bevy_ecs::error::Result::Ok(Mesh2d(self.0.build_template(context)?))
    }
    fn clone_template(&self) -> Self {
        Self(bevy_ecs::template::Template::clone_template(&self.0))
    }
}
impl ::core::default::Default for Mesh2dTemplate {
    fn default() -> Self { Self(::core::default::Default::default()) }
}FromTemplate, #[automatically_derived]
impl ::core::clone::Clone for Mesh2d {
    #[inline]
    fn clone(&self) -> Self { Self(::core::clone::Clone::clone(&self.0)) }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Mesh2d {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Mesh2d",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for Mesh2d {
    #[inline]
    fn default() -> Self { Self(::core::default::Default::default()) }
}Default, impl ::core::ops::Deref for Mesh2d {
    type Target = Handle<Mesh>;
    fn deref(&self) -> &Self::Target { &self.0 }
}Deref, impl ::core::ops::DerefMut for Mesh2d {
    fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}DerefMut, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for Mesh2d where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectComponent, Self,
                    _>(());
                registration.register_type_data_with::<ReflectDefault, Self,
                    _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <Handle<Mesh> as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for Mesh2d where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::TupleStruct(bevy_reflect::tuple_struct::TupleStructInfo::new::<Self>(&[bevy_reflect::UnnamedField::new::<Handle<Mesh>>(0usize)]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for Mesh2d where  {
            fn type_path() -> &'static str { "bevy_mesh::components::Mesh2d" }
            fn short_type_path() -> &'static str { "Mesh2d" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("Mesh2d")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_mesh::components".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_mesh::components")
            }
        }
        impl bevy_reflect::Reflect for Mesh2d 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(<Mesh2d
                                        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 Mesh2d 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)
                ->
                    ::core::result::Result<bevy_reflect::tuple_struct::DynamicTupleStruct,
                    bevy_reflect::ReflectCloneError> {
                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)?);
                ::core::result::Result::Ok(dynamic)
            }
        }
        impl bevy_reflect::PartialReflect for Mesh2d 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)
            }
            #[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 Mesh2d 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) =
                            (||
                                        <Handle<Mesh> 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::marker::StructuralPartialEq for Mesh2d { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Mesh2d {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Mesh2d {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Handle<Mesh>>;
    }
}Eq, #[allow(deprecated)]
#[allow(unreachable_code)]
#[automatically_derived]
impl derive_more::core::convert::From<(Handle<Mesh>)> for Mesh2d {
    #[inline]
    fn from(value: (Handle<Mesh>)) -> Self { Mesh2d(value) }
}From,
43)]
44#[reflect(Component, Default, Clone, PartialEq)]
45#[require(Transform)]
46pub struct Mesh2d(pub Handle<Mesh>);
47
48impl From<Mesh2d> for AssetId<Mesh> {
49    fn from(mesh: Mesh2d) -> Self {
50        mesh.id()
51    }
52}
53
54impl From<&Mesh2d> for AssetId<Mesh> {
55    fn from(mesh: &Mesh2d) -> Self {
56        mesh.id()
57    }
58}
59
60impl AsAssetId for Mesh2d {
61    type Asset = Mesh;
62
63    fn as_asset_id(&self) -> AssetId<Self::Asset> {
64        self.id()
65    }
66}
67
68/// A component for 3D meshes. Requires a [`MeshMaterial3d`] to be rendered, commonly using a [`StandardMaterial`].
69///
70/// [`MeshMaterial3d`]: <https://docs.rs/bevy/latest/bevy/pbr/struct.MeshMaterial3d.html>
71/// [`StandardMaterial`]: <https://docs.rs/bevy/latest/bevy/pbr/struct.StandardMaterial.html>
72///
73/// # Example
74///
75/// ```ignore
76/// # use bevy_pbr::{Material, MeshMaterial3d, StandardMaterial};
77/// # use bevy_ecs::prelude::*;
78/// # use bevy_mesh::{Mesh, Mesh3d};
79/// # use bevy_color::palettes::basic::RED;
80/// # use bevy_asset::Assets;
81/// # use bevy_shape::Capsule3d;
82/// #
83/// // Spawn an entity with a mesh using `StandardMaterial`.
84/// fn setup(
85///     mut commands: Commands,
86///     mut meshes: ResMut<Assets<Mesh>>,
87///     mut materials: ResMut<Assets<StandardMaterial>>,
88/// ) {
89///     commands.spawn((
90///         Mesh3d(meshes.add(Capsule3d::default())),
91///         MeshMaterial3d(materials.add(StandardMaterial {
92///             base_color: RED.into(),
93///             ..Default::default()
94///         })),
95///     ));
96/// }
97/// ```
98#[derive(
99    #[doc =
"**Required Components**: [`Transform`]. \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 Mesh3d 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::<Transform>(<Transform 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 relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}Component, impl bevy_ecs::template::FromTemplate for Mesh3d {
    type Template = Mesh3dTemplate;
}
impl ::core::marker::Unpin for Mesh3d where
    for<'a> [()]: bevy_ecs::template::SpecializeFromTemplate {}
#[allow(missing_docs)]
pub struct Mesh3dTemplate(pub <Handle<Mesh> as
    bevy_ecs::template::FromTemplate>::Template);
impl bevy_ecs::template::Template for Mesh3dTemplate {
    type Output = Mesh3d;
    fn build_template(&self,
        context: &mut bevy_ecs::template::TemplateContext)
        -> bevy_ecs::error::Result<Self::Output> {
        bevy_ecs::error::Result::Ok(Mesh3d(self.0.build_template(context)?))
    }
    fn clone_template(&self) -> Self {
        Self(bevy_ecs::template::Template::clone_template(&self.0))
    }
}
impl ::core::default::Default for Mesh3dTemplate {
    fn default() -> Self { Self(::core::default::Default::default()) }
}FromTemplate, #[automatically_derived]
impl ::core::clone::Clone for Mesh3d {
    #[inline]
    fn clone(&self) -> Self { Self(::core::clone::Clone::clone(&self.0)) }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Mesh3d {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Mesh3d",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for Mesh3d {
    #[inline]
    fn default() -> Self { Self(::core::default::Default::default()) }
}Default, impl ::core::ops::Deref for Mesh3d {
    type Target = Handle<Mesh>;
    fn deref(&self) -> &Self::Target { &self.0 }
}Deref, impl ::core::ops::DerefMut for Mesh3d {
    fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}DerefMut, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for Mesh3d where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectComponent, Self,
                    _>(());
                registration.register_type_data_with::<ReflectDefault, Self,
                    _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <Handle<Mesh> as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for Mesh3d where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::TupleStruct(bevy_reflect::tuple_struct::TupleStructInfo::new::<Self>(&[bevy_reflect::UnnamedField::new::<Handle<Mesh>>(0usize)]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for Mesh3d where  {
            fn type_path() -> &'static str { "bevy_mesh::components::Mesh3d" }
            fn short_type_path() -> &'static str { "Mesh3d" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("Mesh3d")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_mesh::components".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_mesh::components")
            }
        }
        impl bevy_reflect::Reflect for Mesh3d 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(<Mesh3d
                                        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 Mesh3d 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)
                ->
                    ::core::result::Result<bevy_reflect::tuple_struct::DynamicTupleStruct,
                    bevy_reflect::ReflectCloneError> {
                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)?);
                ::core::result::Result::Ok(dynamic)
            }
        }
        impl bevy_reflect::PartialReflect for Mesh3d 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)
            }
            #[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 Mesh3d 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) =
                            (||
                                        <Handle<Mesh> 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::marker::StructuralPartialEq for Mesh3d { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Mesh3d {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Mesh3d {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Handle<Mesh>>;
    }
}Eq, #[allow(deprecated)]
#[allow(unreachable_code)]
#[automatically_derived]
impl derive_more::core::convert::From<(Handle<Mesh>)> for Mesh3d {
    #[inline]
    fn from(value: (Handle<Mesh>)) -> Self { Mesh3d(value) }
}From,
100)]
101#[reflect(Component, Default, Clone, PartialEq)]
102#[require(Transform)]
103pub struct Mesh3d(pub Handle<Mesh>);
104
105impl From<Mesh3d> for AssetId<Mesh> {
106    fn from(mesh: Mesh3d) -> Self {
107        mesh.id()
108    }
109}
110
111impl From<&Mesh3d> for AssetId<Mesh> {
112    fn from(mesh: &Mesh3d) -> Self {
113        mesh.id()
114    }
115}
116
117impl AsAssetId for Mesh3d {
118    type Asset = Mesh;
119
120    fn as_asset_id(&self) -> AssetId<Self::Asset> {
121        self.id()
122    }
123}
124
125/// A system that marks a [`Mesh2d`] as changed if the associated [`Mesh2d`]
126/// asset has changed.
127///
128/// This is needed because the system that extracts meshes, `extract_2d_meshes`,
129/// write some metadata about the mesh into the GPU structures that they build
130/// that needs to be kept up to date if the contents of the mesh change.
131pub fn mark_2d_meshes_as_changed_if_their_assets_changed(
132    mut meshes_2d: Query<&mut Mesh2d>,
133    mut mesh_asset_events: MessageReader<AssetEvent<Mesh>>,
134) {
135    let mut changed_meshes: HashSet<AssetId<Mesh>, FixedHasher> = HashSet::default();
136    for mesh_asset_event in mesh_asset_events.read() {
137        if let AssetEvent::Modified { id } = mesh_asset_event {
138            changed_meshes.insert(*id);
139        }
140    }
141
142    if changed_meshes.is_empty() {
143        return;
144    }
145
146    for mut mesh_2d in &mut meshes_2d {
147        if changed_meshes.contains(&mesh_2d.0.id()) {
148            mesh_2d.set_changed();
149        }
150    }
151}
152
153/// A system that marks a [`Mesh3d`] as changed if the associated [`Mesh`] asset
154/// has changed.
155///
156/// This is needed because the systems that extract meshes, such as
157/// `extract_meshes_for_gpu_building`, write some metadata about the mesh (like
158/// the location within each slab) into the GPU structures that they build that
159/// needs to be kept up to date if the contents of the mesh change.
160pub fn mark_3d_meshes_as_changed_if_their_assets_changed(
161    mut meshes_3d: Query<&mut Mesh3d>,
162    mut mesh_asset_events: MessageReader<AssetEvent<Mesh>>,
163) {
164    let mut changed_meshes: HashSet<AssetId<Mesh>, FixedHasher> = HashSet::default();
165    for mesh_asset_event in mesh_asset_events.read() {
166        if let AssetEvent::Modified { id } = mesh_asset_event {
167            changed_meshes.insert(*id);
168        }
169    }
170
171    if changed_meshes.is_empty() {
172        return;
173    }
174
175    meshes_3d.par_iter_mut().for_each(|mut mesh_3d| {
176        if changed_meshes.contains(&mesh_3d.0.id()) {
177            mesh_3d.set_changed();
178        }
179    });
180}
181
182/// A component that stores an arbitrary index used to identify the mesh
183/// instance when rendering.
184///
185/// You can fetch the value of the tag in the shader using the `tag` field on
186/// `bevy_pbr::mesh_bindings::mesh`.
187///
188/// When using a `GpuComponentArrayBuffer`, the tag represents the index of the
189/// mesh instance data in the buffer. In this case, Bevy automatically manages
190/// the tag, keeping it up to date as component data are extracted to and
191/// removed from the buffer. If you aren't using a `GpuComponentArrayBuffer`,
192/// the tag is free for you to use for whatever purpose you wish.
193///
194/// You may optionally supply a [`TypeId`] to accompany the mesh tag. Bevy
195/// ignores this type and treats it only as an opaque marker. It's not stored
196/// except in debug mode. Its only purpose is to provide diagnostics so that
197/// `GpuComponentArrayBuffer` can emit warnings if it overwrites a mesh tag.
198/// Examples of misuse that `GpuComponentArrayBuffer` can detect are cases in
199/// which you were using a [`MeshTag`] for application-specific purposes in
200/// addition to storing a component backed by a `GpuComponentArrayBuffer` on
201/// your mesh and cases in which you attempted to store multiple components
202/// backed by `GpuComponentArrayBuffer`s on the same mesh.
203#[derive(impl bevy_ecs::component::Component for MeshTag 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 MeshTag {
    #[inline]
    fn clone(&self) -> Self {
        Self {
            value: ::core::clone::Clone::clone(&self.value),
            type_id: ::core::clone::Clone::clone(&self.type_id),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for MeshTag {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "MeshTag",
            "value", &self.value, "type_id", &&self.type_id)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for MeshTag {
    #[inline]
    fn default() -> Self {
        Self {
            value: ::core::default::Default::default(),
            type_id: ::core::default::Default::default(),
        }
    }
}Default, impl ::core::ops::Deref for MeshTag {
    type Target = u32;
    fn deref(&self) -> &Self::Target { &self.value }
}Deref, impl ::core::ops::DerefMut for MeshTag {
    fn deref_mut(&mut self) -> &mut Self::Target { &mut self.value }
}DerefMut, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for MeshTag where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectComponent, Self,
                    _>(());
                registration.register_type_data_with::<ReflectDefault, Self,
                    _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <u32 as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <Option<TypeId> as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for MeshTag where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[bevy_reflect::NamedField::new::<u32>("value"),
                                                bevy_reflect::NamedField::new::<Option<TypeId>>("type_id")]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for MeshTag where  {
            fn type_path() -> &'static str {
                "bevy_mesh::components::MeshTag"
            }
            fn short_type_path() -> &'static str { "MeshTag" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("MeshTag")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_mesh::components".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_mesh::components")
            }
        }
        impl bevy_reflect::Reflect for MeshTag 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(<MeshTag
                                        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 MeshTag where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name {
                    "value" => ::core::option::Option::Some(&self.value),
                    "type_id" => ::core::option::Option::Some(&self.type_id),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name {
                    "value" => ::core::option::Option::Some(&mut self.value),
                    "type_id" =>
                        ::core::option::Option::Some(&mut self.type_id),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.value),
                    1usize => ::core::option::Option::Some(&self.type_id),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.value),
                    1usize => ::core::option::Option::Some(&mut self.type_id),
                    _ => ::core::option::Option::None,
                }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index {
                    0usize => ::core::option::Option::Some("value"),
                    1usize => ::core::option::Option::Some("type_id"),
                    _ => ::core::option::Option::None,
                }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name {
                    "value" => ::core::option::Option::Some(0usize),
                    "type_id" => ::core::option::Option::Some(1usize),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_len(&self) -> usize { 2usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                ->
                    ::core::result::Result<bevy_reflect::structs::DynamicStruct,
                    bevy_reflect::ReflectCloneError> {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed("value",
                    bevy_reflect::PartialReflect::to_dynamic(&self.value)?);
                dynamic.insert_boxed("type_id",
                    bevy_reflect::PartialReflect::to_dynamic(&self.type_id)?);
                ::core::result::Result::Ok(dynamic)
            }
        }
        impl bevy_reflect::PartialReflect for MeshTag 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> {
                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::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 MeshTag 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();
                    if let ::core::option::Option::Some(__field) =
                            (||
                                        <u32 as
                                                bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                                    "value")?))() {
                        __this.value = __field;
                    }
                    if let ::core::option::Option::Some(__field) =
                            (||
                                        <Option<TypeId> as
                                                bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                                    "type_id")?))() {
                        __this.type_id = __field;
                    }
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for MeshTag { }
#[automatically_derived]
impl ::core::cmp::PartialEq for MeshTag {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.value == other.value && self.type_id == other.type_id
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MeshTag {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u32>;
        let _: ::core::cmp::AssertParamIsEq<Option<TypeId>>;
    }
}Eq)]
204#[reflect(Component, Default, Clone, PartialEq)]
205pub struct MeshTag {
206    /// The value made available to the shader.
207    #[deref]
208    pub value: u32,
209
210    /// The optional opaque type ID.
211    ///
212    /// See the documentation of [`MeshTag`] for more information.
213    ///
214    /// This field is only present in debug mode.
215    #[cfg(debug_assertions)]
216    type_id: Option<TypeId>,
217}
218
219impl MeshTag {
220    /// Creates a new [`MeshTag`] with the given value.
221    ///
222    /// No type ID is specified.
223    pub const fn new(value: u32) -> MeshTag {
224        MeshTag {
225            value,
226            #[cfg(debug_assertions)]
227            type_id: None,
228        }
229    }
230
231    /// Creates a new [`MeshTag`] with the given value and type.
232    ///
233    /// In debug mode, the type is stored on the [`MeshTag`] component and used
234    /// for detecting accidental tag overwriting.
235    pub fn with_type<T>(value: u32) -> MeshTag
236    where
237        T: 'static + Sized,
238    {
239        MeshTag::with_type_id(value, TypeId::of::<T>())
240    }
241
242    /// Creates a new [`MeshTag`] with the given value and type ID.
243    ///
244    /// This is the equivalent of [`Self::with_type`], except that the type ID
245    /// can be supplied dynamically.
246    ///
247    /// In debug mode, the type ID is stored on the [`MeshTag`] component and
248    /// used for detecting accidental tag overwriting.
249    pub fn with_type_id(value: u32, _type_id: TypeId) -> MeshTag {
250        MeshTag {
251            value,
252            #[cfg(debug_assertions)]
253            type_id: Some(_type_id),
254        }
255    }
256
257    /// Returns true if the type ID is present and equal to the ID of the given
258    /// type.
259    ///
260    /// `GpuComponentArrayBuffer` uses this to emit diagnostics if the component
261    /// array buffer logic overwrites a tag that might have been used for
262    /// application-specific purposes or for storing other components backed by
263    /// array buffers.
264    ///
265    /// In debug mode, this always returns true.
266    pub fn type_is<T>(&self) -> bool
267    where
268        T: 'static + Sized,
269    {
270        self.type_id_is(TypeId::of::<T>())
271    }
272
273    /// Returns true if the type ID is present and equal to the given type ID.
274    ///
275    /// This is the equivalent of [`Self::type_is`], except that the type ID can
276    /// be supplied dynamically.
277    ///
278    /// In debug mode, this always returns true.
279    #[cfg(debug_assertions)]
280    pub fn type_id_is(&self, type_id: TypeId) -> bool {
281        self.type_id == Some(type_id)
282    }
283
284    /// Returns true if the type ID is present and equal to the given type ID.
285    ///
286    /// This is the equivalent of [`Self::type_is`], except that the type ID can
287    /// be supplied dynamically.
288    ///
289    /// In debug mode, this always returns true.
290    #[cfg(not(debug_assertions))]
291    pub fn type_id_is(&self, _: TypeId) -> bool {
292        true
293    }
294}