pub enum MaterialRef {
Inline {
material: Box<dyn Material>,
uuid: AssetUUID,
},
Asset(AssetUUID),
}Expand description
Authored reference to a material — the only serialized material form.
The enum is the discriminator: Inline embeds the material value,
Asset carries the stable UUID of a .kmat in the VFS.
Both arms carry an identity UUID — the content-derived UUID for Inline,
the stable asset UUID for Asset. The resolver compares this identity
against the resolved handle’s UUID every tick: a mismatch (or a missing
handle) means the authored reference changed and must be re-resolved. The
Inline UUID is never serialized; it is recomputed from the material
content on deserialize via MaterialRef::inline so it stays purely
content-derived. Construct Inline through MaterialRef::inline so the
UUID and the material value can never disagree.
Variants§
Inline
Ad-hoc material data created in code or the editor, embedded inline.
The uuid is content-derived; build via MaterialRef::inline.
Fields
uuid: AssetUUIDContent-derived identity UUID (the same content hash the GPU projection keys on). Not serialized — recomputed on load.
Asset(AssetUUID)
Reference to a .kmat asset in the VFS, resolved by UUID.
Implementations§
Source§impl MaterialRef
impl MaterialRef
Sourcepub fn inline(material: Box<dyn Material>) -> Self
pub fn inline(material: Box<dyn Material>) -> Self
Builds an Inline reference from a material value, deriving its identity
UUID from the material content. Two inline references holding equal
material content get the same UUID, so they dedup to one resolved handle
(and one GpuMaterial). On a serialization failure the UUID falls back
to a fresh random value (logged) rather than panicking.
Trait Implementations§
Source§impl Clone for MaterialRef
impl Clone for MaterialRef
Source§impl Component for MaterialRef
impl Component for MaterialRef
Source§fn make_column() -> Box<dyn AnyVec>where
Self: Sized,
fn make_column() -> Box<dyn AnyVec>where
Self: Sized,
Vec<Self>.Source§fn push_into_column(self, column: &mut dyn AnyVec)where
Self: Sized,
fn push_into_column(self, column: &mut dyn AnyVec)where
Self: Sized,
self as a new row into its column. Read moreSource§fn copy_row_between(src: &dyn AnyVec, src_row: usize, dst: &mut dyn AnyVec)where
Self: Sized,
fn copy_row_between(src: &dyn AnyVec, src_row: usize, dst: &mut dyn AnyVec)where
Self: Sized,
src_row from src into dst (used when an entity migrates
between pages on a structural change). Both columns are this component’s
column type. Read moreSource§fn clone_from_column(column: &dyn AnyVec, row: usize) -> Selfwhere
Self: Sized,
fn clone_from_column(column: &dyn AnyVec, row: usize) -> Selfwhere
Self: Sized,
row of column as an owned value — the uniform by-value
access path that works for both AoS (clone the &T) and field-SoA
(gather the fields) layouts. Used by World::clone_component, the
Soa<T> query, and the serialization recipe. Read moreAuto Trait Implementations§
impl Freeze for MaterialRef
impl !RefUnwindSafe for MaterialRef
impl Send for MaterialRef
impl Sync for MaterialRef
impl Unpin for MaterialRef
impl UnsafeUnpin for MaterialRef
impl !UnwindSafe for MaterialRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<C1> ComponentBundle for C1where
C1: Component,
impl<C1> ComponentBundle for C1where
C1: Component,
Source§fn type_ids() -> Vec<TypeId>
fn type_ids() -> Vec<TypeId>
TypeIds for the components in this bundle. Read moreSource§fn create_columns() -> HashMap<TypeId, Box<dyn AnyVec>>
fn create_columns() -> HashMap<TypeId, Box<dyn AnyVec>>
Vec<T> columns required to store
this bundle’s components. Read moreSource§fn update_metadata(
metadata: &mut EntityMetadata,
location: PageIndex,
registry: &ComponentRegistry,
)
fn update_metadata( metadata: &mut EntityMetadata, location: PageIndex, registry: &ComponentRegistry, )
EntityMetadata struct to point
to the location of this bundle’s data. Read moreSource§unsafe fn add_to_page(self, page: &mut ComponentPage)
unsafe fn add_to_page(self, page: &mut ComponentPage)
ComponentPage. Read more