More plot generation work

This commit is contained in:
Joshua Barretto 2021-03-01 23:43:26 +00:00
parent 66dc24dab1
commit 7bf62d59fd
3 changed files with 17 additions and 17 deletions

View File

@ -68,8 +68,8 @@ impl Fill {
pub trait Structure {
fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Fill)>(
&self,
emit_prim: F,
emit_fill: G,
prim: F,
fill: G,
) {}
// Generate a primitive tree and fills for this structure

View File

@ -500,7 +500,7 @@ impl Site {
// }
// },
// _ => {},
// }
// }
// });
}
}

View File

@ -28,32 +28,32 @@ impl House {
impl Structure for House {
fn render<F: FnMut(Primitive) -> Id<Primitive>, 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),
})),