mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use .downhill for waypoint generation
This commit is contained in:
parent
631124f3fc
commit
a4573f6fb2
@ -1461,32 +1461,14 @@ impl WorldSim {
|
|||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.filter_map(|(i, j)| {
|
.filter_map(|(i, j)| {
|
||||||
let mut pos = Vec2::new(i as i32, j as i32);
|
let mut pos = Vec2::new(i as i32, j as i32);
|
||||||
|
|
||||||
// Slide the waypoints down hills
|
// Slide the waypoints down hills
|
||||||
for _ in 0..32 {
|
const MAX_ITERS: usize = 64;
|
||||||
let last_pos = pos;
|
for _ in 0..MAX_ITERS {
|
||||||
let chunk = this.get(pos)?;
|
match this.get(pos)?.downhill {
|
||||||
|
Some(downhill) => pos = downhill,
|
||||||
for dir in [
|
None => return Some(pos),
|
||||||
Vec2::new(1, 0),
|
|
||||||
Vec2::new(-1, 0),
|
|
||||||
Vec2::new(0, 1),
|
|
||||||
Vec2::new(0, -1),
|
|
||||||
]
|
|
||||||
.iter()
|
|
||||||
{
|
|
||||||
const MAX_HEIGHT_DIFF: f32 = 8.0;
|
|
||||||
let tgt_chunk = this.get(pos + *dir)?;
|
|
||||||
if tgt_chunk.alt + MAX_HEIGHT_DIFF < chunk.alt && !tgt_chunk.is_underwater {
|
|
||||||
pos += *dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if last_pos == pos {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(pos)
|
Some(pos)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user