Struct ShapeRegistry
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§
§impl ShapeRegistry
impl ShapeRegistry
pub fn new() -> ShapeRegistry
pub fn new() -> ShapeRegistry
Creates a new shape registry with the standard empty and full block shapes.
pub fn register(&mut self, shape: VoxelShape) -> ShapeId
pub fn register(&mut self, shape: VoxelShape) -> ShapeId
pub 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.
pub const fn freeze(&mut self)
pub const fn freeze(&mut self)
Freezes the registry, preventing further registrations.
Trait Implementations§
§impl Default for ShapeRegistry
impl Default for ShapeRegistry
§fn default() -> ShapeRegistry
fn default() -> ShapeRegistry
Returns the “default value” for a type. Read more
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>