pub struct ShapeRegistry {
shapes: Vec<VoxelShape>,
allows_registering: bool,
}Expand description
Registry for VoxelShapes.
Shapes are registered once and referenced by ShapeId. This allows deduplication of shapes and compact storage of shape references.
Vanilla shapes are registered at startup. Plugins can register additional shapes for custom blocks.
Fields§
§shapes: Vec<VoxelShape>§allows_registering: boolImplementations§
Source§impl ShapeRegistry
impl ShapeRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new shape registry with the standard empty and full block shapes.
Sourcepub fn register(&mut self, shape: VoxelShape) -> ShapeId
pub fn register(&mut self, shape: VoxelShape) -> ShapeId
Sourcepub fn get(&self, id: ShapeId) -> VoxelShape
pub fn get(&self, id: ShapeId) -> VoxelShape
Gets the shape for a given ID.
Returns an empty shape if the ID is invalid.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShapeRegistry
impl RefUnwindSafe for ShapeRegistry
impl Send for ShapeRegistry
impl Sync for ShapeRegistry
impl Unpin for ShapeRegistry
impl UnsafeUnpin for ShapeRegistry
impl UnwindSafe for ShapeRegistry
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
Mutably borrows from an owned value. Read more