#[non_exhaustive]#[repr(u8)]pub enum Resolution {
R1 = 0,
R2 = 1,
R4 = 2,
R8 = 3,
R16 = 4,
R32 = 5,
R64 = 6,
R128 = 7,
}Expand description
Scale factor between a Block and its component voxels.
This resolution cubed is the number of voxels making up a block.
Resolutions are always powers of 2. This ensures that the arithmetic is well-behaved (no division by zero, exact floating-point representation, and the potential of fixed-point representation), and that it is always possible to subdivide a block further (up to the limit) without shifting the existing voxel boundaries.
Note that while quite high resolutions are permitted, this does not mean that it is practical to routinely use full blocks at that resolution. For example, 64 × 64 × 64 = 262,144 voxels, occupying several megabytes just for color data. High resolutions are permitted for special purposes that do not necessarily use the full cube volume:
- Thin blocks (e.g. 128 × 128 × 1) can display high resolution text and other 2D images.
- Multi-block structures can be defined using
Modifier::Zoom; their total size is limited by the resolution limit.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
Source§impl Resolution
impl Resolution
Sourcepub const MAX: Resolution = Resolution::R128
pub const MAX: Resolution = Resolution::R128
The maximum available resolution.
Sourcepub const fn double(self) -> Option<Resolution>
pub const fn double(self) -> Option<Resolution>
Returns the Resolution that’s twice this one, or None at the limit.
Sourcepub const fn halve(self) -> Option<Resolution>
pub const fn halve(self) -> Option<Resolution>
Returns the Resolution that’s half this one, or None if self is
R1.
Sourcepub const fn log2(self) -> u8
pub const fn log2(self) -> u8
Returns the logarithm base 2 of this resolution.
This is always an exact integer value; all resolutions are powers of 2.
§Example
assert_eq!(Resolution::R1.log2(), 0);
assert_eq!(Resolution::R16.log2(), 4);Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Resolution
impl<'arbitrary> Arbitrary<'arbitrary> for Resolution
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Resolution, Error>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Resolution, Error>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Resolution, Error>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Resolution, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for Resolution
impl Clone for Resolution
Source§fn clone(&self) -> Resolution
fn clone(&self) -> Resolution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Resolution
impl Debug for Resolution
Source§impl<'de> Deserialize<'de> for Resolution
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Resolution
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Resolution, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Resolution, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for Resolution
impl Display for Resolution
Source§impl Div for Resolution
impl Div for Resolution
Source§type Output = Option<Resolution>
type Output = Option<Resolution>
/ operator.Source§fn div(self, rhs: Resolution) -> <Resolution as Div>::Output
fn div(self, rhs: Resolution) -> <Resolution as Div>::Output
/ operation. Read moreSource§impl Exhaust for Resolution
impl Exhaust for Resolution
Source§type Iter = ExhaustResolutionIter
type Iter = ExhaustResolutionIter
Self::exhaust_factories().
See the trait documentation for what properties this iterator should have. Read moreSource§fn exhaust_factories() -> <Resolution as Exhaust>::Iter
fn exhaust_factories() -> <Resolution as Exhaust>::Iter
Source§fn from_factory(factory: <Resolution as Exhaust>::Factory) -> Resolution
fn from_factory(factory: <Resolution as Exhaust>::Factory) -> Resolution
Self::Factory value produced by
its Self::Iter. Read moreSource§impl Hash for Resolution
impl Hash for Resolution
Source§impl Mul for Resolution
impl Mul for Resolution
Source§type Output = Option<Resolution>
type Output = Option<Resolution>
* operator.Source§fn mul(self, rhs: Resolution) -> <Resolution as Mul>::Output
fn mul(self, rhs: Resolution) -> <Resolution as Mul>::Output
* operation. Read moreSource§impl Ord for Resolution
impl Ord for Resolution
Source§fn cmp(&self, other: &Resolution) -> Ordering
fn cmp(&self, other: &Resolution) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Resolution
impl PartialEq for Resolution
Source§impl PartialOrd for Resolution
impl PartialOrd for Resolution
Source§impl Serialize for Resolution
Available on crate feature serde only.
impl Serialize for Resolution
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl TryFrom<i128> for Resolution
impl TryFrom<i128> for Resolution
Source§type Error = IntoResolutionError<i128>
type Error = IntoResolutionError<i128>
Source§fn try_from(
value: i128,
) -> Result<Resolution, <Resolution as TryFrom<i128>>::Error>
fn try_from( value: i128, ) -> Result<Resolution, <Resolution as TryFrom<i128>>::Error>
Source§impl TryFrom<i16> for Resolution
impl TryFrom<i16> for Resolution
Source§type Error = IntoResolutionError<i16>
type Error = IntoResolutionError<i16>
Source§fn try_from(
value: i16,
) -> Result<Resolution, <Resolution as TryFrom<i16>>::Error>
fn try_from( value: i16, ) -> Result<Resolution, <Resolution as TryFrom<i16>>::Error>
Source§impl TryFrom<i32> for Resolution
impl TryFrom<i32> for Resolution
Source§type Error = IntoResolutionError<i32>
type Error = IntoResolutionError<i32>
Source§fn try_from(
value: i32,
) -> Result<Resolution, <Resolution as TryFrom<i32>>::Error>
fn try_from( value: i32, ) -> Result<Resolution, <Resolution as TryFrom<i32>>::Error>
Source§impl TryFrom<i64> for Resolution
impl TryFrom<i64> for Resolution
Source§type Error = IntoResolutionError<i64>
type Error = IntoResolutionError<i64>
Source§fn try_from(
value: i64,
) -> Result<Resolution, <Resolution as TryFrom<i64>>::Error>
fn try_from( value: i64, ) -> Result<Resolution, <Resolution as TryFrom<i64>>::Error>
Source§impl TryFrom<isize> for Resolution
impl TryFrom<isize> for Resolution
Source§type Error = IntoResolutionError<isize>
type Error = IntoResolutionError<isize>
Source§fn try_from(
value: isize,
) -> Result<Resolution, <Resolution as TryFrom<isize>>::Error>
fn try_from( value: isize, ) -> Result<Resolution, <Resolution as TryFrom<isize>>::Error>
Source§impl TryFrom<u128> for Resolution
impl TryFrom<u128> for Resolution
Source§type Error = IntoResolutionError<u128>
type Error = IntoResolutionError<u128>
Source§fn try_from(
value: u128,
) -> Result<Resolution, <Resolution as TryFrom<u128>>::Error>
fn try_from( value: u128, ) -> Result<Resolution, <Resolution as TryFrom<u128>>::Error>
Source§impl TryFrom<u16> for Resolution
impl TryFrom<u16> for Resolution
Source§type Error = IntoResolutionError<u16>
type Error = IntoResolutionError<u16>
Source§fn try_from(
value: u16,
) -> Result<Resolution, <Resolution as TryFrom<u16>>::Error>
fn try_from( value: u16, ) -> Result<Resolution, <Resolution as TryFrom<u16>>::Error>
Source§impl TryFrom<u32> for Resolution
impl TryFrom<u32> for Resolution
Source§type Error = IntoResolutionError<u32>
type Error = IntoResolutionError<u32>
Source§fn try_from(
value: u32,
) -> Result<Resolution, <Resolution as TryFrom<u32>>::Error>
fn try_from( value: u32, ) -> Result<Resolution, <Resolution as TryFrom<u32>>::Error>
Source§impl TryFrom<u64> for Resolution
impl TryFrom<u64> for Resolution
Source§type Error = IntoResolutionError<u64>
type Error = IntoResolutionError<u64>
Source§fn try_from(
value: u64,
) -> Result<Resolution, <Resolution as TryFrom<u64>>::Error>
fn try_from( value: u64, ) -> Result<Resolution, <Resolution as TryFrom<u64>>::Error>
Source§impl TryFrom<usize> for Resolution
impl TryFrom<usize> for Resolution
Source§type Error = IntoResolutionError<usize>
type Error = IntoResolutionError<usize>
Source§fn try_from(
value: usize,
) -> Result<Resolution, <Resolution as TryFrom<usize>>::Error>
fn try_from( value: usize, ) -> Result<Resolution, <Resolution as TryFrom<usize>>::Error>
impl Copy for Resolution
impl Eq for Resolution
impl StructuralPartialEq for Resolution
Auto Trait Implementations§
impl Freeze for Resolution
impl RefUnwindSafe for Resolution
impl Send for Resolution
impl Sync for Resolution
impl Unpin for Resolution
impl UnwindSafe for Resolution
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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 more