mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix path finding calculation of starting point
When a chaser's route finishes calculating, the chaser may already be a few blocks away from the starting position, thanks to movement inertia. The path finding code finds the point along the route closest to the chaser's position. This calculation only considered the xy coordinates when finding the closest point. This caused issues whenever the calculated route goes below the chaser's position (for example, when the chaser is on top of a bridge and the route circled around to go under the bridge). In this case, there was a chance that the closest point was the one below the bridge. This caused the chaser to try to move directly to a directly inaccessible block. The fix was to remove the xy() filter so that the closest point algorithm also considered the z coordinate.
This commit is contained in:
parent
b681ad79ce
commit
74d4e4f45e
@ -428,10 +428,7 @@ impl Chaser {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.min_by_key(|(_, node)| {
|
||||
node.xy()
|
||||
.map(|e| e as f32)
|
||||
.distance_squared(pos.xy() + tgt_dir)
|
||||
as i32
|
||||
node.map(|e| e as f32).distance_squared(pos + tgt_dir) as i32
|
||||
})
|
||||
.map(|(idx, _)| idx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user