mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed extra foundations
This commit is contained in:
parent
e3c4e34edb
commit
25d6ab03aa
@ -158,6 +158,7 @@ impl TownState {
|
|||||||
let houses = vol.gen_houses(rng, 60);
|
let houses = vol.gen_houses(rng, 60);
|
||||||
vol.gen_walls();
|
vol.gen_walls();
|
||||||
vol.resolve_modules(rng);
|
vol.resolve_modules(rng);
|
||||||
|
vol.cull_unused();
|
||||||
|
|
||||||
Some(Self {
|
Some(Self {
|
||||||
center: Vec3::new(center.x, center.y, alt),
|
center: Vec3::new(center.x, center.y, alt),
|
||||||
@ -321,7 +322,7 @@ impl TownVol {
|
|||||||
let mut outer = self.floodfill(outer, |_, col| col.is_empty());
|
let mut outer = self.floodfill(outer, |_, col| col.is_empty());
|
||||||
|
|
||||||
let mut walls = HashSet::new();
|
let mut walls = HashSet::new();
|
||||||
self.floodfill([self.size() / 2].iter().copied().collect(), |pos, _| {
|
let inner = self.floodfill([self.size() / 2].iter().copied().collect(), |pos, _| {
|
||||||
if outer.contains(&pos) {
|
if outer.contains(&pos) {
|
||||||
walls.insert(pos);
|
walls.insert(pos);
|
||||||
false
|
false
|
||||||
@ -472,6 +473,26 @@ impl TownVol {
|
|||||||
houses
|
houses
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cull_unused(&mut self) {
|
||||||
|
for x in 0..self.size().x {
|
||||||
|
for y in 0..self.size().y {
|
||||||
|
for z in self.col_range(Vec2::new(x, y)).unwrap() {
|
||||||
|
let pos = Vec3::new(x, y, z);
|
||||||
|
|
||||||
|
// Remove foundations that don't have anything on top of them
|
||||||
|
if self.get(pos).unwrap().is_foundation()
|
||||||
|
&& self
|
||||||
|
.get(pos + Vec3::unit_z())
|
||||||
|
.map(Vox::is_empty)
|
||||||
|
.unwrap_or(true)
|
||||||
|
{
|
||||||
|
self.set(pos, TownCell::empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn resolve_modules(&mut self, rng: &mut impl Rng) {
|
fn resolve_modules(&mut self, rng: &mut impl Rng) {
|
||||||
fn classify(cell: &TownCell, this_cell: &TownCell) -> ModuleKind {
|
fn classify(cell: &TownCell, this_cell: &TownCell) -> ModuleKind {
|
||||||
match (&cell.kind, &this_cell.kind) {
|
match (&cell.kind, &this_cell.kind) {
|
||||||
|
Loading…
Reference in New Issue
Block a user