Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
fix more bad find-replaces of type params
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsairobo committed Dec 17, 2020
1 parent ed9ba3f commit b0ccec0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 36 deletions.
6 changes: 3 additions & 3 deletions crates/building_blocks_image/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ where
unsafe { map.assume_init() }
}

pub fn encode_image<T, P, Meta>(
map: &Meta,
pub fn encode_image<T, P, Map>(
map: &Map,
map_extent: &Extent2i,
) -> ImageBuffer<P, Vec<<P as Pixel>::Subpixel>>
where
T: Into<P>,
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;
Expand Down
14 changes: 7 additions & 7 deletions crates/building_blocks_mesh/src/greedy_quads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Meta> {
pub struct GreedyQuadsBuffer<Material> {
/// One group of quads per cube face.
pub quad_groups: [QuadGroup<Meta>; 6],
pub quad_groups: [QuadGroup<Material>; 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<bool>,
}

/// A set of `Quad`s that share an orientation. Each quad may specify a material of type `Meta`.
pub struct QuadGroup<Meta> {
/// A set of `Quad`s that share an orientation. Each quad may specify a material of type `Material`.
pub struct QuadGroup<Material> {
/// 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<Meta> QuadGroup<Meta> {
impl<Material> QuadGroup<Material> {
pub fn new(face: OrientedCubeFace) -> Self {
Self {
quads: Vec::new(),
Expand All @@ -33,7 +33,7 @@ impl<Meta> QuadGroup<Meta> {
}
}

impl<Meta> GreedyQuadsBuffer<Meta> {
impl<Material> GreedyQuadsBuffer<Material> {
pub fn new(extent: Extent3i) -> Self {
let quad_groups = [
QuadGroup::new(OrientedCubeFace::new(-1, Axis3Permutation::XZY)),
Expand Down
24 changes: 12 additions & 12 deletions crates/building_blocks_mesh/src/surface_nets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<V, T>(sdf: &V, extent: &Extent3i, output: &mut SurfaceNetsBuffer)
pub fn surface_nets<A, T>(sdf: &A, extent: &Extent3i, output: &mut SurfaceNetsBuffer)
where
V: Array<[i32; 3]> + GetUncheckedRelease<Stride, T>,
A: Array<[i32; 3]> + GetUncheckedRelease<Stride, T>,
T: SignedDistance,
{
output.reset(sdf.extent().num_points());
Expand All @@ -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<V, T>(sdf: &V, extent: &Extent3i, output: &mut SurfaceNetsBuffer)
fn estimate_surface<A, T>(sdf: &A, extent: &Extent3i, output: &mut SurfaceNetsBuffer)
where
V: Array<[i32; 3]> + GetUncheckedRelease<Stride, T>,
A: Array<[i32; 3]> + GetUncheckedRelease<Stride, T>,
T: SignedDistance,
{
// Precalculate these offsets to do faster linear indexing.
Expand Down Expand Up @@ -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<V, T>(
sdf: &V,
fn estimate_surface_in_voxel<A, T>(
sdf: &A,
point: &Point3i,
corner_strides: &[Stride],
) -> Option<([f32; 3], [f32; 3])>
where
V: GetUncheckedRelease<Stride, T>,
A: GetUncheckedRelease<Stride, T>,
T: SignedDistance,
{
// Get the signed distance values at each corner of this cube.
Expand Down Expand Up @@ -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<V, T>(sdf: &V, extent: &Extent3i, output: &mut SurfaceNetsBuffer)
fn make_all_quads<A, T>(sdf: &A, extent: &Extent3i, output: &mut SurfaceNetsBuffer)
where
V: Array<[i32; 3]> + GetUncheckedRelease<Stride, T>,
A: Array<[i32; 3]> + GetUncheckedRelease<Stride, T>,
T: SignedDistance,
{
let mut xyz_strides = [Stride(0); 3];
Expand Down Expand Up @@ -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<V, T>(
sdf: &V,
fn maybe_make_quad<A, T>(
sdf: &A,
stride_to_index: &[u32],
positions: &[[f32; 3]],
p1: Stride,
Expand All @@ -320,7 +320,7 @@ fn maybe_make_quad<V, T>(
axis_c_stride: Stride,
indices: &mut Vec<u32>,
) where
V: GetUncheckedRelease<Stride, T>,
A: GetUncheckedRelease<Stride, T>,
T: SignedDistance,
{
let voxel1 = sdf.get_unchecked_release(p1);
Expand Down
7 changes: 5 additions & 2 deletions crates/building_blocks_search/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Meta, N, T>(map: &Meta, extent: &ExtentN<N>) -> (Vec<PointN<N>>, Vec<Stride>)
pub fn find_surface_points<Map, N, T>(
map: &Map,
extent: &ExtentN<N>,
) -> (Vec<PointN<N>>, Vec<Stride>)
where
Meta: Array<N> + ForEach<N, (PointN<N>, Stride), Data = T> + GetUncheckedRelease<Stride, T>,
Map: Array<N> + ForEach<N, (PointN<N>, Stride), Data = T> + GetUncheckedRelease<Stride, T>,
T: IsEmpty,
PointN<N>: IntegerPoint<N>,
{
Expand Down
8 changes: 4 additions & 4 deletions crates/building_blocks_storage/src/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ pub trait GetUncheckedRelease<L, T>: Get<L, Data = T> + GetUnchecked<L, Data = T
}
}

impl<Meta, L, T> GetUncheckedRelease<L, T> for Meta where
Meta: Get<L, Data = T> + GetUnchecked<L, Data = T>
impl<Map, L, T> GetUncheckedRelease<L, T> for Map where
Map: Get<L, Data = T> + GetUnchecked<L, Data = T>
{
}

Expand All @@ -121,8 +121,8 @@ pub trait GetUncheckedMutRelease<L, T>: GetMut<L, Data = T> + GetUncheckedMut<L,
}
}

impl<Meta, L, T> GetUncheckedMutRelease<L, T> for Meta where
Meta: GetMut<L, Data = T> + GetUncheckedMut<L, Data = T>
impl<Map, L, T> GetUncheckedMutRelease<L, T> for Map where
Map: GetMut<L, Data = T> + GetUncheckedMut<L, Data = T>
{
}

Expand Down
14 changes: 7 additions & 7 deletions crates/building_blocks_storage/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ impl_array_for_each!(

// Newtype avoids potential conflicting impls downstream.
#[derive(Copy, Clone)]
pub struct ArrayCopySrc<Meta>(pub Meta);
pub struct ArrayCopySrc<Map>(pub Map);

impl<'a, N: 'a, T: 'a> ReadExtent<'a, N> for ArrayN<N, T>
where
Expand Down Expand Up @@ -681,18 +681,18 @@ where
}
}

impl<'a, N, T, Meta, F> WriteExtent<N, ArrayCopySrc<TransformMap<'a, Meta, F>>> for ArrayN<N, T>
impl<'a, N, T, Map, F> WriteExtent<N, ArrayCopySrc<TransformMap<'a, Map, F>>> for ArrayN<N, T>
where
Self: Array<N>,
T: Clone,
TransformMap<'a, Meta, F>: Array<N> + GetUncheckedRelease<Stride, T>,
TransformMap<'a, Map, F>: Array<N> + GetUncheckedRelease<Stride, T>,
PointN<N>: IntegerPoint<N>,
ExtentN<N>: Copy,
{
fn write_extent(
&mut self,
extent: &ExtentN<N>,
src_array: ArrayCopySrc<TransformMap<'a, Meta, F>>,
src_array: ArrayCopySrc<TransformMap<'a, Map, F>>,
) {
// It is assumed by the interface that extent is a subset of the src array, so we only need
// to intersect with the destination.
Expand Down Expand Up @@ -721,15 +721,15 @@ fn unchecked_copy_extent_between_arrays<Dst, Src, N, T>(
});
}

impl<Meta, N, T> WriteExtent<N, ChunkCopySrc<Meta, N, T>> for ArrayN<N, T>
impl<Map, N, T> WriteExtent<N, ChunkCopySrc<Map, N, T>> for ArrayN<N, T>
where
Self: WriteExtent<N, ArrayCopySrc<Meta>>,
Self: WriteExtent<N, ArrayCopySrc<Map>>,
N: ArrayIndexer<N>,
T: Clone,
PointN<N>: IntegerPoint<N>,
ExtentN<N>: PartialEq,
{
fn write_extent(&mut self, extent: &ExtentN<N>, src: ChunkCopySrc<Meta, N, T>) {
fn write_extent(&mut self, extent: &ExtentN<N>, src: ChunkCopySrc<Map, N, T>) {
match src {
Either::Left(array) => self.write_extent(extent, array),
Either::Right(ambient) => self.fill_extent(extent, ambient.get()),
Expand Down
2 changes: 1 addition & 1 deletion crates/building_blocks_storage/src/chunk_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ where
}
}

pub type ChunkCopySrc<Meta, N, T> = Either<ArrayCopySrc<Meta>, AmbientExtent<N, T>>;
pub type ChunkCopySrc<Map, N, T> = Either<ArrayCopySrc<Map>, AmbientExtent<N, T>>;

pub type ArrayChunkCopySrcIter<'a, N, T> =
std::vec::IntoIter<(ExtentN<N>, ArrayChunkCopySrc<'a, N, T>)>;
Expand Down

0 comments on commit b0ccec0

Please sign in to comment.