Skip to main content

Mesher

Struct Mesher 

Source
pub struct Mesher<const CS: usize> {
    pub quads: [Vec<Quad>; 6],
    /* private fields */
}

Fields§

§quads: [Vec<Quad>; 6]

Implementations§

Source§

impl<const CS: usize> Mesher<CS>

Source

pub const CS_2: usize

Source

pub const CS_3: usize

Source

pub const CS_P: usize

Source

pub const CS_P2: usize

Source

pub const CS_P3: usize

Source

pub const P_MASK: u64

Source

pub fn new() -> Self

Creates a mesher object, allocates necessary buffers

Source

pub fn clear(&mut self)

Call this between each meshing call to reset the buffers without reallocating them

Source

pub fn fast_mesh( &mut self, voxels: &[u16], opaque_mask: &[u64], trans_mask: &[u64], )

Meshes a voxel buffer representing a chunk, using an opaque and transparent mask with 1 u64 per column with 1 bit per voxel in the column, signaling if the voxel is opaque or transparent. This is ~4x faster than the regular mesh method but requires maintaining 2 masks for each chunk. See https://github.com/Inspirateur/binary-greedy-meshing?tab=readme-ov-file#what-to-do-with-mesh_dataquads for using the output

Source

pub fn mesh(&mut self, voxels: &[u16], transparents: &BTreeSet<u16>)

Meshes a voxel buffer representing a chunk, using a BTreeSet signaling which voxel values are transparent. This is ~4x slower than the fast_mesh method but does not require maintaining 2 masks for each chunk. See https://github.com/Inspirateur/binary-greedy-meshing?tab=readme-ov-file#what-to-do-with-mesh_dataquads for using the output

Source

pub fn mesh_lod( &mut self, voxels: &mut [u16], transparents: &BTreeSet<u16>, lod: usize, max_voxel_value: Option<u16>, )

Same as mesh but with a level-of-detail controlled by the lod parameter. The LOD algorithm divides the chunk into cubic windows of size lod and selects the most common air-exposed voxel to fill that window.

You can save a O(n) check on voxels by providing the max_voxel_value if you already have it (due to palette compression or equivalent).

If lod is 1 (or 0), this is equivalent to calling mesh.

NB: you don’t need to use multiples of the chunk size for lod. Partial windows are handled properly.

Trait Implementations§

Source§

impl<const CS: usize> Debug for Mesher<CS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const CS: usize> Freeze for Mesher<CS>

§

impl<const CS: usize> RefUnwindSafe for Mesher<CS>

§

impl<const CS: usize> Send for Mesher<CS>

§

impl<const CS: usize> Sync for Mesher<CS>

§

impl<const CS: usize> Unpin for Mesher<CS>

§

impl<const CS: usize> UnsafeUnpin for Mesher<CS>

§

impl<const CS: usize> UnwindSafe for Mesher<CS>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.