pub struct MaterialTable { /* private fields */ }Expand description
A 256-entry palette of Materials indexed by a per-voxel u8 material
id. The renderer owns one table (a global palette); voxels reference
materials by id rather than embedding them.
Id 0 is permanently Material::OPAQUE and cannot be redefined —
it is the value every material-free voxel resolves to, so the opaque
world stays byte-for-byte unchanged. set silently
ignores id 0.
Implementations§
Source§impl MaterialTable
impl MaterialTable
Sourcepub fn new() -> Self
pub fn new() -> Self
A fresh palette: every id is Material::OPAQUE.
Sourcepub fn set(&mut self, id: u8, mat: Material) -> bool
pub fn set(&mut self, id: u8, mat: Material) -> bool
Define material id. Id 0 is reserved as Material::OPAQUE and
cannot be overwritten — defining it is a no-op that returns false;
any other id returns true.
Sourcepub fn get(&self, id: u8) -> Material
pub fn get(&self, id: u8) -> Material
The material at id (Material::OPAQUE for any never-set id).
Sourcepub fn all_opaque(&self) -> bool
pub fn all_opaque(&self) -> bool
True when every id is BlendMode::Opaque — lets a backend skip the
whole transparency path while nothing translucent is defined.
Trait Implementations§
Source§impl Clone for MaterialTable
impl Clone for MaterialTable
Source§fn clone(&self) -> MaterialTable
fn clone(&self) -> MaterialTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more