### Create New GenericMeshBuilder Instance Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Instantiates a new GenericMeshBuilder. This is the starting point for building a mesh. ```rust pub fn new() -> Self ``` -------------------------------- ### Define Blocks for Extraction Source: https://docs.rs/transvoxel/2.0.0/transvoxel/index.html Setup of blocks with specific resolutions and positions for mesh extraction. ```rust use transvoxel::prelude::*; let b1 = Block::new([0.0, 0.0, 0.0], 10.0, 16); let b2 = Block::new([10.0, 0.0, 0.0], 10.0, 32); // Or b2 = b1.high_res_neighbour_to(HighX); ``` -------------------------------- ### Inspect Mesh Structure Source: https://docs.rs/transvoxel/2.0.0/transvoxel/index.html Example of the mesh data structure returned by the GenericMeshBuilder, containing positions, normals, and triangle indices. ```rust Extracted mesh: Mesh { positions: [ 10.0, 5.0, 0.0, 0.0, 5.0, 0.0, 0.0, 5.0, 10.0, 10.0, 5.0, 10.0, ], normals: [ -0.0, 1.0, -0.0, -0.0, 1.0, -0.0, -0.0, 1.0, -0.0, -0.0, 1.0, -0.0, ], triangle_indices: [ 0, 1, 2, 0, 2, 3, ], } ``` -------------------------------- ### Get All Transition Sides Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Returns a set containing all six TransitionSide values. Use this when transition cells are needed for all faces. ```rust pub fn all() -> TransitionSides ``` -------------------------------- ### Mesh num_tris Method Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Mesh.html Provides a shorthand to get the total number of triangles stored in the mesh. This is a utility method for quick access to triangle count. ```rust pub fn num_tris(&self) -> usize ``` -------------------------------- ### Get Empty Set of Transition Sides Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Returns an empty set of TransitionSide values. Use this when no transition cells are needed for any face. ```rust pub fn none() -> TransitionSides ``` -------------------------------- ### Construct Block Instances Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block/struct.Block.html Demonstrates manual struct initialization and the use of the new constructor. ```rust use transvoxel::prelude::*; // Just meant to be constructed and passed around let a_block = Block { base: [10.0, 20.0, 30.0], size: 10.0, subdivisions: 8, }; let another_block = Block::new([10.0, 20.0, 30.0], 10.0, 8); ``` -------------------------------- ### Get TypeId of Self Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Gets the `TypeId` of the current type. This is part of the `Any` trait implementation. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Configure Transition Sides Source: https://docs.rs/transvoxel/2.0.0/transvoxel/index.html Demonstrates building a set of transition sides incrementally using the FlagSet crate. ```rust use transvoxel::structs::transition_sides::TransitionSide; // If you don't hardcode sides like in the example above, you can build a set of sides incrementally: // They use the FlagSet crate let mut sides = TransitionSide::none(); sides |= TransitionSide::LowX; sides |= TransitionSide::HighY; assert!(sides.contains(TransitionSide::LowX)); assert!(!sides.contains(TransitionSide::HighX)); ``` -------------------------------- ### Extracting a mesh with Transvoxel Source: https://docs.rs/transvoxel/2.0.0/transvoxel/index.html Demonstrates defining a density function, configuring block parameters, and performing mesh extraction with and without transition faces. ```rust fn sphere_density(x: f32, y: f32, z: f32) -> f32 { 1f32 - (x * x + y * y + z * z).sqrt() / 5f32 } let threshold = 0f32; use transvoxel::prelude::*; let subdivisions = 10; let block = Block::new([0.0, 0.0, 0.0], 10.0, subdivisions); let transition_sides = TransitionSide::none(); let builder = GenericMeshBuilder::new(); let builder = extract_from_field( &sphere_density, FieldCaching::CacheNothing, block, transition_sides, threshold, builder ); let mesh = builder.build(); assert!(mesh.tris().len() == 103); use TransitionSide::LowX; let builder = GenericMeshBuilder::new(); let builder = extract_from_field( &sphere_density, FieldCaching::CacheNothing, block, LowX.into(), threshold, builder ); let mesh = builder.build(); assert!(mesh.tris().len() == 131); use TransitionSide::HighZ; let builder = GenericMeshBuilder::new(); let builder = extract_from_field( &sphere_density, FieldCaching::CacheNothing, block, HighZ.into(), threshold, builder ); let mesh = builder.build(); assert!(mesh.tris().len() == 103); ``` -------------------------------- ### FlagSet Default Creation Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Creates a new, empty FlagSet instance. ```APIDOC ## fn default() ### Description Creates a new, empty FlagSet. ### Request Example ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u8 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let set = FlagSet::::default(); ``` ``` -------------------------------- ### Transvoxel Modules Overview Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/index.html Overview of the core modules available in the Transvoxel library. ```APIDOC ## Transvoxel Modules ### Description The Transvoxel library is organized into several key modules that define the structure and behavior of voxel data and mesh generation. ### Modules - **coordinate**: Traits for world coordinates. - **data_field**: Trait for accessing world data. - **mesh_builder**: Trait used to customize mesh generation. - **voxel_block**: Trait defining a voxel block. - **voxel_data**: Traits for defining voxel data and density. ``` -------------------------------- ### Implement BlockStarView Methods Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/struct.BlockStarView.html Provides implementations for accessing central blocks, transition sides, and neighbors within the BlockStarView. ```rust pub fn central(&self) -> &CentralBlock ``` ```rust pub fn transition_sides(&self) -> &TransitionSides ``` ```rust pub fn neighbour_at(&self, side: TransitionSide) -> &DenserNeighbourBlock ``` -------------------------------- ### Get Raw Bits of a FlagSet Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Retrieves the underlying raw bit representation of a FlagSet. This is useful for debugging or when interacting with systems that expect raw bitmasks. ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u16 { Foo = 0b0001, Bar = 0b0010, Baz = 0b0100, } } let set = Flag::Foo | Flag::Baz; assert_eq!(set.bits(), 0b0101u16); ``` -------------------------------- ### Create Simple BlockStarView Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/struct.BlockStarView.html Constructs a simple BlockStarView with only a central block, useful when no neighbors are immediately needed. ```rust pub fn new_simple(central: B1) -> Self ``` -------------------------------- ### impl Density for f64: HALF Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/voxel_data/trait.Density.html The half value (0.5) for f64. ```rust const HALF: Self = 0.5f64; ``` -------------------------------- ### Convert Option to FlagSet Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Demonstrates using the From trait to convert an Option into a FlagSet, allowing None to represent an empty set. ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u8 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } fn convert(v: impl Into>) -> u8 { v.into().bits() } assert_eq!(convert(Flag::Foo | Flag::Bar), 0b011); assert_eq!(convert(Flag::Foo), 0b001); assert_eq!(convert(None), 0b000); ``` -------------------------------- ### BlockStarView Implementations Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/struct.BlockStarView.html Various implementations for the BlockStarView struct, including methods for accessing data and creating new instances. ```APIDOC ## Implementations for BlockStarView ### impl, DenserNeighbourBlock: VoxelBlock> BlockStarView #### `central(&self) -> &CentralBlock` Returns a reference to the central block. #### `transition_sides(&self) -> &TransitionSides` Returns a reference to the transition sides information. #### `neighbour_at(&self, side: TransitionSide) -> &DenserNeighbourBlock` Returns a reference to the neighbor block at the specified side. ### impl<'a, C: Coordinate, V: VoxelData> BlockStarView, VoxelBlockRelayingToField<'a, C, V>> #### `new_relaying_to_field(field: &'a dyn DataField, block: Block, transition_sides: &TransitionSides) -> BlockStarView, VoxelBlockRelayingToField<'a, C, V>>` Creates a new `BlockStarView` that relays data from a `DataField`. ### impl, B2: VoxelBlock> BlockStarView #### `new_simple(central: B1) -> Self` Creates a new `BlockStarView` with only the central block. #### `with_neighbour(self, neighbour: B2, side: TransitionSide) -> Self` Adds a neighbor block to the `BlockStarView` for a specific side. ``` -------------------------------- ### Implement CloneToUninit trait (Nightly) Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Nightly-only experimental API for performing copy-assignment to uninitialized memory. Requires T to implement Clone. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Structs Source: https://docs.rs/transvoxel/2.0.0/transvoxel/all.html Details on the data structures used within the transvoxel crate. ```APIDOC ## Structs ### `structs::block::Block` Represents a block of voxel data. ### `structs::block_star_view::BlockStarView` Represents a view of a block in a star configuration. ### `structs::generic_mesh::GenericMeshBuilder` A builder for creating generic meshes. ### `structs::generic_mesh::Mesh` Represents a generated mesh. ### `structs::generic_mesh::Triangle` Represents a triangle in the mesh. ### `structs::generic_mesh::Vertex` Represents a vertex in the mesh. ### `structs::grid_point::GridPoint` Represents a point in the 3D grid. ### `structs::position::OutputPosition` Represents the output position of a voxel. ### `structs::position::SamplingPosition` Represents the sampling position for voxel data. ### `structs::vertex_index::VertexIndex` An index for vertices. ### `structs::voxel_blocks::VoxelBlockRelayingToField` A voxel block that relays data to a field. ### `structs::voxel_blocks::VoxelVecBlock` A vector-based voxel block. ### `structs::voxel_index::VoxelIndex` An index for voxels. ``` -------------------------------- ### Transvoxel Module Overview Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/index.html Overview of the primary modules available in the transvoxel crate for voxel data manipulation. ```APIDOC ## Module Overview ### Description The transvoxel crate provides structures for voxel-based terrain generation and mesh extraction. ### Modules - **block**: Defines the core Block structure. - **block_star_view**: Provides a view on a main VoxelBlock and its neighbors at higher resolution. - **generic_mesh**: Engine-independent implementation of a Mesh and MeshBuilder. - **grid_point**: Defines the Grid point struct. - **position**: Contains structs for world position. - **transition_sides**: Enum defining the 6 sides of a block for double-resolution extraction. - **vertex_index**: Newtype for vertex indexing. - **voxel_blocks**: Implementations of various VoxelBlock types. - **voxel_index**: Structs for addressing discrete voxels and cells within the grid. ``` -------------------------------- ### Functions Source: https://docs.rs/transvoxel/2.0.0/transvoxel/all.html Utility functions available in the transvoxel crate. ```APIDOC ## Functions ### `extraction::extract` Extracts mesh data. ### `extraction::extract_from_field` Extracts mesh data from a field. ### `private::_internal_high_res_voxel_index_to_position` Internal function to convert high-resolution voxel index to position. ### `structs::block::shrink_if_needed` Shrinks a block if necessary. ``` -------------------------------- ### Vertex Trait Implementations Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Details the various trait implementations for the Vertex struct, including Clone, Debug, PartialEq, Copy, and others. ```APIDOC ## Vertex Trait Implementations ### `impl Clone for Vertex` where `F: Float + Clone` - `fn clone(&self) -> Vertex`: Returns a duplicate of the value. - `fn clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. ### `impl Debug for Vertex` where `F: Float + Debug` - `fn fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. ### `impl PartialEq for Vertex` where `F: Float + PartialEq` - `fn eq(&self, other: &Vertex) -> bool`: Tests for `self` and `other` values to be equal. - `fn ne(&self, other: &Rhs) -> bool`: Tests for `!=`. ### `impl Copy for Vertex` where `F: Float + Copy` ### Auto Trait Implementations - `Freeze` - `RefUnwindSafe` - `Send` - `Sync` - `Unpin` - `UnwindSafe` ### Blanket Implementations - `Any` - `Borrow` - `BorrowMut` - `CloneToUninit` (Nightly-only experimental API) - `From` - `Into` - `ToOwned` - `TryFrom` - `TryInto` ``` -------------------------------- ### impl Density for f32: HALF Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/voxel_data/trait.Density.html The half value (0.5) for f32. ```rust const HALF: Self = 0.5f32; ``` -------------------------------- ### impl Density for f64: ZERO Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/voxel_data/trait.Density.html The zero value (0) for f64. ```rust const ZERO: Self = 0f64; ``` -------------------------------- ### Implement Any trait Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Provides runtime type information for any type T that implements the 'static trait. ```rust impl Any for T where T: 'static + ?Sized, { fn type_id(&self) -> TypeId } ``` -------------------------------- ### BlockStarView Struct Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/index.html Documentation for the BlockStarView struct within the transvoxel::structs module. ```APIDOC ## Struct: BlockStarView ### Description A view on a central VoxelBlock and up to 6 of its neighbours, having double the resolution of the central block. ### Module transvoxel::structs::block_star_view ``` -------------------------------- ### Create a default FlagSet Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Initializes an empty FlagSet using the Default trait. ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u8 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let set = FlagSet::::default(); assert!(set.is_empty()); assert!(!set.is_full()); assert!(!set.contains(Flag::Foo)); assert!(!set.contains(Flag::Bar)); assert!(!set.contains(Flag::Baz)); ``` -------------------------------- ### Block Struct API Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block/struct.Block.html API documentation for the Block struct and its associated methods for voxel grid management. ```APIDOC ## Struct: Block ### Description A Block represents a cubic region of the world with an attached number of subdivisions for extraction. With n subdivisions, the block contains n^3 cells, encompassing n + 1 voxels across each dimension. ### Fields - **base** ([C; 3]) - The lowest x, y, z point of the block. - **size** (C) - The side length of the cube. - **subdivisions** (usize) - The number of subdivisions. ### Methods - **new(base: [C; 3], size: C, subdivisions: usize) -> Self** Creates a new Block instance. - **high_res_neighbour_to(&self, side: TransitionSide) -> Self** Returns the high-resolution neighbor block for a given transition side. - **original_voxel_position(&self, index: RegularVoxelIndex) -> SamplingPosition** Calculates the position of a given voxel on the original regular grid. - **morphed_voxel_position(&self, index: RegularVoxelIndex, transition_sides: &TransitionSides) -> OutputPosition** Calculates the position of a given voxel after potential shrinking for output purposes. ``` -------------------------------- ### Trait Implementations Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Implementations of standard traits for FlagSet. ```APIDOC ### impl AsRef<::Type> for FlagSet #### fn as_ref(&self) -> &::Type Converts this type into a shared reference of the (usually inferred) input type. ``` ```APIDOC ### impl BitAnd for FlagSet #### fn bitand(self, rhs: R) -> FlagSet Calculates the intersection of the current set and the specified flags. #### type Output = FlagSet The resulting type after applying the `&` operator. ### Example ```rust use flagset::{FlagSet, flags}; flags! { #[derive(PartialOrd, Ord)] pub enum Flag: u8 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let set0 = Flag::Foo | Flag::Bar; let set1 = Flag::Baz | Flag::Bar; assert_eq!(set0 & set1, Flag::Bar); assert_eq!(set0 & Flag::Foo, Flag::Foo); assert_eq!(set1 & Flag::Baz, Flag::Baz); ``` ``` ```APIDOC ### impl BitAndAssign for FlagSet #### fn bitand_assign(&mut self, rhs: R) Assigns the intersection of the current set and the specified flags. ### Example ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u64 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let mut set0 = Flag::Foo | Flag::Bar; let mut set1 = Flag::Baz | Flag::Bar; set0 &= set1; assert_eq!(set0, Flag::Bar); set1 &= Flag::Baz; assert_eq!(set0, Flag::Bar); ``` ``` ```APIDOC ### impl BitOr for FlagSet #### fn bitor(self, rhs: R) -> FlagSet Calculates the union of the current set with the specified flags. #### type Output = FlagSet The resulting type after applying the `|` operator. ### Example ```rust use flagset::{FlagSet, flags}; flags! { #[derive(PartialOrd, Ord)] pub enum Flag: u8 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let set0 = Flag::Foo | Flag::Bar; let set1 = Flag::Baz | Flag::Bar; assert_eq!(set0 | set1, FlagSet::full()); ``` ``` ```APIDOC ### impl BitOrAssign for FlagSet #### fn bitor_assign(&mut self, rhs: R) Assigns the union of the current set with the specified flags. ### Example ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u64 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let mut set0 = Flag::Foo | Flag::Bar; let mut set1 = Flag::Bar | Flag::Baz; set0 |= set1; assert_eq!(set0, FlagSet::full()); set1 |= Flag::Baz; assert_eq!(set1, Flag::Bar | Flag::Baz); ``` ``` ```APIDOC ### impl BitXor for FlagSet #### fn bitxor(self, rhs: R) -> FlagSet Calculates the current set with the specified flags toggled. This is commonly known as toggling the presence. #### type Output = FlagSet The resulting type after applying the `^` operator. ### Example ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u32 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let set0 = Flag::Foo | Flag::Bar; let set1 = Flag::Baz | Flag::Bar; assert_eq!(set0 ^ set1, Flag::Foo | Flag::Baz); assert_eq!(set0 ^ Flag::Foo, Flag::Bar); ``` ``` ```APIDOC ### impl BitXorAssign for FlagSet #### fn bitxor_assign(&mut self, rhs: R) Assigns the current set with the specified flags toggled. ### Example ```rust use flagset::{FlagSet, flags}; flags! { enum Flag: u16 { Foo = 0b001, Bar = 0b010, Baz = 0b100 } } let mut set0 = Flag::Foo | Flag::Bar; let mut set1 = Flag::Baz | Flag::Bar; set0 ^= set1; assert_eq!(set0, Flag::Foo | Flag::Baz); set1 ^= Flag::Baz; assert_eq!(set1, Flag::Bar); ``` ``` ```APIDOC ### impl Clone for FlagSet #### fn clone(&self) -> FlagSet Returns a duplicate of the value. Read more ``` -------------------------------- ### Enums Source: https://docs.rs/transvoxel/2.0.0/transvoxel/all.html Enumerations used in the transvoxel crate. ```APIDOC ## Enums ### `extraction::FieldCaching` Defines caching behavior for fields. ### `structs::transition_sides::TransitionSide` Represents the sides of a transition in voxel data. ``` -------------------------------- ### BlockStarView Blanket Implementations Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/struct.BlockStarView.html Details on blanket implementations available for the BlockStarView struct. ```APIDOC ## Blanket Implementations for BlockStarView ### `Any` Implemented for any type `T` that is `'static + ?Sized`. #### `type_id(&self) -> TypeId` Gets the `TypeId` of `self`. ### `Borrow` Implemented for any type `T` where `T: ?Sized`. #### `borrow(&self) -> &T` Immutably borrows from an owned value. ### `BorrowMut` Implemented for any type `T` where `T: ?Sized`. #### `borrow_mut(&mut self) -> &mut T` Mutably borrows from an owned value. ### `From` Implemented for any type `T`. #### `from(t: T) -> T` Returns the argument unchanged. ### `Into` Implemented for any type `T` where `U: From`. #### `into(self) -> U` Calls `U::from(self)`. ### `TryFrom` Implemented for any type `T` where `U: Into`. #### `type Error = Infallible` The type returned in the event of a conversion error. #### `try_from(value: U) -> Result>::Error>` Performs the conversion. ### `TryInto` Implemented for any type `T` where `U: TryFrom`. #### `type Error = >::Error` The type returned in the event of a conversion error. #### `try_into(self) -> Result>::Error>` Performs the conversion. ``` -------------------------------- ### Build Mesh from GenericMeshBuilder Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Finalizes the mesh construction process and returns the resulting Mesh. This consumes the builder. ```rust pub fn build(self) -> Mesh ``` -------------------------------- ### Clone Trait Implementation Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Documentation for the clone_into method used for replacing owned data with borrowed data. ```APIDOC ## fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. ### Parameters - **target** (&mut T) - Required - The mutable reference to the target object to be replaced. ``` -------------------------------- ### Extract iso-surface mesh Source: https://docs.rs/transvoxel/2.0.0/transvoxel/extraction/fn.extract.html Uses a BlockStarView to generate a mesh based on a density threshold. The mesh_builder is returned after processing. ```rust pub fn extract( blocks: &BlockStarView, threshold: V::Density, mesh_builder: M, ) -> M where C: Coordinate, V: VoxelData, B1: VoxelBlock, B2: VoxelBlock, M: MeshBuilder, ``` -------------------------------- ### Implement PartialEq for Vertex Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Allows comparison for equality between Vertex instances. Requires the F type to implement the PartialEq trait. ```rust impl PartialEq for Vertex where F: Float + PartialEq, { fn eq(&self, other: &Vertex) -> bool } ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### FlagSet Methods Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Methods for manipulating the FlagSet. ```APIDOC ## clear ### Description Removes all flags from the FlagSet. ### Method `clear(&mut self)` ### Example ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u8 { Foo = 1, Bar = 2, Baz = 4 } } let mut set = Flag::Foo | Flag::Bar; assert!(!set.is_empty()); set.clear(); assert!(set.is_empty()); ``` ``` ```APIDOC ## drain ### Description Clears the current set and returns an iterator of all removed flags. ### Method `drain(&mut self) -> Iter` ### Example ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u8 { Foo = 1, Bar = 2, Baz = 4 } } let mut set = Flag::Foo | Flag::Bar; let mut iter = set.drain(); assert!(set.is_empty()); assert_eq!(iter.next(), Some(Flag::Foo)); assert_eq!(iter.next(), Some(Flag::Bar)); assert_eq!(iter.next(), None); ``` ``` ```APIDOC ## retain ### Description Retain only the flags specified by the predicate. ### Method `retain(&mut self, func: impl Fn(F) -> bool)` ### Example ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u8 { Foo = 1, Bar = 2, Baz = 4 } } let mut set0 = Flag::Foo | Flag::Bar; set0.retain(|f| f != Flag::Foo); assert_eq!(set0, Flag::Bar); ``` ``` -------------------------------- ### impl Density for f32: ZERO Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/voxel_data/trait.Density.html The zero value (0) for f32. ```rust const ZERO: Self = 0f32; ``` -------------------------------- ### Main Mesh Extraction Functions Source: https://docs.rs/transvoxel/2.0.0/transvoxel/extraction/index.html Provides details on the primary functions for extracting iso-surface meshes using the transvoxel library. ```APIDOC ## extract ### Description Extracts an iso-surface mesh. ### Method (Not specified, likely a function call within Rust code) ### Endpoint (Not applicable, this is a library function) ### Parameters (Not specified in the provided text) ### Request Example (Not applicable) ### Response (Not specified in the provided text) ## extract_from_field ### Description Extracts an iso-surface mesh for a DataField. ### Method (Not specified, likely a function call within Rust code) ### Endpoint (Not applicable, this is a library function) ### Parameters (Not specified in the provided text) ### Request Example (Not applicable) ### Response (Not specified in the provided text) ``` -------------------------------- ### Module generic_mesh Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/index.html Overview of the generic_mesh module which provides structures for building and representing meshes. ```APIDOC ## Module generic_mesh ### Description A generic (engine independent) implementation of a Mesh, and an associated MeshBuilder. ### Structs - **GenericMeshBuilder**: A MeshBuilder that builds a Mesh. - **Mesh**: The primary mesh structure. - **Triangle**: A triangle, mostly for debugging or test purposes. - **Vertex**: A vertex, mostly for debugging or test purposes. ``` -------------------------------- ### Implement DataField for References Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/data_field/trait.DataField.html Provides a DataField implementation for references to other DataField instances. This allows treating a reference to a data source as a data source itself. ```rust impl DataField for &dyn DataField { // Required method fn get_data(&self, x: C, y: C, z: C) -> V; } ``` -------------------------------- ### FlagSet Extend Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Adds values to the FlagSet by iterating over a collection. ```APIDOC ## fn extend(&mut self, iter: T) ### Description Add values by iterating over some collection. ### Request Example ```rust let flag_vec = vec![Flag::Bar, Flag::Baz]; let mut some_extended_flags = FlagSet::from(Flag::Foo); some_extended_flags.extend(flag_vec); ``` ``` -------------------------------- ### impl Density for f64: EPSILON Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/voxel_data/trait.Density.html The epsilon value for f64, used in floating-point comparisons. ```rust const EPSILON: Self = 2.2204460492503131E-16f64; ``` -------------------------------- ### BlockStarView Auto Trait Implementations Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/struct.BlockStarView.html Information about the auto trait implementations for the BlockStarView struct. ```APIDOC ## Auto Trait Implementations for BlockStarView ### `Freeze` Implemented if `CentralBlock` and `DenserNeighbourBlock` implement `Freeze`. ### `RefUnwindSafe` Implemented if `CentralBlock`, `V`, `C`, and `DenserNeighbourBlock` implement `RefUnwindSafe`. ### `Send` Implemented if `CentralBlock`, `V`, `C`, and `DenserNeighbourBlock` implement `Send`. ### `Sync` Implemented if `CentralBlock`, `V`, `C`, and `DenserNeighbourBlock` implement `Sync`. ### `Unpin` Implemented if `CentralBlock`, `V`, `C`, and `DenserNeighbourBlock` implement `Unpin`. ### `UnwindSafe` Implemented if `CentralBlock`, `V`, `C`, and `DenserNeighbourBlock` implement `UnwindSafe`. ``` -------------------------------- ### Implement Cached Density Extraction Source: https://docs.rs/transvoxel/2.0.0/transvoxel/index.html Uses VoxelVecBlock to cache density data and BlockStarView to perform efficient mesh extraction across multiple blocks. ```rust let density_function = |x, y, z| z; let threshold = 0.0; // Cache each block separately let cached_b1 = VoxelVecBlock::cache(&density_function, b1); let cached_b2 = VoxelVecBlock::cache(&density_function, b2); // Now just use views into the cached blocks, to reuse data across `extract` calls: // We use `&VoxelVecBlock` here. You can use anything that implements [VoxelBlock] type View<'a> = BlockStarView, &'a VoxelVecBlock>; let mesh1 = extract( &View::new_simple(&cached_b1).with_neighbour(&cached_b2, TransitionSide::HighX), threshold, GenericMeshBuilder::new() ).build(); let mesh2 = extract( &View::new_simple(&cached_b2), threshold, GenericMeshBuilder::new() ).build(); ``` -------------------------------- ### Try Convert U to T Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Performs the conversion from U to T. Returns a `Result` which is `Ok(T)` on success or `Err(Infallible)` on failure. ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Type Aliases Source: https://docs.rs/transvoxel/2.0.0/transvoxel/all.html Type aliases for convenience in the transvoxel crate. ```APIDOC ## Type Aliases ### `structs::transition_sides::TransitionSides` An alias for transition sides. ``` -------------------------------- ### Create a Full FlagSet Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Creates a new FlagSet containing all possible flags defined for the enum. Useful for operations that require a complete set. ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u8 { Foo = 1, Bar = 2, Baz = 4 } } let set = FlagSet::full(); assert!(!set.is_empty()); assert!(set.is_full()); assert!(set.contains(Flag::Foo)); assert!(set.contains(Flag::Bar)); assert!(set.contains(Flag::Baz)); ``` -------------------------------- ### TryInto Trait Implementation Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Documentation for fallible conversion of self into type U. ```APIDOC ## impl TryInto for T ### Description Performs a fallible conversion of self into type U. ### Associated Types - **Error** (>::Error) - The type returned in the event of a conversion error. ### Methods - **try_into(self) -> Result>::Error>** - Performs the conversion. ``` -------------------------------- ### Create BlockStarView by Relaying to Field Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/block_star_view/struct.BlockStarView.html Constructs a BlockStarView by relaying to a DataField, suitable for scenarios where data is accessed through an interface. ```rust pub fn new_relaying_to_field( field: &'a dyn DataField, block: Block, transition_sides: &TransitionSides, ) -> BlockStarView, VoxelBlockRelayingToField<'a, C, V>> ``` -------------------------------- ### OutputPosition Struct Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/position/struct.OutputPosition.html Represents a world space position with generic coordinate types. ```APIDOC ## Struct OutputPosition ### Description A world space position. ### Fields - **x** (C) - Description: X coordinate. - **y** (C) - Description: Y coordinate. - **z** (C) - Description: Z coordinate. ### Methods #### pub fn interpolate_toward(&self, other: &OutputPosition, factor: C) -> OutputPosition Interpolate between this `self` position and `other`, by the given `factor` (0 giving self, 1 giving other). ### Trait Implementations #### impl Add<&[C; 3]> for &OutputPosition - **Output**: OutputPosition - **add**: Performs the `+` operation. #### impl Mul for &OutputPosition - **Output**: OutputPosition - **mul**: Performs the `*` operation. #### impl PartialEq for OutputPosition - **eq**: Tests for `self` and `other` values to be equal. - **ne**: Tests for `!=`. #### impl Eq for OutputPosition #### impl Debug for OutputPosition - **fmt**: Formats the value using the given formatter. #### impl StructuralPartialEq for OutputPosition #### Auto Trait Implementations - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe #### Blanket Implementations - Any - Borrow - BorrowMut - From - Into - TryFrom - TryInto ``` -------------------------------- ### Try Convert T to U Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Performs the conversion from T to U. Returns a `Result` which is `Ok(U)` on success or `Err(>::Error)` on failure. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### FlagSet Operations Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Common methods available for FlagSet types, including creation, bit manipulation, and set comparison. ```APIDOC ## FlagSet Operations ### Methods - **new(bits)**: Creates a new set from bits; returns Err(InvalidBits) on invalid input. - **new_truncated(bits)**: Creates a new set from bits, truncating invalid or unknown bits. - **new_unchecked(bits)**: Unsafe constructor; assumes bits are valid. - **full()**: Returns a set containing all possible flags. - **bits()**: Returns the raw bit representation of the set. - **is_empty()**: Returns true if no flags are set. - **is_full()**: Returns true if all possible flags are set. - **is_disjoint(rhs)**: Checks if the set shares no flags with the provided set. - **contains(rhs)**: Checks if the set is a superset of the provided flags. ``` -------------------------------- ### Traits Source: https://docs.rs/transvoxel/2.0.0/transvoxel/all.html Traits defining core functionalities in the transvoxel crate. ```APIDOC ## Traits ### `traits::coordinate::Coordinate` Trait for coordinate systems. ### `traits::data_field::DataField` Trait for data fields. ### `traits::mesh_builder::MeshBuilder` Trait for mesh building operations. ### `traits::voxel_block::VoxelBlock` Trait for voxel block functionalities. ### `traits::voxel_data::Density` Trait for voxel density data. ### `traits::voxel_data::VoxelData` Trait for general voxel data. ``` -------------------------------- ### Unsafe Clone to Uninit for TransitionSide Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Performs copy-assignment from a TransitionSide to an uninitialized memory location. This is a nightly-only experimental API. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### TryFrom Trait Implementation Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Documentation for fallible conversion from type U to type T. ```APIDOC ## impl TryFrom for T ### Description Performs a fallible conversion from type U to type T. ### Associated Types - **Error** (Infallible) - The type returned in the event of a conversion error. ### Methods - **try_from(value: U) -> Result>::Error>** - Performs the conversion. ``` -------------------------------- ### Convert T to T (Identity) Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Returns the argument unchanged. This is the implementation for `From for T`. ```rust fn from(t: T) -> T ``` -------------------------------- ### GenericMeshBuilder Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Represents a builder for creating a Mesh. It provides methods to construct a mesh by adding vertices and triangles. ```APIDOC ## Struct GenericMeshBuilder ### Description A MeshBuilder that builds a Mesh. ### Fields (Private fields, not exposed) ### Methods #### pub fn new() -> Self Create a fresh builder. #### pub fn build(self) -> Mesh Output the Mesh. ``` -------------------------------- ### Implement From trait Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Provides a trivial conversion from a type T to itself. ```rust impl From for T { fn from(t: T) -> T } ``` -------------------------------- ### Coordinate::from_ratio Method Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/coordinate/trait.Coordinate.html Returns a value representing the ratio a / b. This method is part of the Coordinate trait. ```rust fn from_ratio(a: isize, b: usize) -> Self; ``` -------------------------------- ### impl Density for f32: EPSILON Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/voxel_data/trait.Density.html The epsilon value for f32, used in floating-point comparisons. ```rust const EPSILON: Self = 1.1920929E-7f32; ``` -------------------------------- ### Mesh tris Method Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Mesh.html Outputs a copy of the triangles in a structured format. This method is useful for iterating over triangles in a more convenient representation. ```rust pub fn tris(&self) -> Vec> ``` -------------------------------- ### Mesh Methods Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Mesh.html Utility methods available on the Mesh struct for retrieving mesh information. ```APIDOC ## Methods ### num_tris - **Description**: Returns the total count of triangles in the mesh. - **Return Type**: usize ### tris - **Description**: Returns a copy of the triangles in a structured format. - **Return Type**: Vec> ``` -------------------------------- ### Implement Clone for Vertex Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Provides cloning functionality for the Vertex struct. Requires the F type to implement both Float and Clone traits. ```rust impl Clone for Vertex where F: Float + Clone, { fn clone(&self) -> Vertex } ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### f64 Implementation of Coordinate Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/coordinate/trait.Coordinate.html Provides implementations for the Coordinate trait methods on the f64 type. ```rust impl Coordinate for f64 ``` -------------------------------- ### Create FlagSet from Bits with Validation Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Creates a new FlagSet from raw bits, returning an error if any bits are invalid or unknown. Use this when strict validation is required. ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u16 { Foo = 0b0001, Bar = 0b0010, Baz = 0b0100, Qux = 0b1010, // Implies Bar } } assert_eq!(FlagSet::::new(0b00101), Ok(Flag::Foo | Flag::Baz)); assert_eq!(FlagSet::::new(0b01101), Err(flagset::InvalidBits)); // Invalid assert_eq!(FlagSet::::new(0b10101), Err(flagset::InvalidBits)); // Unknown ``` -------------------------------- ### SamplingPosition Struct Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/position/struct.SamplingPosition.html Represents a world space position using generic coordinates. ```APIDOC ## Struct: SamplingPosition ### Description A world space position represented by x, y, and z coordinates. ### Fields - **x** (C) - The X coordinate. - **y** (C) - The Y coordinate. - **z** (C) - The Z coordinate. ### Definition ```rust pub struct SamplingPosition { pub x: C, pub y: C, pub z: C, } ``` ``` -------------------------------- ### TransitionSides Type Alias Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Demonstrates the usage of the TransitionSides type alias for creating and manipulating sets of TransitionSide flags. Supports empty sets, single flags, and incremental building. ```rust pub type TransitionSides = FlagSet; ``` ```rust // You can specify "no side" (empty set) let nothing = TransitionSide::none(); let nothing_either: TransitionSides = None.into(); // You can hardcode one side let one_side: TransitionSides = LowX.into(); // Or build a set incrementally let mut sides = TransitionSide::none(); sides |= TransitionSide::LowX; sides |= TransitionSide::HighY; assert!(sides.contains(TransitionSide::LowX)); assert!(!sides.contains(TransitionSide::HighX)); ``` -------------------------------- ### Implement StructuralPartialEq for Vertex Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Provides structural partial equality comparison for the Vertex struct. Requires the F type to implement the Float trait. ```rust impl StructuralPartialEq for Vertex where F: Float, ``` -------------------------------- ### Create FlagSet from Bits Unchecked Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/type.TransitionSides.html Creates a new FlagSet from raw bits without any validation. Use this with caution, as undefined behavior may result if invalid or unknown bits are provided. ```rust use flagset::{FlagSet, flags}; flags! { pub enum Flag: u16 { Foo = 0b0001, Bar = 0b0010, Baz = 0b0100, Qux = 0b1010, // Implies Bar } } // Unknown and invalid bits are retained. Behavior is undefined. const set: FlagSet = unsafe { FlagSet::::new_unchecked(0b11101) }; assert_eq!(set.bits(), 0b11101); ``` -------------------------------- ### MeshBuilder Trait Implementation for GenericMeshBuilder Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.GenericMeshBuilder.html Implementation of the MeshBuilder trait for GenericMeshBuilder, providing methods for adding vertices and triangles during mesh generation. ```APIDOC ### impl MeshBuilder for GenericMeshBuilder #### fn add_vertex_between( &mut self, point_a: GridPoint, point_b: GridPoint, interpolate_toward_b: f32, ) -> VertexIndex Called by the extraction algorithm when a new vertex it to be created between 2 grid points. #### fn add_triangle( &mut self, vertex_1_index: VertexIndex, vertex_2_index: VertexIndex, vertex_3_index: VertexIndex, ) Called by the extraction algorithm when a triangle is to be created, using 3 previously created vertices. ``` -------------------------------- ### add_triangle Method Source: https://docs.rs/transvoxel/2.0.0/transvoxel/traits/mesh_builder/trait.MeshBuilder.html Called when a triangle needs to be created using three previously added vertices. The indices of these vertices are provided as arguments. ```rust fn add_triangle( &mut self, vertex_1_index: VertexIndex, vertex_2_index: VertexIndex, vertex_3_index: VertexIndex, ); ``` -------------------------------- ### Implement Copy for Vertex Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/generic_mesh/struct.Vertex.html Enables the Vertex struct to be copied implicitly. Requires the F type to implement the Copy trait. ```rust impl Copy for Vertex where F: Float + Copy, ``` -------------------------------- ### Bitwise AND Operation for TransitionSide Source: https://docs.rs/transvoxel/2.0.0/transvoxel/structs/transition_sides/enum.TransitionSide.html Performs the bitwise AND operation between a TransitionSide and another type that can be converted into a FlagSet. The result is a FlagSet. ```rust fn bitand(self, rhs: R) -> Self::Output ```