Skip to content

Commit f078f3f

Browse files
committed
Rename FaceMap::repeat() to splat().
This is consistent with `euclid` vector types. Also, it's shorter.
1 parent c3b220d commit f078f3f

File tree

25 files changed

+60
-62
lines changed

25 files changed

+60
-62
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- `block::EvalBlockError` is now a `struct` with an inner `ErrorKind` enum, instead of an enum, and contains more information.
2020
- `block::Move`’s means of construction have been changed to be more systematic and orthogonal. In particular, paired moves are constructed from unpaired ones.
2121

22+
- `math::FaceMap::repeat()` has been renamed to `splat()`, for consistency with the same concept in the `euclid` vector types which we use.
2223
- `math::GridAab::expand()` now takes unsigned values; use `GridAab::shrink()` instead of negative ones. This allows both versions to never panic.
2324

2425
- `all-is-cubes-gpu` library:

all-is-cubes-base/src/math/face.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ impl<V> FaceMap<V> {
794794
impl<V: Clone> FaceMap<V> {
795795
/// Constructs a [`FaceMap`] containing clones of the provided value.
796796
#[inline]
797-
pub fn repeat(value: V) -> Self {
797+
pub fn splat(value: V) -> Self {
798798
Self {
799799
nx: value.clone(),
800800
ny: value.clone(),
@@ -809,11 +809,11 @@ impl<V: Clone> FaceMap<V> {
809809
impl<V: Copy> FaceMap<V> {
810810
/// Constructs a [`FaceMap`] containing copies of the provided value.
811811
///
812-
/// This is practically identical to [`FaceMap::repeat()`] except that it is a
812+
/// This is practically identical to [`FaceMap::splat()`] except that it is a
813813
/// `const fn`. It may be removed from future major versions once Rust supports const
814814
/// trait function calls.
815815
#[inline]
816-
pub const fn repeat_copy(value: V) -> Self {
816+
pub const fn splat_copy(value: V) -> Self {
817817
Self {
818818
nx: value,
819819
ny: value,

all-is-cubes-base/src/math/vol.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ where
164164
}
165165

166166
/// Constructs a `Vol<C>` by cloning the provided value for each point.
167-
///
168-
/// TODO: This feels like it should be called 'filled' or 'cloned', but if so,
169-
/// maybe [`FaceMap::repeat`](crate::math::FaceMap::repeat) should also change?
170167
#[inline]
171168
pub fn repeat(bounds: GridAab, value: V) -> Self
172169
where

all-is-cubes-base/src/raycast/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn intersection_point_random_test() {
421421
// A one-cube box, so that all possible rays should either intersect
422422
// exactly this cube, or none at all.
423423
let bounds = GridAab::from_lower_size([0, 0, 0], [1, 1, 1]);
424-
let ray_origins: Aab = bounds.expand(FaceMap::repeat(1)).to_free();
424+
let ray_origins: Aab = bounds.expand(FaceMap::splat(1)).to_free();
425425

426426
let mut rng = rand_xoshiro::Xoshiro256Plus::seed_from_u64(0);
427427
for _ in 0..1000 {

all-is-cubes-content/src/city.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ fn place_one_exhibit<I: Instant>(
450450
// Amount by which the exhibit's own size is expanded to form walls and empty space
451451
// for displaying it and allowing players to move around it.
452452
let enclosure_thickness = match exhibit.placement {
453-
Placement::Surface => FaceMap::repeat(1),
453+
Placement::Surface => FaceMap::splat(1),
454454
// Underground exhibits get no enclosure; they are expected to play nicely with being
455455
// buried in stone except for the entranceway.
456-
Placement::Underground => FaceMap::repeat(0),
456+
Placement::Underground => FaceMap::splat(0),
457457
};
458458

459459
// Now that we know the size of the exhibit, find a place for it that fits its bounds.
@@ -902,7 +902,7 @@ impl CityPlanner {
902902
}
903903

904904
let for_occupancy_check =
905-
transformed.expand(FaceMap::repeat(Self::GAP_BETWEEN_PLOTS));
905+
transformed.expand(FaceMap::splat(Self::GAP_BETWEEN_PLOTS));
906906

907907
if self.is_occupied(for_occupancy_check) {
908908
continue 'search;

all-is-cubes-content/src/city/exhibits.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ fn COLOR_LIGHTS(_: Context<'_>) {
973973
[0, 0, 0],
974974
Size3D::new(room_width, room_height, room_length).to_u32(),
975975
);
976-
let mut space = Space::empty(interior.expand(FaceMap::repeat(1)));
976+
let mut space = Space::empty(interior.expand(FaceMap::splat(1)));
977977

978978
fn normalize(color: Rgb) -> Rgb {
979979
color * color.luminance().recip()
@@ -1054,7 +1054,7 @@ fn COLOR_LIGHTS(_: Context<'_>) {
10541054
Some(wall_block.clone()),
10551055
Some(corner.rotate(GridRotation::RxYz)),
10561056
)
1057-
.create_box(interior.expand(FaceMap::repeat(1)))
1057+
.create_box(interior.expand(FaceMap::splat(1)))
10581058
.execute(&mut space, &mut transaction::no_outputs)?;
10591059

10601060
// Separators between floors
@@ -1159,7 +1159,7 @@ fn COLORED_BOUNCE(_: Context<'_>) {
11591159
GridPoint::splat(-interior_radius),
11601160
GridSize::splat(u32::try_from(interior_radius).unwrap() * 2 + 1),
11611161
);
1162-
let mut space = Space::empty(interior.expand(FaceMap::repeat(wall_thickness)));
1162+
let mut space = Space::empty(interior.expand(FaceMap::splat(wall_thickness)));
11631163

11641164
// Thick walls + interior cavity
11651165
space.fill_uniform(space.bounds(), &wall_block).unwrap();
@@ -1176,7 +1176,7 @@ fn COLORED_BOUNCE(_: Context<'_>) {
11761176

11771177
// Central reflecting block
11781178
space.fill_uniform(
1179-
GridAab::ORIGIN_CUBE.expand(FaceMap::repeat(1)),
1179+
GridAab::ORIGIN_CUBE.expand(FaceMap::splat(1)),
11801180
&reflecting_block,
11811181
)?;
11821182

all-is-cubes-content/src/dungeon/demo_dungeon.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl DemoTheme {
106106
None,
107107
)
108108
.with_interior(Some(AIR))
109-
.create_box(interior.expand(FaceMap::repeat(1)))
109+
.create_box(interior.expand(FaceMap::splat(1)))
110110
.execute(space, &mut transaction::no_outputs)?;
111111

112112
Ok(())
@@ -309,7 +309,7 @@ impl Theme<Option<DemoRoom>> for DemoTheme {
309309
.y
310310
+ 1;
311311
four_walls(
312-
interior.expand(FaceMap::repeat(1)),
312+
interior.expand(FaceMap::splat(1)),
313313
|origin, along_wall, length, wall_excluding_corners_box| {
314314
let wall = GridRotation::CLOCKWISE.transform(along_wall); // TODO: make four_walls provide this in a nice name
315315
if let WallFeature::Window = room_data.wall_features[wall] {
@@ -411,7 +411,7 @@ pub(crate) async fn demo_dungeon(
411411

412412
let dungeon_grid = DungeonGrid {
413413
room_box: GridAab::from_lower_size([0, 0, 0], [9, 5, 9]),
414-
room_wall_thickness: FaceMap::repeat(1),
414+
room_wall_thickness: FaceMap::splat(1),
415415
gap_between_walls: Size3D::new(1, 1, 1),
416416
};
417417
let perimeter_margin: GridSizeCoord = 30;

all-is-cubes-content/src/dungeon/maze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn generate_maze(seed: u64, requested_rooms: GridSize) -> Maze {
4747
GridAab::from_lower_size([0, 0, 0], requested_rooms),
4848
MazeRoom {
4949
kind: MazeRoomKind::Unoccupied,
50-
passages: FaceMap::repeat(false),
50+
passages: FaceMap::splat(false),
5151
},
5252
);
5353

all-is-cubes-content/src/template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ async fn islands(
370370
&& cell_bounds.size().depth >= margin * 2
371371
{
372372
let occupied_bounds = cell_bounds
373-
.shrink(FaceMap::repeat(10).with(Face6::PY, 25))
373+
.shrink(FaceMap::splat(10).with(Face6::PY, 25))
374374
.unwrap();
375375
wavy_landscape(occupied_bounds, &mut space, &landscape_blocks, 0.5)?;
376376
}
@@ -464,7 +464,7 @@ async fn arbitrary_space(
464464
// Patch spawn position to be reasonable
465465
let bounds = space.bounds();
466466
let mut spawn = space.spawn().clone();
467-
spawn.set_bounds(bounds.expand(FaceMap::repeat(20)));
467+
spawn.set_bounds(bounds.expand(FaceMap::splat(20)));
468468
spawn.set_eye_position(bounds.center());
469469
space.set_spawn(spawn);
470470

all-is-cubes-gpu/src/in_wgpu/light_texture.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn visible_light_volume(space_bounds: GridAab, camera: &Camera) -> GridAab {
4444
.round_up_to_grid();
4545
// Extra volume of 1 extra cube around all sides automatically captures sky light.
4646
visible_bounds
47-
.intersection_cubes(space_bounds.expand(FaceMap::repeat(1)))
47+
.intersection_cubes(space_bounds.expand(FaceMap::splat(1)))
4848
.unwrap_or(GridAab::ORIGIN_CUBE)
4949
}
5050

@@ -163,7 +163,7 @@ impl LightTexture {
163163
///
164164
/// Returns the volume (number of cubes) that needed to be copied to the texture.
165165
pub fn ensure_mapped(&mut self, queue: &wgpu::Queue, space: &Space, region: GridAab) -> usize {
166-
let Some(region) = region.intersection_cubes(space.bounds().expand(FaceMap::repeat(1)))
166+
let Some(region) = region.intersection_cubes(space.bounds().expand(FaceMap::splat(1)))
167167
else {
168168
return 0;
169169
};

0 commit comments

Comments
 (0)