From 7bf62d59fd38e55538523946f575a89d3783c70f Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 1 Mar 2021 23:43:26 +0000 Subject: [PATCH] More plot generation work --- world/src/site2/gen.rs | 4 ++-- world/src/site2/mod.rs | 2 +- world/src/site2/plot/house.rs | 28 ++++++++++++++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/world/src/site2/gen.rs b/world/src/site2/gen.rs index 244e1ff196..c72c02d3f6 100644 --- a/world/src/site2/gen.rs +++ b/world/src/site2/gen.rs @@ -68,8 +68,8 @@ impl Fill { pub trait Structure { fn render Id, G: FnMut(Fill)>( &self, - emit_prim: F, - emit_fill: G, + prim: F, + fill: G, ) {} // Generate a primitive tree and fills for this structure diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index 2f3dcbac5d..3b11c32a3b 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -500,7 +500,7 @@ impl Site { // } // }, // _ => {}, - // } + // } // }); } } diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index dd6e4f0f2d..6a503c87b0 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -28,32 +28,32 @@ impl House { impl Structure for House { fn render Id, G: FnMut(Fill)>( &self, - mut emit_prim: F, - mut emit_fill: G, + mut prim: F, + mut fill: G, ) { let storey = 8; let roof = storey * self.levels as i32; let foundations = 8; // Walls - let wall = emit_prim(Primitive::Aabb(Aabb { + let wall = prim(Primitive::Aabb(Aabb { min: Vec3::new(self.bounds.min.x, self.bounds.min.y, self.alt - foundations), max: Vec3::new(self.bounds.max.x, self.bounds.max.y, self.alt + roof), })); - let inner = emit_prim(Primitive::Aabb(Aabb { + let inner = prim(Primitive::Aabb(Aabb { min: Vec3::new(self.bounds.min.x + 1, self.bounds.min.y + 1, self.alt + 0), max: Vec3::new(self.bounds.max.x - 1, self.bounds.max.y - 1, self.alt + roof), })); - emit_fill(Fill { - prim: emit_prim(Primitive::Xor(wall, inner)), + fill(Fill { + prim: prim(Primitive::Xor(wall, inner)), block: Block::new(BlockKind::Rock, Rgb::new(181, 170, 148)), }); // Floor for i in 0..self.levels + 1 { let height = storey * i as i32; - emit_fill(Fill { - prim: emit_prim(Primitive::Aabb(Aabb { + fill(Fill { + prim: prim(Primitive::Aabb(Aabb { min: Vec3::new(self.bounds.min.x, self.bounds.min.y, self.alt + height + 0), max: Vec3::new(self.bounds.max.x, self.bounds.max.y, self.alt + height + 1), })), @@ -64,8 +64,8 @@ impl Structure for House { // Corner pillars for &rpos in SQUARE_4.iter() { let pos = self.bounds.min + (self.bounds.max - self.bounds.min) * rpos; - emit_fill(Fill { - prim: emit_prim(Primitive::Aabb(Aabb { + fill(Fill { + prim: prim(Primitive::Aabb(Aabb { min: Vec3::new(pos.x - 1, pos.y - 1, self.alt - foundations), max: Vec3::new(pos.x + 1, pos.y + 1, self.alt + roof), })), @@ -78,8 +78,8 @@ impl Structure for House { let roof_height = (self.bounds.min - self.bounds.max).map(|e| e.abs()).reduce_min() / 2 + roof_lip; // Roof - emit_fill(Fill { - prim: emit_prim(Primitive::Pyramid { + fill(Fill { + prim: prim(Primitive::Pyramid { aabb: Aabb { min: Vec3::new(self.bounds.min.x - roof_lip, self.bounds.min.y - roof_lip, self.alt + roof), max: Vec3::new(self.bounds.max.x + roof_lip, self.bounds.max.y + roof_lip, self.alt + roof + roof_height), @@ -90,8 +90,8 @@ impl Structure for House { }); // Foundations - emit_fill(Fill { - prim: emit_prim(Primitive::Aabb(Aabb { + fill(Fill { + prim: prim(Primitive::Aabb(Aabb { min: Vec3::new(self.bounds.min.x - 1, self.bounds.min.y - 1, self.alt - foundations), max: Vec3::new(self.bounds.max.x + 1, self.bounds.max.y + 1, self.alt + 1), })),