[−][src]Struct density_mesh_core::live::LiveDensityMesh
Density mesh with support for interactive region changes. This struct allows you to make changes without splitting mesh into chunks. Best for real-time applications.
Examples
use density_mesh_core::prelude::*; let map = DensityMap::new(2, 4, 1, vec![255; 8]).unwrap(); let settings = GenerateDensityMeshSettings { points_separation: 0.5.into(), steepness_threshold: 0.0, keep_invisible_triangles: true, ..Default::default() }; // create live density mesh. let mut live = LiveDensityMesh::new(map, settings.clone()); // perform initial processing. live.process_wait().unwrap(); // apply new data to inner density map region. live.change_map(0, 2, 2, 2, vec![0; 4], settings); // process changes. live.process_wait().unwrap(); assert_eq!(live.map().values(), &[1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]); assert_eq!(live.mesh().unwrap(), &DensityMesh { points: vec![ Coord { x: 1.0, y: 0.0 }, Coord { x: 0.0, y: 0.0 }, Coord { x: 1.0, y: 2.0 }, Coord { x: 0.0, y: 2.0 }, Coord { x: 1.0, y: 1.0 }, Coord { x: 0.0, y: 1.0 }, Coord { x: 0.0, y: 3.0 }, Coord { x: 1.0, y: 3.0 }, Coord { x: 1.0, y: 2.0 }, Coord { x: 0.0, y: 2.0 }, ], triangles: vec![ Triangle { a: 2, b: 4, c: 3 }, Triangle { a: 4, b: 5, c: 3 }, Triangle { a: 4, b: 0, c: 5 }, Triangle { a: 0, b: 1, c: 5 }, Triangle { a: 6, b: 7, c: 8 }, Triangle { a: 8, b: 9, c: 6 }, ], });
Implementations
impl LiveDensityMesh[src]
pub fn new(map: DensityMap, settings: GenerateDensityMeshSettings) -> Self[src]
Create new live density mesh instance.
Arguments
map- Density map.settings- Density mesh generation settings.
Returns
Live density mesh instance.
pub fn map(&self) -> &DensityMap[src]
Get inner density map.
pub fn mesh(&self) -> Option<&DensityMesh>[src]
Get inner density mesh if one is already generated.
pub fn in_progress(&self) -> bool[src]
Tells if there are changes left to process.
pub fn change_map(
&mut self,
col: usize,
row: usize,
width: usize,
height: usize,
data: Vec<u8>,
settings: GenerateDensityMeshSettings
) -> Result<(), DensityMapError>[src]
&mut self,
col: usize,
row: usize,
width: usize,
height: usize,
data: Vec<u8>,
settings: GenerateDensityMeshSettings
) -> Result<(), DensityMapError>
Process pending changes.
Arguments
col- Density map destination column.row- Density map destination row.width- Source data unscaled width.height- Source data unscaled height.data- Source data buffer.settings- Density mesh generation settings applied for this change.
Returns
Ok if successful or density map error.
pub fn process(&mut self) -> Result<LiveProcessStatus, GenerateDensityMeshError>[src]
Process all pending changes to internal mesh.
Returns
Result with process status (Ok), or density mesh generation error.
pub fn process_wait(&mut self) -> Result<(), GenerateDensityMeshError>[src]
Process all pending changes to internal mesh until it's done.
Returns
Ok when done, or density mesh generation error.
Trait Implementations
impl Clone for LiveDensityMesh[src]
fn clone(&self) -> LiveDensityMesh[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for LiveDensityMesh[src]
impl<'de> Deserialize<'de> for LiveDensityMesh[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PartialEq<LiveDensityMesh> for LiveDensityMesh[src]
fn eq(&self, other: &LiveDensityMesh) -> bool[src]
fn ne(&self, other: &LiveDensityMesh) -> bool[src]
impl Serialize for LiveDensityMesh[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralPartialEq for LiveDensityMesh[src]
Auto Trait Implementations
impl RefUnwindSafe for LiveDensityMesh
impl Send for LiveDensityMesh
impl Sync for LiveDensityMesh
impl Unpin for LiveDensityMesh
impl UnwindSafe for LiveDensityMesh
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,