diff --git a/crates/building_blocks_image/src/lib.rs b/crates/building_blocks_image/src/lib.rs index 8c07de3b..950a3910 100644 --- a/crates/building_blocks_image/src/lib.rs +++ b/crates/building_blocks_image/src/lib.rs @@ -22,13 +22,13 @@ where unsafe { map.assume_init() } } -pub fn encode_image( - map: &Meta, +pub fn encode_image( + map: &Map, map_extent: &Extent2i, ) -> ImageBuffer::Subpixel>> where T: Into

, - Meta: for<'a> Get<&'a Point2i, Data = T>, + Map: for<'a> Get<&'a Point2i, Data = T>, P: Pixel + 'static, { let img_extent = *map_extent - map_extent.minimum; diff --git a/crates/building_blocks_mesh/src/greedy_quads.rs b/crates/building_blocks_mesh/src/greedy_quads.rs index b09758d4..ba419a30 100644 --- a/crates/building_blocks_mesh/src/greedy_quads.rs +++ b/crates/building_blocks_mesh/src/greedy_quads.rs @@ -7,24 +7,24 @@ use building_blocks_core::{axis::Axis3Permutation, prelude::*}; use building_blocks_storage::{access::GetUncheckedRelease, prelude::*, IsEmpty}; /// Contains the output from the `greedy_quads` algorithm. Can be reused to avoid re-allocations. -pub struct GreedyQuadsBuffer { +pub struct GreedyQuadsBuffer { /// One group of quads per cube face. - pub quad_groups: [QuadGroup; 6], + pub quad_groups: [QuadGroup; 6], // A single array is used for the visited mask because it allows us to index by the same strides // as the voxels array. It also only requires a single allocation. visited: Array3, } -/// A set of `Quad`s that share an orientation. Each quad may specify a material of type `Meta`. -pub struct QuadGroup { +/// A set of `Quad`s that share an orientation. Each quad may specify a material of type `Material`. +pub struct QuadGroup { /// The quads themselves. We rely on the cube face metadata to interpret them. - pub quads: Vec<(UnorientedQuad, Meta)>, + pub quads: Vec<(UnorientedQuad, Material)>, /// One of 6 cube faces. All quads in this struct are comprised of only this face. pub face: OrientedCubeFace, } -impl QuadGroup { +impl QuadGroup { pub fn new(face: OrientedCubeFace) -> Self { Self { quads: Vec::new(), @@ -33,7 +33,7 @@ impl QuadGroup { } } -impl GreedyQuadsBuffer { +impl GreedyQuadsBuffer { pub fn new(extent: Extent3i) -> Self { let quad_groups = [ QuadGroup::new(OrientedCubeFace::new(-1, Axis3Permutation::XZY)), diff --git a/crates/building_blocks_mesh/src/surface_nets.rs b/crates/building_blocks_mesh/src/surface_nets.rs index 7dc6509e..52b76eb6 100644 --- a/crates/building_blocks_mesh/src/surface_nets.rs +++ b/crates/building_blocks_mesh/src/surface_nets.rs @@ -69,9 +69,9 @@ impl SurfaceNetsBuffer { /// /// The set of corners sampled is exactly the set of points in `extent`. `sdf` must contain all of /// those points. -pub fn surface_nets(sdf: &V, extent: &Extent3i, output: &mut SurfaceNetsBuffer) +pub fn surface_nets(sdf: &A, extent: &Extent3i, output: &mut SurfaceNetsBuffer) where - V: Array<[i32; 3]> + GetUncheckedRelease, + A: Array<[i32; 3]> + GetUncheckedRelease, T: SignedDistance, { output.reset(sdf.extent().num_points()); @@ -82,9 +82,9 @@ where // Find all vertex positions and normals. Also generate a map from grid position to vertex index // to be used to look up vertices when generating quads. -fn estimate_surface(sdf: &V, extent: &Extent3i, output: &mut SurfaceNetsBuffer) +fn estimate_surface(sdf: &A, extent: &Extent3i, output: &mut SurfaceNetsBuffer) where - V: Array<[i32; 3]> + GetUncheckedRelease, + A: Array<[i32; 3]> + GetUncheckedRelease, T: SignedDistance, { // Precalculate these offsets to do faster linear indexing. @@ -132,13 +132,13 @@ const CUBE_EDGES: [(usize, usize); 12] = [ // // This is done by estimating, for each cube edge, where the isosurface crosses the edge (if it // does at all). Then the estimated surface point is the average of these edge crossings. -fn estimate_surface_in_voxel( - sdf: &V, +fn estimate_surface_in_voxel( + sdf: &A, point: &Point3i, corner_strides: &[Stride], ) -> Option<([f32; 3], [f32; 3])> where - V: GetUncheckedRelease, + A: GetUncheckedRelease, T: SignedDistance, { // Get the signed distance values at each corner of this cube. @@ -216,9 +216,9 @@ fn estimate_surface_edge_intersection( // touching that surface. The "centers" are actually the vertex positions found earlier. Also, // make sure the triangles are facing the right way. See the comments on `maybe_make_quad` to help // with understanding the indexing. -fn make_all_quads(sdf: &V, extent: &Extent3i, output: &mut SurfaceNetsBuffer) +fn make_all_quads(sdf: &A, extent: &Extent3i, output: &mut SurfaceNetsBuffer) where - V: Array<[i32; 3]> + GetUncheckedRelease, + A: Array<[i32; 3]> + GetUncheckedRelease, T: SignedDistance, { let mut xyz_strides = [Stride(0); 3]; @@ -310,8 +310,8 @@ where // // then we must find the other 3 quad corners by moving along the other two axes (those orthogonal // to A) in the negative directions; these are axis B and axis C. -fn maybe_make_quad( - sdf: &V, +fn maybe_make_quad( + sdf: &A, stride_to_index: &[u32], positions: &[[f32; 3]], p1: Stride, @@ -320,7 +320,7 @@ fn maybe_make_quad( axis_c_stride: Stride, indices: &mut Vec, ) where - V: GetUncheckedRelease, + A: GetUncheckedRelease, T: SignedDistance, { let voxel1 = sdf.get_unchecked_release(p1); diff --git a/crates/building_blocks_search/src/surface.rs b/crates/building_blocks_search/src/surface.rs index 8dbd7fc0..8deec3b7 100644 --- a/crates/building_blocks_search/src/surface.rs +++ b/crates/building_blocks_search/src/surface.rs @@ -4,9 +4,12 @@ use building_blocks_storage::{access::GetUncheckedRelease, prelude::*, IsEmpty}; /// Returns the "surface points" i.e. those points that are non-empty and Von-Neumann-adjacent to an /// empty point. Since this algorithm does adjacency checks for all points in `extent`, you must /// ensure that those points are within the bounds of `map`. -pub fn find_surface_points(map: &Meta, extent: &ExtentN) -> (Vec>, Vec) +pub fn find_surface_points( + map: &Map, + extent: &ExtentN, +) -> (Vec>, Vec) where - Meta: Array + ForEach, Stride), Data = T> + GetUncheckedRelease, + Map: Array + ForEach, Stride), Data = T> + GetUncheckedRelease, T: IsEmpty, PointN: IntegerPoint, { diff --git a/crates/building_blocks_storage/src/access.rs b/crates/building_blocks_storage/src/access.rs index 532db89a..f0962731 100644 --- a/crates/building_blocks_storage/src/access.rs +++ b/crates/building_blocks_storage/src/access.rs @@ -102,8 +102,8 @@ pub trait GetUncheckedRelease: Get + GetUnchecked GetUncheckedRelease for Meta where - Meta: Get + GetUnchecked +impl GetUncheckedRelease for Map where + Map: Get + GetUnchecked { } @@ -121,8 +121,8 @@ pub trait GetUncheckedMutRelease: GetMut + GetUncheckedMut GetUncheckedMutRelease for Meta where - Meta: GetMut + GetUncheckedMut +impl GetUncheckedMutRelease for Map where + Map: GetMut + GetUncheckedMut { } diff --git a/crates/building_blocks_storage/src/array.rs b/crates/building_blocks_storage/src/array.rs index 0c90754d..e93daec1 100644 --- a/crates/building_blocks_storage/src/array.rs +++ b/crates/building_blocks_storage/src/array.rs @@ -640,7 +640,7 @@ impl_array_for_each!( // Newtype avoids potential conflicting impls downstream. #[derive(Copy, Clone)] -pub struct ArrayCopySrc(pub Meta); +pub struct ArrayCopySrc(pub Map); impl<'a, N: 'a, T: 'a> ReadExtent<'a, N> for ArrayN where @@ -681,18 +681,18 @@ where } } -impl<'a, N, T, Meta, F> WriteExtent>> for ArrayN +impl<'a, N, T, Map, F> WriteExtent>> for ArrayN where Self: Array, T: Clone, - TransformMap<'a, Meta, F>: Array + GetUncheckedRelease, + TransformMap<'a, Map, F>: Array + GetUncheckedRelease, PointN: IntegerPoint, ExtentN: Copy, { fn write_extent( &mut self, extent: &ExtentN, - src_array: ArrayCopySrc>, + src_array: ArrayCopySrc>, ) { // It is assumed by the interface that extent is a subset of the src array, so we only need // to intersect with the destination. @@ -721,15 +721,15 @@ fn unchecked_copy_extent_between_arrays( }); } -impl WriteExtent> for ArrayN +impl WriteExtent> for ArrayN where - Self: WriteExtent>, + Self: WriteExtent>, N: ArrayIndexer, T: Clone, PointN: IntegerPoint, ExtentN: PartialEq, { - fn write_extent(&mut self, extent: &ExtentN, src: ChunkCopySrc) { + fn write_extent(&mut self, extent: &ExtentN, src: ChunkCopySrc) { match src { Either::Left(array) => self.write_extent(extent, array), Either::Right(ambient) => self.fill_extent(extent, ambient.get()), diff --git a/crates/building_blocks_storage/src/chunk_map.rs b/crates/building_blocks_storage/src/chunk_map.rs index 5413f521..64202150 100644 --- a/crates/building_blocks_storage/src/chunk_map.rs +++ b/crates/building_blocks_storage/src/chunk_map.rs @@ -608,7 +608,7 @@ where } } -pub type ChunkCopySrc = Either, AmbientExtent>; +pub type ChunkCopySrc = Either, AmbientExtent>; pub type ArrayChunkCopySrcIter<'a, N, T> = std::vec::IntoIter<(ExtentN, ArrayChunkCopySrc<'a, N, T>)>;