mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Brick fill
This commit is contained in:
parent
173a127d5e
commit
0ede7d3899
@ -1,7 +1,8 @@
|
||||
use super::*;
|
||||
use crate::util::{RandomField, Sampler};
|
||||
use common::{
|
||||
store::{Id, Store},
|
||||
terrain::Block,
|
||||
terrain::{Block, BlockKind},
|
||||
};
|
||||
use vek::*;
|
||||
|
||||
@ -20,6 +21,7 @@ pub enum Primitive {
|
||||
|
||||
pub enum Fill {
|
||||
Block(Block),
|
||||
Brick(BlockKind, Rgb<u8>, u8),
|
||||
}
|
||||
|
||||
impl Fill {
|
||||
@ -71,6 +73,12 @@ impl Fill {
|
||||
if self.contains_at(tree, prim, pos) {
|
||||
match self {
|
||||
Fill::Block(block) => Some(*block),
|
||||
Fill::Brick(bk, col, range) => Some(Block::new(
|
||||
*bk,
|
||||
*col + (RandomField::new(13)
|
||||
.get((pos + Vec3::new(pos.z, pos.z, 0)) / Vec3::new(2, 2, 1))
|
||||
% *range as u32) as u8,
|
||||
)),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
@ -98,16 +98,19 @@ impl Site {
|
||||
w: u16,
|
||||
) -> Option<Id<Plot>> {
|
||||
const MAX_ITERS: usize = 4096;
|
||||
let range = -(w as i32) / 2..w as i32 - w as i32 / 2;
|
||||
let range = -(w as i32) / 2..w as i32 - (w as i32 + 1) / 2;
|
||||
let heuristic = |tile: &Vec2<i32>| {
|
||||
let mut max_cost = (tile.distance_squared(b) as f32).sqrt();
|
||||
for y in range.clone() {
|
||||
for x in range.clone() {
|
||||
if self.tiles.get(*tile + Vec2::new(x, y)).is_obstacle() {
|
||||
return 1000.0;
|
||||
max_cost = max_cost.max(1000.0);
|
||||
} else if !self.tiles.get(*tile + Vec2::new(x, y)).is_empty() {
|
||||
max_cost = max_cost.max(25.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
(tile.distance_squared(b) as f32).sqrt()
|
||||
max_cost
|
||||
};
|
||||
let path = Astar::new(MAX_ITERS, a, &heuristic, DefaultHashBuilder::default())
|
||||
.poll(
|
||||
@ -488,7 +491,7 @@ impl Site {
|
||||
.map(|aabr| aabr.distance_to_point(wpos2df))
|
||||
.min_by_key(|d| (*d * 100.0) as i32);
|
||||
|
||||
if dist.map_or(false, |d| d <= 3.0) {
|
||||
if dist.map_or(false, |d| d <= 1.5) {
|
||||
let alt = canvas.col(wpos2d).map_or(0, |col| col.alt as i32);
|
||||
(-8..6).for_each(|z| {
|
||||
canvas.map(Vec3::new(wpos2d.x, wpos2d.y, alt + z), |b| {
|
||||
@ -521,8 +524,8 @@ impl Site {
|
||||
if let TileKind::Road { a, b, w } = &tile.kind {
|
||||
if let Some(PlotKind::Road(path)) = tile.plot.map(|p| &self.plot(p).kind) {
|
||||
Some((LineSegment2 {
|
||||
start: self.tile_wpos(path.nodes()[*a as usize]).map(|e| e as f32),
|
||||
end: self.tile_wpos(path.nodes()[*b as usize]).map(|e| e as f32),
|
||||
start: self.tile_center_wpos(path.nodes()[*a as usize]).map(|e| e as f32),
|
||||
end: self.tile_center_wpos(path.nodes()[*b as usize]).map(|e| e as f32),
|
||||
}, *w))
|
||||
} else {
|
||||
None
|
||||
|
@ -68,7 +68,7 @@ impl Structure for House {
|
||||
}));
|
||||
fill(
|
||||
outer,
|
||||
Fill::Block(Block::new(BlockKind::Rock, Rgb::new(181, 170, 148))),
|
||||
Fill::Brick(BlockKind::Rock, Rgb::new(80, 75, 85), 24),
|
||||
);
|
||||
fill(inner, Fill::Block(Block::empty()));
|
||||
let walls = prim(Primitive::Xor(outer, inner));
|
||||
@ -149,8 +149,8 @@ impl Structure for House {
|
||||
// Floor
|
||||
fill(
|
||||
prim(Primitive::Aabb(Aabb {
|
||||
min: self.bounds.min.with_z(self.alt + height),
|
||||
max: (self.bounds.max + 1).with_z(self.alt + height + 1),
|
||||
min: (self.bounds.min + 1).with_z(self.alt + height),
|
||||
max: self.bounds.max.with_z(self.alt + height + 1),
|
||||
})),
|
||||
Fill::Block(Block::new(BlockKind::Rock, Rgb::new(89, 44, 14))),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user