Fix paths (sorta) and rock moss.

This commit is contained in:
Joshua Yanovski 2022-07-18 09:19:20 -07:00
parent a3491d5073
commit 0b91f5ba90
2 changed files with 7 additions and 7 deletions

View File

@ -69,17 +69,17 @@ pub fn apply_paths_to(canvas: &mut Canvas) {
// Try to use the column at the centre of the path for sampling to make them
// flatter
let col_pos = -info.wpos().map(|e| e as f32) + path_nearest;
let col00 = info.col(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(0, 0));
let col10 = info.col(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(1, 0));
let col01 = info.col(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(0, 1));
let col11 = info.col(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(1, 1));
let col00 = info.col_or_gen(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(0, 0));
let col10 = info.col_or_gen(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(1, 0));
let col01 = info.col_or_gen(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(0, 1));
let col11 = info.col_or_gen(info.wpos() + col_pos.map(|e| e.floor() as i32) + Vec2::new(1, 1));
let col_attr = |col: &ColumnSample| {
Vec3::new(col.riverless_alt, col.alt, col.water_dist.unwrap_or(1000.0))
};
let [riverless_alt, alt, water_dist] = match (col00, col10, col01, col11) {
(Some(col00), Some(col10), Some(col01), Some(col11)) => Lerp::lerp(
Lerp::lerp(col_attr(col00), col_attr(col10), path_nearest.x.fract()),
Lerp::lerp(col_attr(col01), col_attr(col11), path_nearest.x.fract()),
Lerp::lerp(col_attr(&col00), col_attr(&col10), path_nearest.x.fract()),
Lerp::lerp(col_attr(&col01), col_attr(&col11), path_nearest.x.fract()),
path_nearest.y.fract(),
),
_ => col_attr(col),

View File

@ -122,7 +122,6 @@ pub fn apply_rocks_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
} */
/* let mut is_top = true; */
let mut last_block = Block::empty();
(/*bounds*/aabb.min.x../*bounds*/aabb.max.x).for_each(|x| {
(/*bounds*/aabb.min.y../*bounds*/aabb.max.y).for_each(|y| {
let col = if let Some(col) = info.col(Vec2::new(x, y)) {
@ -131,6 +130,7 @@ pub fn apply_rocks_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
// NOTE: Should never happen as we're always within the render area.
return;
};
let mut last_block = Block::empty();
for z in (/*bounds*/aabb.min.z../*bounds*/aabb.max.z).rev() {
let wpos = Vec3::new(x, y, z);
let model_pos = wpos - rock.wpos;