From f078f3f12eae5579e57c08bb4c3a5f695f53e669 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 7 Sep 2024 15:15:46 -0700 Subject: [PATCH] Rename `FaceMap::repeat()` to `splat()`. This is consistent with `euclid` vector types. Also, it's shorter. --- CHANGELOG.md | 1 + all-is-cubes-base/src/math/face.rs | 6 ++--- all-is-cubes-base/src/math/vol.rs | 3 --- all-is-cubes-base/src/raycast/tests.rs | 2 +- all-is-cubes-content/src/city.rs | 6 ++--- all-is-cubes-content/src/city/exhibits.rs | 8 +++---- .../src/dungeon/demo_dungeon.rs | 6 ++--- all-is-cubes-content/src/dungeon/maze.rs | 2 +- all-is-cubes-content/src/template.rs | 4 ++-- all-is-cubes-gpu/src/in_wgpu/light_texture.rs | 4 ++-- .../examples/visualize-block-mesh.rs | 2 +- all-is-cubes-mesh/src/block_mesh/analyze.rs | 2 +- all-is-cubes-mesh/src/space_mesh.rs | 2 +- all-is-cubes-mesh/src/tests.rs | 8 +++---- all-is-cubes/build.rs | 2 +- all-is-cubes/src/block/eval/derived.rs | 6 ++--- all-is-cubes/src/block/eval/evaluated.rs | 8 +++---- all-is-cubes/src/block/eval/tests.rs | 6 ++--- all-is-cubes/src/block/modifier.rs | 2 +- all-is-cubes/src/block/modifier/move.rs | 4 ++-- all-is-cubes/src/block/tests.rs | 22 +++++++++---------- all-is-cubes/src/character/exposure.rs | 2 +- all-is-cubes/src/raytracer/surface.rs | 2 +- all-is-cubes/src/space/light/updater.rs | 10 ++++----- all-is-cubes/src/space/sky.rs | 2 +- 25 files changed, 60 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b27dce2a..36d1c75e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - `block::EvalBlockError` is now a `struct` with an inner `ErrorKind` enum, instead of an enum, and contains more information. - `block::Move`’s means of construction have been changed to be more systematic and orthogonal. In particular, paired moves are constructed from unpaired ones. + - `math::FaceMap::repeat()` has been renamed to `splat()`, for consistency with the same concept in the `euclid` vector types which we use. - `math::GridAab::expand()` now takes unsigned values; use `GridAab::shrink()` instead of negative ones. This allows both versions to never panic. - `all-is-cubes-gpu` library: diff --git a/all-is-cubes-base/src/math/face.rs b/all-is-cubes-base/src/math/face.rs index f93232c36..5485f3e59 100644 --- a/all-is-cubes-base/src/math/face.rs +++ b/all-is-cubes-base/src/math/face.rs @@ -794,7 +794,7 @@ impl FaceMap { impl FaceMap { /// Constructs a [`FaceMap`] containing clones of the provided value. #[inline] - pub fn repeat(value: V) -> Self { + pub fn splat(value: V) -> Self { Self { nx: value.clone(), ny: value.clone(), @@ -809,11 +809,11 @@ impl FaceMap { impl FaceMap { /// Constructs a [`FaceMap`] containing copies of the provided value. /// - /// This is practically identical to [`FaceMap::repeat()`] except that it is a + /// This is practically identical to [`FaceMap::splat()`] except that it is a /// `const fn`. It may be removed from future major versions once Rust supports const /// trait function calls. #[inline] - pub const fn repeat_copy(value: V) -> Self { + pub const fn splat_copy(value: V) -> Self { Self { nx: value, ny: value, diff --git a/all-is-cubes-base/src/math/vol.rs b/all-is-cubes-base/src/math/vol.rs index 325327d7c..ab0eea1c1 100644 --- a/all-is-cubes-base/src/math/vol.rs +++ b/all-is-cubes-base/src/math/vol.rs @@ -164,9 +164,6 @@ where } /// Constructs a `Vol` by cloning the provided value for each point. - /// - /// TODO: This feels like it should be called 'filled' or 'cloned', but if so, - /// maybe [`FaceMap::repeat`](crate::math::FaceMap::repeat) should also change? #[inline] pub fn repeat(bounds: GridAab, value: V) -> Self where diff --git a/all-is-cubes-base/src/raycast/tests.rs b/all-is-cubes-base/src/raycast/tests.rs index 82ec71c5a..c0a194cfc 100644 --- a/all-is-cubes-base/src/raycast/tests.rs +++ b/all-is-cubes-base/src/raycast/tests.rs @@ -421,7 +421,7 @@ fn intersection_point_random_test() { // A one-cube box, so that all possible rays should either intersect // exactly this cube, or none at all. let bounds = GridAab::from_lower_size([0, 0, 0], [1, 1, 1]); - let ray_origins: Aab = bounds.expand(FaceMap::repeat(1)).to_free(); + let ray_origins: Aab = bounds.expand(FaceMap::splat(1)).to_free(); let mut rng = rand_xoshiro::Xoshiro256Plus::seed_from_u64(0); for _ in 0..1000 { diff --git a/all-is-cubes-content/src/city.rs b/all-is-cubes-content/src/city.rs index 6b7bc1d1b..235991ae3 100644 --- a/all-is-cubes-content/src/city.rs +++ b/all-is-cubes-content/src/city.rs @@ -450,10 +450,10 @@ fn place_one_exhibit( // Amount by which the exhibit's own size is expanded to form walls and empty space // for displaying it and allowing players to move around it. let enclosure_thickness = match exhibit.placement { - Placement::Surface => FaceMap::repeat(1), + Placement::Surface => FaceMap::splat(1), // Underground exhibits get no enclosure; they are expected to play nicely with being // buried in stone except for the entranceway. - Placement::Underground => FaceMap::repeat(0), + Placement::Underground => FaceMap::splat(0), }; // Now that we know the size of the exhibit, find a place for it that fits its bounds. @@ -902,7 +902,7 @@ impl CityPlanner { } let for_occupancy_check = - transformed.expand(FaceMap::repeat(Self::GAP_BETWEEN_PLOTS)); + transformed.expand(FaceMap::splat(Self::GAP_BETWEEN_PLOTS)); if self.is_occupied(for_occupancy_check) { continue 'search; diff --git a/all-is-cubes-content/src/city/exhibits.rs b/all-is-cubes-content/src/city/exhibits.rs index 586b64402..d7ed314e5 100644 --- a/all-is-cubes-content/src/city/exhibits.rs +++ b/all-is-cubes-content/src/city/exhibits.rs @@ -973,7 +973,7 @@ fn COLOR_LIGHTS(_: Context<'_>) { [0, 0, 0], Size3D::new(room_width, room_height, room_length).to_u32(), ); - let mut space = Space::empty(interior.expand(FaceMap::repeat(1))); + let mut space = Space::empty(interior.expand(FaceMap::splat(1))); fn normalize(color: Rgb) -> Rgb { color * color.luminance().recip() @@ -1054,7 +1054,7 @@ fn COLOR_LIGHTS(_: Context<'_>) { Some(wall_block.clone()), Some(corner.rotate(GridRotation::RxYz)), ) - .create_box(interior.expand(FaceMap::repeat(1))) + .create_box(interior.expand(FaceMap::splat(1))) .execute(&mut space, &mut transaction::no_outputs)?; // Separators between floors @@ -1159,7 +1159,7 @@ fn COLORED_BOUNCE(_: Context<'_>) { GridPoint::splat(-interior_radius), GridSize::splat(u32::try_from(interior_radius).unwrap() * 2 + 1), ); - let mut space = Space::empty(interior.expand(FaceMap::repeat(wall_thickness))); + let mut space = Space::empty(interior.expand(FaceMap::splat(wall_thickness))); // Thick walls + interior cavity space.fill_uniform(space.bounds(), &wall_block).unwrap(); @@ -1176,7 +1176,7 @@ fn COLORED_BOUNCE(_: Context<'_>) { // Central reflecting block space.fill_uniform( - GridAab::ORIGIN_CUBE.expand(FaceMap::repeat(1)), + GridAab::ORIGIN_CUBE.expand(FaceMap::splat(1)), &reflecting_block, )?; diff --git a/all-is-cubes-content/src/dungeon/demo_dungeon.rs b/all-is-cubes-content/src/dungeon/demo_dungeon.rs index a57546f65..e7840aea7 100644 --- a/all-is-cubes-content/src/dungeon/demo_dungeon.rs +++ b/all-is-cubes-content/src/dungeon/demo_dungeon.rs @@ -106,7 +106,7 @@ impl DemoTheme { None, ) .with_interior(Some(AIR)) - .create_box(interior.expand(FaceMap::repeat(1))) + .create_box(interior.expand(FaceMap::splat(1))) .execute(space, &mut transaction::no_outputs)?; Ok(()) @@ -309,7 +309,7 @@ impl Theme> for DemoTheme { .y + 1; four_walls( - interior.expand(FaceMap::repeat(1)), + interior.expand(FaceMap::splat(1)), |origin, along_wall, length, wall_excluding_corners_box| { let wall = GridRotation::CLOCKWISE.transform(along_wall); // TODO: make four_walls provide this in a nice name if let WallFeature::Window = room_data.wall_features[wall] { @@ -411,7 +411,7 @@ pub(crate) async fn demo_dungeon( let dungeon_grid = DungeonGrid { room_box: GridAab::from_lower_size([0, 0, 0], [9, 5, 9]), - room_wall_thickness: FaceMap::repeat(1), + room_wall_thickness: FaceMap::splat(1), gap_between_walls: Size3D::new(1, 1, 1), }; let perimeter_margin: GridSizeCoord = 30; diff --git a/all-is-cubes-content/src/dungeon/maze.rs b/all-is-cubes-content/src/dungeon/maze.rs index 19c8ca4b9..95041d07c 100644 --- a/all-is-cubes-content/src/dungeon/maze.rs +++ b/all-is-cubes-content/src/dungeon/maze.rs @@ -47,7 +47,7 @@ pub fn generate_maze(seed: u64, requested_rooms: GridSize) -> Maze { GridAab::from_lower_size([0, 0, 0], requested_rooms), MazeRoom { kind: MazeRoomKind::Unoccupied, - passages: FaceMap::repeat(false), + passages: FaceMap::splat(false), }, ); diff --git a/all-is-cubes-content/src/template.rs b/all-is-cubes-content/src/template.rs index 4d6b1301d..92b9c5c10 100644 --- a/all-is-cubes-content/src/template.rs +++ b/all-is-cubes-content/src/template.rs @@ -370,7 +370,7 @@ async fn islands( && cell_bounds.size().depth >= margin * 2 { let occupied_bounds = cell_bounds - .shrink(FaceMap::repeat(10).with(Face6::PY, 25)) + .shrink(FaceMap::splat(10).with(Face6::PY, 25)) .unwrap(); wavy_landscape(occupied_bounds, &mut space, &landscape_blocks, 0.5)?; } @@ -464,7 +464,7 @@ async fn arbitrary_space( // Patch spawn position to be reasonable let bounds = space.bounds(); let mut spawn = space.spawn().clone(); - spawn.set_bounds(bounds.expand(FaceMap::repeat(20))); + spawn.set_bounds(bounds.expand(FaceMap::splat(20))); spawn.set_eye_position(bounds.center()); space.set_spawn(spawn); diff --git a/all-is-cubes-gpu/src/in_wgpu/light_texture.rs b/all-is-cubes-gpu/src/in_wgpu/light_texture.rs index 672c4552c..066cfca1f 100644 --- a/all-is-cubes-gpu/src/in_wgpu/light_texture.rs +++ b/all-is-cubes-gpu/src/in_wgpu/light_texture.rs @@ -44,7 +44,7 @@ fn visible_light_volume(space_bounds: GridAab, camera: &Camera) -> GridAab { .round_up_to_grid(); // Extra volume of 1 extra cube around all sides automatically captures sky light. visible_bounds - .intersection_cubes(space_bounds.expand(FaceMap::repeat(1))) + .intersection_cubes(space_bounds.expand(FaceMap::splat(1))) .unwrap_or(GridAab::ORIGIN_CUBE) } @@ -163,7 +163,7 @@ impl LightTexture { /// /// Returns the volume (number of cubes) that needed to be copied to the texture. pub fn ensure_mapped(&mut self, queue: &wgpu::Queue, space: &Space, region: GridAab) -> usize { - let Some(region) = region.intersection_cubes(space.bounds().expand(FaceMap::repeat(1))) + let Some(region) = region.intersection_cubes(space.bounds().expand(FaceMap::splat(1))) else { return 0; }; diff --git a/all-is-cubes-mesh/examples/visualize-block-mesh.rs b/all-is-cubes-mesh/examples/visualize-block-mesh.rs index 49d86930a..15278a324 100644 --- a/all-is-cubes-mesh/examples/visualize-block-mesh.rs +++ b/all-is-cubes-mesh/examples/visualize-block-mesh.rs @@ -92,7 +92,7 @@ fn make_transparent_block(universe: &mut Universe) -> Block { .build(); let resolution = Resolution::R16; let solid_box = GridAab::for_block(resolution) - .shrink(FaceMap::repeat(2)) + .shrink(FaceMap::splat(2)) .unwrap(); let transparent_box = GridAab::for_block(resolution).abut(Face6::PX, -4).unwrap(); let emissive_box = GridAab::for_block(resolution).abut(Face6::NX, -4).unwrap(); diff --git a/all-is-cubes-mesh/src/block_mesh/analyze.rs b/all-is-cubes-mesh/src/block_mesh/analyze.rs index 8e2380d22..eaf88c070 100644 --- a/all-is-cubes-mesh/src/block_mesh/analyze.rs +++ b/all-is-cubes-mesh/src/block_mesh/analyze.rs @@ -70,7 +70,7 @@ fn unflatten( impl Analysis { pub fn empty() -> Self { Analysis { - occupied_planes: FaceMap::repeat([EMPTY_PLANE_BOX; MAX_PLANES]), + occupied_planes: FaceMap::splat([EMPTY_PLANE_BOX; MAX_PLANES]), needs_texture: false, resolution: Resolution::R1, } diff --git a/all-is-cubes-mesh/src/space_mesh.rs b/all-is-cubes-mesh/src/space_mesh.rs index b642fd66d..f512bc5c8 100644 --- a/all-is-cubes-mesh/src/space_mesh.rs +++ b/all-is-cubes-mesh/src/space_mesh.rs @@ -671,7 +671,7 @@ impl Snapshot { #[allow(dead_code)] pub(crate) fn new(space: &Space, bounds: GridAab) -> Snapshot { let expanded_bounds = bounds - .expand(FaceMap::repeat(1)) + .expand(FaceMap::splat(1)) .intersection_box(space.bounds()) .unwrap_or(GridAab::ORIGIN_EMPTY); Snapshot { diff --git a/all-is-cubes-mesh/src/tests.rs b/all-is-cubes-mesh/src/tests.rs index 1e0444027..92384cb49 100644 --- a/all-is-cubes-mesh/src/tests.rs +++ b/all-is-cubes-mesh/src/tests.rs @@ -504,15 +504,15 @@ fn opacities(mesh: &BlockMesh) -> FaceMap { fn atom_transparency() { assert_eq!( opacities(&test_block_mesh(color_block!(Rgba::WHITE))), - FaceMap::repeat(true) + FaceMap::splat(true) ); assert_eq!( opacities(&test_block_mesh(color_block!(Rgba::TRANSPARENT))), - FaceMap::repeat(false) + FaceMap::splat(false) ); assert_eq!( opacities(&test_block_mesh(color_block!(1.0, 1.0, 1.0, 0.5))), - FaceMap::repeat(false) + FaceMap::splat(false) ); } @@ -610,7 +610,7 @@ fn invisible_voxel_block() { "sanity check test data" ); - assert_eq!(opacities(&test_block_mesh(block)), FaceMap::repeat(false)); + assert_eq!(opacities(&test_block_mesh(block)), FaceMap::splat(false)); } #[test] diff --git a/all-is-cubes/build.rs b/all-is-cubes/build.rs index 4fc759b29..dfc5b186d 100644 --- a/all-is-cubes/build.rs +++ b/all-is-cubes/build.rs @@ -38,7 +38,7 @@ fn generate_light_ray_pattern() -> Vec { { let direction = Vector3D::new(x as f32, y as f32, z as f32).normalize(); - let mut cosines = FaceMap::repeat(0.0f32); + let mut cosines = FaceMap::splat(0.0f32); for face in Face6::ALL { let unit_vector: FreeVector = face.normal_vector(); let cosine = unit_vector.to_f32().dot(direction.to_f32()).max(0.0); diff --git a/all-is-cubes/src/block/eval/derived.rs b/all-is-cubes/src/block/eval/derived.rs index a7e7c0dea..1d1ab7916 100644 --- a/all-is-cubes/src/block/eval/derived.rs +++ b/all-is-cubes/src/block/eval/derived.rs @@ -98,9 +98,9 @@ pub(in crate::block::eval) fn compute_derived( let visible = !color.fully_transparent() || emission != Rgb::ZERO; return Derived { color, - face_colors: FaceMap::repeat(color), + face_colors: FaceMap::splat(color), light_emission: emission, - opaque: FaceMap::repeat(color.fully_opaque()), + opaque: FaceMap::splat(color.fully_opaque()), visible, uniform_collision: Some(collision), voxel_opacity_mask: VoxelOpacityMask::new_r1(voxel), @@ -116,7 +116,7 @@ pub(in crate::block::eval) fn compute_derived( // of all six faces by tracing in from the edges, and then averages them. let (color, face_colors, emission): (Rgba, FaceMap, Rgb) = { let mut all_faces_sum = VoxSum::default(); - let mut face_colors = FaceMap::repeat(Rgba::TRANSPARENT); + let mut face_colors = FaceMap::splat(Rgba::TRANSPARENT); // Loop over all face voxels. // (This is a similar structure to the algorithm we use for mesh generation.) diff --git a/all-is-cubes/src/block/eval/evaluated.rs b/all-is-cubes/src/block/eval/evaluated.rs index 800bf2799..dde05e951 100644 --- a/all-is-cubes/src/block/eval/evaluated.rs +++ b/all-is-cubes/src/block/eval/evaluated.rs @@ -73,7 +73,7 @@ impl fmt::Debug for EvaluatedBlock { ds.field("attributes", attributes); } ds.field("color", color); - if *face_colors != FaceMap::repeat(*color) { + if *face_colors != FaceMap::splat(*color) { ds.field("face_colors", face_colors); } if *light_emission != Rgb::ZERO { @@ -256,7 +256,7 @@ impl EvaluatedBlock { /// TODO: Review uses of .opaque and .visible and see if they can be usefully replaced /// by this. pub(crate) fn opacity_as_category(&self) -> OpacityCategory { - if self.derived.opaque == FaceMap::repeat(true) { + if self.derived.opaque == FaceMap::splat(true) { OpacityCategory::Opaque } else if !self.derived.visible { OpacityCategory::Invisible @@ -368,9 +368,9 @@ const AIR_ATTRIBUTES: BlockAttributes = BlockAttributes { const AIR_DERIVED: Derived = Derived { color: Rgba::TRANSPARENT, - face_colors: FaceMap::repeat_copy(Rgba::TRANSPARENT), + face_colors: FaceMap::splat_copy(Rgba::TRANSPARENT), light_emission: Rgb::ZERO, - opaque: FaceMap::repeat_copy(false), + opaque: FaceMap::splat_copy(false), visible: false, uniform_collision: Some(BlockCollision::None), voxel_opacity_mask: VoxelOpacityMask::R1_INVISIBLE, diff --git a/all-is-cubes/src/block/eval/tests.rs b/all-is-cubes/src/block/eval/tests.rs index 6c0ce6e79..30ee82f57 100644 --- a/all-is-cubes/src/block/eval/tests.rs +++ b/all-is-cubes/src/block/eval/tests.rs @@ -168,9 +168,9 @@ fn from_voxels_zero_bounds() { attributes, derived: Derived { color: Rgba::TRANSPARENT, - face_colors: FaceMap::repeat(Rgba::TRANSPARENT), + face_colors: FaceMap::splat(Rgba::TRANSPARENT), light_emission: Rgb::ZERO, - opaque: FaceMap::repeat(false), + opaque: FaceMap::splat(false), visible: false, uniform_collision: Some(BlockCollision::None), voxel_opacity_mask: block::VoxelOpacityMask::new(resolution, voxels.as_vol_ref()), @@ -189,7 +189,7 @@ fn from_voxels_zero_bounds() { fn overall_color_ignores_interior() { let resolution = R8; let outer_bounds = GridAab::for_block(resolution); - let inner_bounds = outer_bounds.shrink(FaceMap::repeat(1)).unwrap(); + let inner_bounds = outer_bounds.shrink(FaceMap::splat(1)).unwrap(); let outer_color = Rgba::new(1.0, 0.0, 0.0, 1.0); let inner_color = Rgba::new(0.0, 1.0, 0.0, 1.0); let voxels = Evoxels::from_many( diff --git a/all-is-cubes/src/block/modifier.rs b/all-is-cubes/src/block/modifier.rs index ea62456bb..c7c4fb17f 100644 --- a/all-is-cubes/src/block/modifier.rs +++ b/all-is-cubes/src/block/modifier.rs @@ -414,7 +414,7 @@ mod tests { color: be.color(), face_colors: be.face_colors().rotate(rotation), light_emission: Rgb::ZERO, - opaque: FaceMap::repeat(false).with(rotation.transform(Face6::NY), true), + opaque: FaceMap::splat(false).with(rotation.transform(Face6::NY), true), visible: true, uniform_collision: Some(BlockCollision::Hard), voxel_opacity_mask: block::VoxelOpacityMask::new_raw( diff --git a/all-is-cubes/src/block/modifier/move.rs b/all-is-cubes/src/block/modifier/move.rs index 0f2614694..d89db3b92 100644 --- a/all-is-cubes/src/block/modifier/move.rs +++ b/all-is-cubes/src/block/modifier/move.rs @@ -276,7 +276,7 @@ mod tests { pz: color.to_rgb().with_alpha(notnan!(0.5)), }, light_emission: Rgb::ZERO, - opaque: FaceMap::repeat(false).with(Face6::PY, true), + opaque: FaceMap::splat(false).with(Face6::PY, true), visible: true, uniform_collision: None, voxel_opacity_mask: VoxelOpacityMask::new_raw( @@ -333,7 +333,7 @@ mod tests { pz: color.to_rgb().with_alpha(notnan!(0.5)), }, light_emission: Rgb::ZERO, - opaque: FaceMap::repeat(false).with(Face6::PY, true), + opaque: FaceMap::splat(false).with(Face6::PY, true), visible: true, uniform_collision: None, voxel_opacity_mask: VoxelOpacityMask::new_raw( diff --git a/all-is-cubes/src/block/tests.rs b/all-is-cubes/src/block/tests.rs index 581c149d1..1a89ae316 100644 --- a/all-is-cubes/src/block/tests.rs +++ b/all-is-cubes/src/block/tests.rs @@ -136,7 +136,7 @@ mod eval { let e = block.evaluate().unwrap(); assert_eq!(e.attributes(), BlockAttributes::DEFAULT_REF); assert_eq!(e.color(), color); - assert_eq!(e.face_colors(), FaceMap::repeat(color)); + assert_eq!(e.face_colors(), FaceMap::splat(color)); assert_eq!(e.light_emission(), Rgb::ONE); assert_eq!( e.voxels, @@ -148,7 +148,7 @@ mod eval { }) ); assert_eq!(e.resolution(), R1); - assert_eq!(e.opaque(), FaceMap::repeat(true)); + assert_eq!(e.opaque(), FaceMap::splat(true)); assert_eq!(e.visible(), true); assert_eq!( *e.voxel_opacity_mask(), @@ -162,10 +162,10 @@ mod eval { let block = Block::from(color); let e = block.evaluate().unwrap(); assert_eq!(e.color(), color); - assert_eq!(e.face_colors(), FaceMap::repeat(color)); + assert_eq!(e.face_colors(), FaceMap::splat(color)); assert_eq!(e.light_emission(), Rgb::ZERO); assert!(e.voxels.single_voxel().is_some()); - assert_eq!(e.opaque(), FaceMap::repeat(false)); + assert_eq!(e.opaque(), FaceMap::splat(false)); assert_eq!(e.visible(), true); assert_eq!( *e.voxel_opacity_mask(), @@ -182,10 +182,10 @@ mod eval { .build(); let e = block.evaluate().unwrap(); assert_eq!(e.color(), Rgba::TRANSPARENT); - assert_eq!(e.face_colors(), FaceMap::repeat(Rgba::TRANSPARENT)); + assert_eq!(e.face_colors(), FaceMap::splat(Rgba::TRANSPARENT)); assert_eq!(e.light_emission(), emissive_color); assert!(e.voxels.single_voxel().is_some()); - assert_eq!(e.opaque(), FaceMap::repeat(false)); + assert_eq!(e.opaque(), FaceMap::splat(false)); assert_eq!(e.visible(), true); assert_eq!( *e.voxel_opacity_mask(), @@ -198,9 +198,9 @@ mod eval { let block = color_block!(Rgba::TRANSPARENT); let e = block.evaluate().unwrap(); assert_eq!(e.color(), Rgba::TRANSPARENT); - assert_eq!(e.face_colors(), FaceMap::repeat(Rgba::TRANSPARENT)); + assert_eq!(e.face_colors(), FaceMap::splat(Rgba::TRANSPARENT)); assert!(e.voxels.single_voxel().is_some()); - assert_eq!(e.opaque(), FaceMap::repeat(false)); + assert_eq!(e.opaque(), FaceMap::splat(false)); assert_eq!(e.visible(), false); assert_eq!( *e.voxel_opacity_mask(), @@ -256,7 +256,7 @@ mod eval { } ); assert_eq!(e.resolution(), resolution); - assert_eq!(e.opaque(), FaceMap::repeat(true)); + assert_eq!(e.opaque(), FaceMap::splat(true)); assert_eq!(e.visible(), true); assert_eq!( *e.voxel_opacity_mask(), @@ -424,7 +424,7 @@ mod eval { Rgba::new(0.0, 0.0, 0.0, 1.0 / f32::from(resolution).powi(2)) ); assert_eq!(e.resolution(), resolution); - assert_eq!(e.opaque(), FaceMap::repeat(false)); + assert_eq!(e.opaque(), FaceMap::splat(false)); assert_eq!(e.visible(), true); } @@ -447,7 +447,7 @@ mod eval { // of 6 faces, 2 are opaque and 2 are half-transparent, thus there are 8 opaque half-faces. assert_eq!(e.color(), Rgba::new(1.0, 1.0, 1.0, 8. / 12.)); assert_eq!(e.resolution(), resolution); - assert_eq!(e.opaque(), FaceMap::repeat(false).with(Face6::NX, true)); + assert_eq!(e.opaque(), FaceMap::splat(false).with(Face6::NX, true)); assert_eq!(e.visible(), true); } diff --git a/all-is-cubes/src/character/exposure.rs b/all-is-cubes/src/character/exposure.rs index 5f4aa8bfb..6974bc6e0 100644 --- a/all-is-cubes/src/character/exposure.rs +++ b/all-is-cubes/src/character/exposure.rs @@ -182,7 +182,7 @@ mod tests { // space.fill_uniform(space.bounds(), light_block).unwrap(); // space - // .fill_uniform(space.bounds().expand(FaceMap::repeat(-1)), AIR) + // .fill_uniform(space.bounds().shrink(FaceMap::splat(1)), AIR) // .unwrap(); space.evaluate_light::(0, |_| {}); diff --git a/all-is-cubes/src/raytracer/surface.rs b/all-is-cubes/src/raytracer/surface.rs index f49b6eef2..b96144dba 100644 --- a/all-is-cubes/src/raytracer/surface.rs +++ b/all-is-cubes/src/raytracer/surface.rs @@ -204,7 +204,7 @@ where // Do this by expanding the raycast bounds by one cube. self.block_raycaster.remove_bounds(); self.block_raycaster - .add_bounds(self.array.bounds().expand(FaceMap::repeat(1))); + .add_bounds(self.array.bounds().expand(FaceMap::splat(1))); self.state = SurfaceIterState::EnteredSpace; } diff --git a/all-is-cubes/src/space/light/updater.rs b/all-is-cubes/src/space/light/updater.rs index 1b07b0641..fee9c0577 100644 --- a/all-is-cubes/src/space/light/updater.rs +++ b/all-is-cubes/src/space/light/updater.rs @@ -322,7 +322,7 @@ impl LightStorage { if *neighbor_light == new_light_value { continue; } - if uc.get_evaluated(neighbor_cube).opaque() == FaceMap::repeat(true) { + if uc.get_evaluated(neighbor_cube).opaque() == FaceMap::splat(true) { // neighbor is fully opaque — don't light it continue; } @@ -376,7 +376,7 @@ impl LightStorage { }; let ev_origin = uc.get_evaluated(cube); - let origin_is_opaque = ev_origin.opaque() == FaceMap::repeat(true); + let origin_is_opaque = ev_origin.opaque() == FaceMap::splat(true); if origin_is_opaque { // Opaque blocks are always dark inside — unless they are light sources. if !opaque_for_light_computation(ev_origin) { @@ -592,7 +592,7 @@ fn directions_to_seek_light( ) -> FaceMap { if origin.visible_or_animated() { // Non-opaque blocks should work the same as blocks which have all six adjacent faces present. - FaceMap::repeat(1.0) + FaceMap::splat(1.0) } else { FaceMap::from_fn(|face| { // We want directions that either face away from visible faces, or towards light sources. @@ -703,7 +703,7 @@ impl LightBuffer { let face_opacity = ev_hit.opaque(); let hit_opaque_face: bool = match Face6::try_from(hit.face) { Ok(face) => face_opacity[face], - Err(_) => face_opacity == FaceMap::repeat(true), + Err(_) => face_opacity == FaceMap::splat(true), }; if hit_opaque_face && hit.face == Face7::Within { @@ -906,5 +906,5 @@ impl Fmt for LightUpdatesInfo { /// This function is fairly straightforward; it exists for purposes of *documenting /// the places that care about this* rather than for code reduction. pub(crate) fn opaque_for_light_computation(block: &EvaluatedBlock) -> bool { - block.opaque() == FaceMap::repeat(true) && block.light_emission() == Rgb::ZERO + block.opaque() == FaceMap::splat(true) && block.light_emission() == Rgb::ZERO } diff --git a/all-is-cubes/src/space/sky.rs b/all-is-cubes/src/space/sky.rs index b61f504e4..710fa0a82 100644 --- a/all-is-cubes/src/space/sky.rs +++ b/all-is-cubes/src/space/sky.rs @@ -53,7 +53,7 @@ impl Sky { pub(crate) fn for_blocks(&self) -> BlockSky { BlockSky { faces: match *self { - Sky::Uniform(color) => FaceMap::repeat(PackedLight::from(color)), + Sky::Uniform(color) => FaceMap::splat(PackedLight::from(color)), Sky::Octants(_) => FaceMap::from_fn(|face| { let transform = face.face_transform(0); // Take four samples from rays into the correct octants.