Fixed clippy warnings and fmt

This commit is contained in:
Joshua Barretto 2021-03-06 17:23:03 +00:00
parent 0cbdc2b1b7
commit 911acdd9db
20 changed files with 149 additions and 119 deletions

View File

@ -73,6 +73,8 @@ impl<T> Default for Store<T> {
}
impl<T> Store<T> {
pub fn is_empty(&self) -> bool { self.len == 0 }
pub fn len(&self) -> usize { self.len }
pub fn contains(&self, id: Id<T>) -> bool {

View File

@ -570,7 +570,6 @@ impl<'a> Widget for Map<'a> {
SiteKind::Castle => self.imgs.mmap_site_castle,
SiteKind::Cave => self.imgs.mmap_site_cave,
SiteKind::Tree => self.imgs.mmap_site_tree,
_ => self.imgs.mmap_site_excl,
})
.x_y_position_relative_to(
state.ids.grid,
@ -584,7 +583,6 @@ impl<'a> Widget for Map<'a> {
SiteKind::Castle => self.imgs.mmap_site_castle_hover,
SiteKind::Cave => self.imgs.mmap_site_cave_hover,
SiteKind::Tree => self.imgs.mmap_site_tree_hover,
_ => self.imgs.mmap_site_excl,
})
.image_color(UI_HIGHLIGHT_0)
.with_tooltip(
@ -605,7 +603,7 @@ impl<'a> Widget for Map<'a> {
_ => TEXT_COLOR,
},
SiteKind::Cave => TEXT_COLOR,
_ => TEXT_COLOR,
SiteKind::Tree => TEXT_COLOR,
},
);
// Only display sites that are toggled on
@ -630,8 +628,10 @@ impl<'a> Widget for Map<'a> {
site_btn.set(state.ids.mmap_site_icons[i], ui);
}
},
_ => {
site_btn.set(state.ids.mmap_site_icons[i], ui);
SiteKind::Tree => {
if show_trees {
site_btn.set(state.ids.mmap_site_icons[i], ui);
}
},
}

View File

@ -304,7 +304,6 @@ impl<'a> Widget for MiniMap<'a> {
SiteKind::Castle => self.imgs.mmap_site_castle_bg,
SiteKind::Cave => self.imgs.mmap_site_cave_bg,
SiteKind::Tree => self.imgs.mmap_site_tree,
_ => self.imgs.mmap_site_excl,
})
.x_y_position_relative_to(
state.ids.grid,
@ -335,7 +334,6 @@ impl<'a> Widget for MiniMap<'a> {
SiteKind::Castle => self.imgs.mmap_site_castle,
SiteKind::Cave => self.imgs.mmap_site_cave,
SiteKind::Tree => self.imgs.mmap_site_tree,
_ => self.imgs.mmap_site_excl,
})
.middle_of(state.ids.mmap_site_icons_bgs[i])
.w_h(20.0, 20.0)

View File

@ -515,7 +515,7 @@ impl<V: RectRasterableVol> Terrain<V> {
const AMBIANCE: f32 = 0.15; // 0-1, the proportion of light that should illuminate the rear of an object
let (bias, total, max) = Spiral2d::new()
let (bias, total) = Spiral2d::new()
.take(9)
.map(|rpos| {
let chunk_pos = wpos_chunk + rpos;
@ -535,14 +535,13 @@ impl<V: RectRasterableVol> Terrain<V> {
})
.flatten()
.fold(
(Vec3::broadcast(0.001), 0.0, 0.0f32),
|(bias, total, max), (lpos, level)| {
(Vec3::broadcast(0.001), 0.0),
|(bias, total), (lpos, level)| {
let rpos = lpos.map(|e| e as f32 + 0.5) - wpos;
let level = (*level as f32 - rpos.magnitude()).max(0.0) / SUNLIGHT as f32;
(
bias + rpos.try_normalized().unwrap_or_else(Vec3::zero) * level,
total + level,
max.max(level),
)
},
);
@ -643,7 +642,7 @@ impl<V: RectRasterableVol> Terrain<V> {
// be meshed
span!(guard, "Add chunks with modified blocks to mesh todo list");
// TODO: would be useful if modified blocks were grouped by chunk
for (&pos, &block) in scene_data.state.terrain_changes().modified_blocks.iter() {
for (&pos, &_block) in scene_data.state.terrain_changes().modified_blocks.iter() {
// TODO: Be cleverer about this to avoid remeshing all neighbours. There are a
// few things that can create an 'effect at a distance'. These are
// as follows:

View File

@ -1,4 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Benchmark, Criterion};
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
use rand::prelude::*;
use veloren_world::layer::tree::{ProceduralTree, TreeConfig};
fn tree(c: &mut Criterion) {
@ -6,7 +7,10 @@ fn tree(c: &mut Criterion) {
let mut i = 0;
b.iter(|| {
i += 1;
black_box(ProceduralTree::generate(TreeConfig::OAK, i));
black_box(ProceduralTree::generate(
TreeConfig::oak(&mut thread_rng(), 1.0),
&mut thread_rng(),
));
});
});
@ -15,7 +19,7 @@ fn tree(c: &mut Criterion) {
b.iter_batched(
|| {
i += 1;
ProceduralTree::generate(TreeConfig::OAK, i)
ProceduralTree::generate(TreeConfig::oak(&mut thread_rng(), 1.0), &mut thread_rng())
},
|tree| {
let bounds = tree.get_bounds();

View File

@ -1,4 +1,3 @@
use structopt::StructOpt;
use svg_fmt::*;
use veloren_world::site2::test_site;

View File

@ -68,7 +68,7 @@ impl<'a> Canvas<'a> {
.get(pos - self.wpos())
.ok()
.copied()
.unwrap_or(Block::empty())
.unwrap_or_else(Block::empty)
}
pub fn set(&mut self, pos: Vec3<i32>, block: Block) {

View File

@ -108,7 +108,7 @@ impl Civs {
attempt(5, || {
let (kind, size) = match ctx.rng.gen_range(0..64) {
0..=4 => (SiteKind::Castle, 3),
5..=28 => (SiteKind::Refactor, 6),
// 5..=28 => (SiteKind::Refactor, 6),
29..=31 => (SiteKind::Tree, 4),
_ => (SiteKind::Dungeon, 0),
};

View File

@ -69,10 +69,10 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
let sim = &self.sim;
let turb = Vec2::new(
sim.gen_ctx.turb_x_nz.get((wposf.div(48.0)).into_array()) as f32,
sim.gen_ctx.turb_y_nz.get((wposf.div(48.0)).into_array()) as f32,
) * 12.0;
// let turb = Vec2::new(
// sim.gen_ctx.turb_x_nz.get((wposf.div(48.0)).into_array()) as f32,
// sim.gen_ctx.turb_y_nz.get((wposf.div(48.0)).into_array()) as f32,
// ) * 12.0;
let wposf_turb = wposf; // + turb.map(|e| e as f64);
let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?;

View File

@ -333,7 +333,7 @@ impl TreeConfig {
}
}
pub fn giant(rng: &mut impl Rng, scale: f32, inhabited: bool) -> Self {
pub fn giant(_rng: &mut impl Rng, scale: f32, inhabited: bool) -> Self {
let log_scale = 1.0 + scale.log2().max(0.0);
Self {
@ -380,7 +380,6 @@ impl ProceduralTree {
0,
None,
rng,
true,
);
this.trunk_idx = trunk_idx;
@ -391,6 +390,7 @@ impl ProceduralTree {
// returning the index and AABB of the branch. This AABB gets propagated
// down to the parent and is used later during sampling to cull the branches to
// be sampled.
#[allow(clippy::too_many_arguments)]
fn add_branch(
&mut self,
config: &TreeConfig,
@ -401,7 +401,6 @@ impl ProceduralTree {
depth: usize,
sibling_idx: Option<usize>,
rng: &mut impl Rng,
has_stairs: bool,
) -> (usize, Aabb<f32>) {
let end = start + dir * branch_len;
let line = LineSegment3 { start, end };
@ -412,7 +411,10 @@ impl ProceduralTree {
0.0
};
let has_stairs = /*has_stairs &&*/ config.inhabited && depth < config.max_depth && branch_radius > 6.5 && start.xy().distance(end.xy()) < (start.z - end.z).abs() * 1.5;
let has_stairs = config.inhabited
&& depth < config.max_depth
&& branch_radius > 6.5
&& start.xy().distance(end.xy()) < (start.z - end.z).abs() * 1.5;
let bark_radius = if has_stairs { 5.0 } else { 0.0 } + wood_radius * 0.25;
// The AABB that covers this branch, along with wood and leaves that eminate
@ -477,7 +479,6 @@ impl ProceduralTree {
depth + 1,
child_idx,
rng,
has_stairs,
);
child_idx = Some(branch_idx);
// Parent branches AABBs include the AABBs of child branches to allow for
@ -523,7 +524,7 @@ impl ProceduralTree {
// within its AABB
if branch.aabb.contains_point(pos) {
// Probe this branch
let (this, d2) = branch.is_branch_or_leaves_at(pos, parent);
let (this, _d2) = branch.is_branch_or_leaves_at(pos, parent);
let siblings = branch_or_leaves | Vec4::from(this);

View File

@ -1,6 +1,10 @@
#![deny(unsafe_code)]
#![allow(incomplete_features)]
#![allow(clippy::option_map_unit_fn)]
#![allow(
clippy::option_map_unit_fn,
clippy::blocks_in_if_conditions,
clippy::too_many_arguments
)]
#![deny(clippy::clone_on_ref_ptr)]
#![feature(
arbitrary_enum_discriminant,

View File

@ -29,8 +29,8 @@ use crate::{
column::ColumnGen,
site::Site,
util::{
seed_expan, DHashSet, FastNoise, FastNoise2d, RandomField, RandomPerm, Sampler,
StructureGen2d, CARDINALS, LOCALITY, NEIGHBORS,
seed_expan, DHashSet, FastNoise, FastNoise2d, RandomField, Sampler, StructureGen2d,
CARDINALS, LOCALITY, NEIGHBORS,
},
IndexRef, CONFIG,
};
@ -1570,15 +1570,14 @@ impl WorldSim {
// Vec2::new(rng.gen_range(-16..17), rng.gen_range(-16..17)); }
for cliff in cliffs {
let alt = self.get(cliff).map_or(0.0, |c| c.alt);
Spiral2d::new()
.take((4usize * 2 + 1).pow(2))
.for_each(|rpos| {
let dist = rpos.map(|e| e as f32).magnitude();
if let Some(c) = self.get_mut(cliff + rpos) {
let warp = 1.0 / (1.0 + dist);
c.tree_density *= (1.0 - warp);
c.cliff_height = Lerp::lerp(44.0, 0.0, (-1.0 + dist / 3.5));
c.tree_density *= 1.0 - warp;
c.cliff_height = Lerp::lerp(44.0, 0.0, -1.0 + dist / 3.5);
}
});
}

View File

@ -12,12 +12,8 @@ pub use self::{
settlement::Settlement, tree::Tree,
};
use crate::{column::ColumnSample, site2, Canvas, IndexRef};
use common::{
generation::ChunkSupplement,
terrain::Block,
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
};
use crate::{column::ColumnSample, site2, Canvas};
use common::generation::ChunkSupplement;
use rand::Rng;
use serde::Deserialize;
use vek::*;
@ -121,8 +117,8 @@ impl Site {
SiteKind::Settlement(s) => s.name(),
SiteKind::Dungeon(d) => d.name(),
SiteKind::Castle(c) => c.name(),
SiteKind::Refactor(s) => "Town",
SiteKind::Tree(t) => "Tree",
SiteKind::Refactor(_) => "Town",
SiteKind::Tree(_) => "Giant Tree",
}
}

View File

@ -1,7 +1,7 @@
use crate::{
layer::tree::{ProceduralTree, TreeConfig},
util::{FastNoise, Sampler},
site::SpawnRules,
util::{FastNoise, Sampler},
Canvas, Land,
};
use common::terrain::{Block, BlockKind};
@ -38,7 +38,7 @@ impl Tree {
}
}
pub fn render(&self, canvas: &mut Canvas, dynamic_rng: &mut impl Rng) {
pub fn render(&self, canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
let nz = FastNoise::new(self.seed);
canvas.foreach_col(|canvas, wpos2d, col| {
@ -50,18 +50,38 @@ impl Tree {
return;
}
let mut above = true;
for z in (bounds.min.z..bounds.max.z + 1).rev() {
let wpos = wpos2d.with_z(self.alt + z);
let rposf = (wpos - self.origin.with_z(self.alt)).map(|e| e as f32 + 0.5);
let (branch, leaves, _, _) = self.tree.is_branch_or_leaves_at(rposf);
if leaves {
let dark = Rgb::new(10, 70, 50).map(|e| e as f32);
let light = Rgb::new(80, 140, 10).map(|e| e as f32);
let leaf_col = Lerp::lerp(dark, light, nz.get(rposf.map(|e| e as f64) * 0.05) * 0.5 + 0.5);
canvas.set(wpos, Block::new(BlockKind::Leaves, leaf_col.map(|e| e as u8)));
} else if branch {
canvas.set(wpos, Block::new(BlockKind::Wood, Rgb::new(80, 32, 0)));
if branch || leaves {
if above && col.snow_cover {
canvas.set(
wpos + Vec3::unit_z(),
Block::new(BlockKind::Snow, Rgb::new(255, 255, 255)),
);
}
if leaves {
let dark = Rgb::new(10, 70, 50).map(|e| e as f32);
let light = Rgb::new(80, 140, 10).map(|e| e as f32);
let leaf_col = Lerp::lerp(
dark,
light,
nz.get(rposf.map(|e| e as f64) * 0.05) * 0.5 + 0.5,
);
canvas.set(
wpos,
Block::new(BlockKind::Leaves, leaf_col.map(|e| e as u8)),
);
} else if branch {
canvas.set(wpos, Block::new(BlockKind::Wood, Rgb::new(80, 32, 0)));
}
above = true;
}
}
});

View File

@ -129,7 +129,7 @@ pub trait Structure {
fn render_collect(&self, site: &Site) -> (Store<Primitive>, Vec<(Id<Primitive>, Fill)>) {
let mut tree = Store::default();
let mut fills = Vec::new();
let root = self.render(site, |p| tree.insert(p), |p, f| fills.push((p, f)));
self.render(site, |p| tree.insert(p), |p, f| fills.push((p, f)));
(tree, fills)
}
}

View File

@ -5,18 +5,19 @@ mod tile;
use self::{
gen::{Fill, Primitive, Structure},
plot::{Plot, PlotKind},
tile::{HazardKind, Tile, TileGrid, TileKind, KeepKind, Ori, TILE_SIZE},
tile::{HazardKind, Ori, Tile, TileGrid, TileKind, TILE_SIZE},
};
use crate::{
site::SpawnRules,
util::{attempt, DHashSet, Grid, CARDINALS, LOCALITY, SQUARE_4, SQUARE_9},
util::{attempt, DHashSet, Grid, CARDINALS, SQUARE_4, SQUARE_9},
Canvas, Land,
};
use common::{
astar::Astar,
lottery::Lottery,
spiral::Spiral2d,
store::{Id, Store}, terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize},
store::{Id, Store},
terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize},
vol::RectVolSize,
};
use hashbrown::hash_map::DefaultHashBuilder;
@ -62,7 +63,6 @@ impl Site {
self.wpos_tile(wpos + rpos * tile::TILE_SIZE as i32)
.is_empty()
}),
..SpawnRules::default()
}
}
@ -193,12 +193,10 @@ impl Site {
let search_pos = if rng.gen() {
self.plot(*self.plazas.choose(rng)?).root_tile
+ (dir * 4.0).map(|e: f32| e.round() as i32)
} else if let PlotKind::Road(path) = &self.plot(*self.roads.choose(rng)?).kind {
*path.nodes().choose(rng)? + (dir * 1.0).map(|e: f32| e.round() as i32)
} else {
if let PlotKind::Road(path) = &self.plot(*self.roads.choose(rng)?).kind {
*path.nodes().choose(rng)? + (dir * 1.0).map(|e: f32| e.round() as i32)
} else {
unreachable!()
}
unreachable!()
};
self.find_aabr(search_pos, area_range, min_dims)
@ -360,14 +358,11 @@ impl Site {
* rng.gen_range(16.0..48.0))
.map(|e| e as i32);
if site.plazas.iter().all(|&p| {
site.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2)
}) && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max()
{
Some(tile)
} else {
None
}
Some(tile).filter(|_| {
site.plazas.iter().all(|&p| {
site.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2)
}) && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max()
})
})
.unwrap_or_else(Vec2::zero);
@ -444,21 +439,33 @@ impl Site {
plot: Some(plot),
},
);
site.tiles.set(Vec2::new(aabr.center().x + 2, aabr.center().y + 2), tower.clone());
site.tiles.set(Vec2::new(aabr.center().x + 2, aabr.center().y - 3), tower.clone());
site.tiles.set(Vec2::new(aabr.center().x - 3, aabr.center().y + 2), tower.clone());
site.tiles.set(Vec2::new(aabr.center().x - 3, aabr.center().y - 3), tower.clone());
site.tiles.set(
Vec2::new(aabr.center().x + 2, aabr.center().y + 2),
tower.clone(),
);
site.tiles.set(
Vec2::new(aabr.center().x + 2, aabr.center().y - 3),
tower.clone(),
);
site.tiles.set(
Vec2::new(aabr.center().x - 3, aabr.center().y + 2),
tower.clone(),
);
site.tiles.set(
Vec2::new(aabr.center().x - 3, aabr.center().y - 3),
tower.clone(),
);
site.blit_aabr(
Aabr {
min: aabr.center() - 2,
max: aabr.center() + 2,
},
Tile {
kind: TileKind::Keep(tile::KeepKind::Middle),
plot: Some(plot),
},
);
Aabr {
min: aabr.center() - 2,
max: aabr.center() + 2,
},
Tile {
kind: TileKind::Keep(tile::KeepKind::Middle),
plot: Some(plot),
},
);
castles += 1;
}
@ -486,7 +493,7 @@ impl Site {
self.origin + tile * tile::TILE_SIZE as i32 + tile::TILE_SIZE as i32 / 2
}
pub fn render_tile(&self, canvas: &mut Canvas, dynamic_rng: &mut impl Rng, tpos: Vec2<i32>) {
pub fn render_tile(&self, canvas: &mut Canvas, _dynamic_rng: &mut impl Rng, tpos: Vec2<i32>) {
let tile = self.tiles.get(tpos);
let twpos = self.tile_wpos(tpos);
let border = TILE_SIZE as i32;
@ -497,6 +504,7 @@ impl Site {
})
.flatten();
#[allow(clippy::single_match)]
match &tile.kind {
TileKind::Plaza => {
let near_roads = CARDINALS.iter().filter_map(|rpos| {
@ -510,7 +518,7 @@ impl Site {
}
});
cols.for_each(|(wpos2d, offs)| {
cols.for_each(|(wpos2d, _offs)| {
let wpos2df = wpos2d.map(|e| e as f32);
let dist = near_roads
.clone()
@ -584,6 +592,7 @@ impl Site {
let tile = self.wpos_tile(wpos2d);
let seed = tile.plot.map_or(0, |p| self.plot(p).seed);
#[allow(clippy::single_match)]
match tile.kind {
TileKind::Field /*| TileKind::Road*/ => (-4..5).for_each(|z| canvas.map(
Vec3::new(wpos2d.x, wpos2d.y, col.alt as i32 + z),

View File

@ -26,7 +26,6 @@ impl Plot {
}
pub enum PlotKind {
Field,
House(House),
Plaza,
Castle(Castle),

View File

@ -1,28 +1,28 @@
use super::*;
use crate::{util::SQUARE_4, Land};
use common::terrain::{Block, BlockKind, SpriteKind};
use crate::Land;
use common::terrain::{Block, BlockKind};
use rand::prelude::*;
use vek::*;
pub struct Castle {
entrance_tile: Vec2<i32>,
_entrance_tile: Vec2<i32>,
tile_aabr: Aabr<i32>,
bounds: Aabr<i32>,
_bounds: Aabr<i32>,
alt: i32,
}
impl Castle {
pub fn generate(
land: &Land,
rng: &mut impl Rng,
_rng: &mut impl Rng,
site: &Site,
entrance_tile: Vec2<i32>,
tile_aabr: Aabr<i32>,
) -> Self {
Self {
entrance_tile,
_entrance_tile: entrance_tile,
tile_aabr,
bounds: Aabr {
_bounds: Aabr {
min: site.tile_wpos(tile_aabr.min),
max: site.tile_wpos(tile_aabr.max),
},
@ -39,20 +39,20 @@ impl Structure for Castle {
mut fill: G,
) {
let wall_height = 24;
let thickness = 12;
let _thickness = 12;
let parapet_height = 2;
let parapet_width = 1;
let downwards = 40;
let _downwards = 40;
let tower_height = 12;
let keep_levels = 3;
let keep_level_height = 8;
let keep_height = wall_height + keep_levels * keep_level_height + 1;
let _keep_height = wall_height + keep_levels * keep_level_height + 1;
for x in 0..self.tile_aabr.size().w {
for y in 0..self.tile_aabr.size().h {
let tile_pos = self.tile_aabr.min + Vec2::new(x, y);
let wpos_center = site.tile_center_wpos(tile_pos);
let _wpos_center = site.tile_center_wpos(tile_pos);
let wpos = site.tile_wpos(tile_pos);
let ori = if x == 0 || x == self.tile_aabr.size().w - 1 {
Vec2::new(1, 0)
@ -71,7 +71,7 @@ impl Structure for Castle {
};
let ori_tower = ori_tower_x + ori_tower_y;
match site.tiles.get(tile_pos).kind.clone() {
TileKind::Wall(orientation) => {
TileKind::Wall(_ori) => {
let wall = prim(Primitive::Aabb(Aabb {
min: wpos.with_z(self.alt),
max: (wpos + 6).with_z(self.alt + wall_height + parapet_height),
@ -115,7 +115,7 @@ impl Structure for Castle {
}));
let tower_lower_inner_x = prim(Primitive::Aabb(Aabb {
min: Vec3::new(
wpos.x + 1 * ori_tower.x,
wpos.x + ori_tower.x,
wpos.y + parapet_width,
self.alt + wall_height,
),
@ -128,7 +128,7 @@ impl Structure for Castle {
let tower_lower_inner_y = prim(Primitive::Aabb(Aabb {
min: Vec3::new(
wpos.x + parapet_width,
wpos.y + 1 * ori_tower.y,
wpos.y + ori_tower.y,
self.alt + wall_height,
),
max: Vec3::new(
@ -147,19 +147,19 @@ impl Structure for Castle {
min: Vec3::new(
wpos.x - 1,
wpos.y - 1,
self.alt + wall_height + tower_height - 3 as i32,
self.alt + wall_height + tower_height - 3i32,
),
max: Vec3::new(
wpos.x + 7,
wpos.y + 7,
self.alt + wall_height + tower_height - 1 as i32,
self.alt + wall_height + tower_height - 1i32,
),
}));
let tower_upper2 = prim(Primitive::Aabb(Aabb {
min: Vec3::new(
wpos.x - 2,
wpos.y - 2,
self.alt + wall_height + tower_height - 1 as i32,
self.alt + wall_height + tower_height - 1i32,
),
max: Vec3::new(
wpos.x + 8,
@ -209,11 +209,11 @@ impl Structure for Castle {
}
},
tile::KeepKind::Corner => {},
tile::KeepKind::Wall(orientation) => {
tile::KeepKind::Wall(_ori) => {
for i in 0..keep_levels + 1 {
let height = keep_level_height * i;
let _height = keep_level_height * i;
// TODO clamp value in case of big heights
let window_height = keep_level_height - 3;
let _window_height = keep_level_height - 3;
}
},
}

View File

@ -1,11 +1,11 @@
use super::*;
use crate::{util::SQUARE_4, Land};
use crate::Land;
use common::terrain::{Block, BlockKind, SpriteKind};
use rand::prelude::*;
use vek::*;
pub struct House {
door_tile: Vec2<i32>,
_door_tile: Vec2<i32>,
tile_aabr: Aabr<i32>,
bounds: Aabr<i32>,
alt: i32,
@ -22,7 +22,7 @@ impl House {
tile_aabr: Aabr<i32>,
) -> Self {
Self {
door_tile,
_door_tile: door_tile,
tile_aabr,
bounds: Aabr {
min: site.tile_wpos(tile_aabr.min),

View File

@ -7,6 +7,7 @@ pub const TILE_SIZE: u32 = 6;
pub const ZONE_SIZE: u32 = 16;
pub const ZONE_RADIUS: u32 = 16;
pub const TILE_RADIUS: u32 = ZONE_SIZE * ZONE_RADIUS;
#[allow(dead_code)]
pub const MAX_BLOCK_RADIUS: u32 = TILE_SIZE * TILE_RADIUS;
pub struct TileGrid {
@ -48,7 +49,7 @@ impl TileGrid {
Grid::populate_from(Vec2::broadcast(ZONE_SIZE as i32), |_| None)
})
.get_mut(tpos.map(|e| e.rem_euclid(ZONE_SIZE as i32)))
.map(|tile| tile.get_or_insert_with(|| Tile::empty()))
.map(|tile| tile.get_or_insert_with(Tile::empty))
})
}
@ -87,15 +88,14 @@ impl TileGrid {
let mut last_growth = 0;
for i in 0..32 {
if i - last_growth >= 4 {
break;
} else if aabr.size().product()
+ if i % 2 == 0 {
aabr.size().h
} else {
aabr.size().w
}
> area_range.end as i32
if i - last_growth >= 4
|| aabr.size().product()
+ if i % 2 == 0 {
aabr.size().h
} else {
aabr.size().w
}
> area_range.end as i32
{
break;
} else {
@ -239,5 +239,5 @@ pub enum Ori {
}
impl Ori {
pub fn dir(self) -> Vec2<i32> {CARDINALS[self as u8 as usize]}
pub fn dir(self) -> Vec2<i32> { CARDINALS[self as u8 as usize] }
}