diff --git a/world/src/site2/gen.rs b/world/src/site2/gen.rs index 617e6723dd..7681fc3c73 100644 --- a/world/src/site2/gen.rs +++ b/world/src/site2/gen.rs @@ -50,7 +50,7 @@ pub enum Primitive { Intersect(Id, Id), Union(Id, Id), // Not commutative - Diff(Id, Id), + Subtract(Id, Id), // Operators Rotate(Id, Mat3), Translate(Id, Vec3), @@ -66,8 +66,8 @@ impl Primitive { Self::Union(a.into(), b.into()) } - pub fn diff(a: impl Into>, b: impl Into>) -> Self { - Self::Diff(a.into(), b.into()) + pub fn subtract(a: impl Into>, b: impl Into>) -> Self { + Self::Subtract(a.into(), b.into()) } pub fn sampling(a: impl Into>, f: Box) -> bool>) -> Self { @@ -225,7 +225,7 @@ impl Fill { Primitive::Union(a, b) => { self.contains_at(tree, *a, pos) || self.contains_at(tree, *b, pos) }, - Primitive::Diff(a, b) => { + Primitive::Subtract(a, b) => { self.contains_at(tree, *a, pos) && !self.contains_at(tree, *b, pos) }, Primitive::Rotate(prim, mat) => { @@ -340,7 +340,7 @@ impl Fill { self.get_bounds_inner(tree, *b), |a, b| a.union(b), )?, - Primitive::Diff(a, _) => self.get_bounds_inner(tree, *a)?, + Primitive::Subtract(a, _) => self.get_bounds_inner(tree, *a)?, Primitive::Rotate(prim, mat) => { let aabb = self.get_bounds_inner(tree, *prim)?; let extent = *mat * Vec3::from(aabb.size()); @@ -452,8 +452,8 @@ impl<'a> PrimitiveRef<'a> { self.painter.prim(Primitive::intersect(self, other)) } - pub fn and_not(self, other: impl Into>) -> PrimitiveRef<'a> { - self.painter.prim(Primitive::diff(self, other)) + pub fn subtract(self, other: impl Into>) -> PrimitiveRef<'a> { + self.painter.prim(Primitive::subtract(self, other)) } pub fn fill(self, fill: Fill) { self.painter.fill(self, fill); } @@ -498,7 +498,7 @@ pub fn aabb_corners Id>( min: aabb.min + vec, max: aabb.max - vec, })); - prim(Primitive::Diff(ret, sub)) + prim(Primitive::Subtract(ret, sub)) }; let mut ret = prim(Primitive::Aabb(aabb)); ret = f(prim, ret, Vec3::new(1, 0, 0)); diff --git a/world/src/site2/plot/castle.rs b/world/src/site2/plot/castle.rs index 58d0b0a073..490eaa4e74 100644 --- a/world/src/site2/plot/castle.rs +++ b/world/src/site2/plot/castle.rs @@ -200,7 +200,7 @@ impl Structure for Castle { tower_top_outer .union(tower_top_inner) - .and_not(tower_top_outer.intersect(tower_top_inner)) + .subtract(tower_top_outer.intersect(tower_top_inner)) .fill(Fill::Brick(BlockKind::Rock, wall_rgb, 12)); for x in (wpos.x..wpos.x + ts).step_by(2 * parapet_gap as usize) { diff --git a/world/src/site2/plot/dungeon.rs b/world/src/site2/plot/dungeon.rs index bed6616b1d..82498e7003 100644 --- a/world/src/site2/plot/dungeon.rs +++ b/world/src/site2/plot/dungeon.rs @@ -1151,7 +1151,7 @@ impl Floor { } lighting_mask_x .union(lighting_mask_y) - .and_not(lighting_mask_x.intersect(lighting_mask_y)) + .subtract(lighting_mask_x.intersect(lighting_mask_y)) }; // Declare collections of various disjoint primitives that need postprocessing @@ -1184,7 +1184,7 @@ impl Floor { tile_aabr, floor_z..floor_z + 1, ))); - let sprite_layer = painter.prim(Primitive::diff(sprite_layer, wall_contours)); + let sprite_layer = painter.prim(Primitive::subtract(sprite_layer, wall_contours)); // Lights are 2 units above the floor, and aligned with the `lighting_mask` grid let lighting_plane = painter.prim(Primitive::Aabb(aabr_with_z( @@ -1226,7 +1226,7 @@ impl Floor { max: (aabb.max - Vec3::new(1, 1, 0)).with_z(floor_z + i + 1), })); - light = painter.prim(Primitive::diff(light, inner)); + light = painter.prim(Primitive::subtract(light, inner)); lights = painter.prim(Primitive::union(light, lights)); } } @@ -1263,7 +1263,7 @@ impl Floor { tile_aabr, floor_z - 7..floor_z, ))); - let tile_pit = painter.prim(Primitive::diff(tile_pit, wall_contours)); + let tile_pit = painter.prim(Primitive::subtract(tile_pit, wall_contours)); painter.fill(tile_pit, Fill::Block(vacant)); // Fill with lava @@ -1271,7 +1271,7 @@ impl Floor { tile_aabr, floor_z - 7..floor_z - 5, ))); - let tile_lava = painter.prim(Primitive::diff(tile_lava, wall_contours)); + let tile_lava = painter.prim(Primitive::subtract(tile_lava, wall_contours)); //pits.push(tile_pit); //pits.push(tile_lava); painter.fill(tile_lava, Fill::Block(lava)); @@ -1348,7 +1348,7 @@ impl Floor { tile_aabr, floor_z..floor_z + height, ))); - let tile_air = painter.prim(Primitive::diff(tile_air, wall_contours)); + let tile_air = painter.prim(Primitive::subtract(tile_air, wall_contours)); painter.fill(tile_air, Fill::Block(vacant)); // Place torches on the walls with the aforementioned spacing @@ -1359,7 +1359,7 @@ impl Floor { // Defer chest/floor sprite placement if let Some((chest_sprite, chest_sprite_fill)) = chests { - let chest_sprite = painter.prim(Primitive::diff(chest_sprite, wall_contours)); + let chest_sprite = painter.prim(Primitive::subtract(chest_sprite, wall_contours)); sprites.push((chest_sprite, chest_sprite_fill)); } @@ -1397,7 +1397,7 @@ impl Floor { // Prevent sprites from floating above the stairs let stair_bb_up = painter.prim(Primitive::translate(*stair_bb, Vec3::unit_z())); for (sprite, _) in sprites.iter_mut() { - *sprite = painter.prim(Primitive::diff(*sprite, stair_bb_up)); + *sprite = painter.prim(Primitive::subtract(*sprite, stair_bb_up)); } } // Place the stairs themselves, and lights within the stairwells diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index a233ad216e..2d5d1f8ad3 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -600,7 +600,7 @@ impl Structure for House { let walls = outer_level .union(inner_level) - .and_not(outer_level.intersect(inner_level)); + .subtract(outer_level.intersect(inner_level)); // Wall Pillars // Only upper non-stone floors have wooden beams in the walls @@ -1368,11 +1368,11 @@ impl Structure for House { let window_ori = if self.front % 2 == 0 { 0 } else { 2 }; if valid_dormer { painter.fill( - painter.prim(Primitive::diff(dormer_box, shed)), + painter.prim(Primitive::subtract(dormer_box, shed)), Fill::Brick(BlockKind::Wood, Rgb::new(200, 180, 150), 24), ); painter.fill( - painter.prim(Primitive::diff(dormer_roof, shed)), + painter.prim(Primitive::subtract(dormer_roof, shed)), Fill::Block(Block::new(BlockKind::Wood, self.roof_color)), ); painter.fill(window_cavity, Fill::Block(Block::empty()));