More tolerant pathfinding

This commit is contained in:
Joshua Barretto
2020-07-03 20:30:21 +01:00
committed by jshipsey
parent db26c10299
commit 177bd7a128
5 changed files with 13 additions and 6 deletions

View File

@ -266,7 +266,10 @@ where
.map(move |(dir, _)| pos + *dir), .map(move |(dir, _)| pos + *dir),
) )
}; };
let transition = |_: &Vec3<i32>, _: &Vec3<i32>| 1.0; let transition = |a: &Vec3<i32>, b: &Vec3<i32>| {
((*a - *b) * Vec3::new(1, 1, 3)).map(|e| e.abs()).reduce_max() as f32
+ endf.distance((*b).map(|e| e as f32)) * 0.01
};
let satisfied = |pos: &Vec3<i32>| pos == &end; let satisfied = |pos: &Vec3<i32>| pos == &end;
let mut new_astar = match astar.take() { let mut new_astar = match astar.take() {

View File

@ -67,7 +67,7 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
}; };
update.vel.0 = update.vel.0 =
update.vel.0 + Vec2::broadcast(data.dt.0) * data.inputs.move_dir * accel * efficiency; update.vel.0 + Vec2::broadcast(data.dt.0) * data.inputs.move_dir * accel * efficiency;
handle_orientation(data, update, 20.0); handle_orientation(data, update, 20.0);
} }

View File

@ -32,6 +32,7 @@ impl<'a> System<'a> for Sys {
Write<'a, EventBus<ServerEvent>>, Write<'a, EventBus<ServerEvent>>,
Entities<'a>, Entities<'a>,
ReadStorage<'a, Pos>, ReadStorage<'a, Pos>,
ReadStorage<'a, Vel>,
ReadStorage<'a, Ori>, ReadStorage<'a, Ori>,
ReadStorage<'a, Scale>, ReadStorage<'a, Scale>,
ReadStorage<'a, Stats>, ReadStorage<'a, Stats>,
@ -55,6 +56,7 @@ impl<'a> System<'a> for Sys {
event_bus, event_bus,
entities, entities,
positions, positions,
velocities,
orientations, orientations,
scales, scales,
stats, stats,
@ -71,6 +73,7 @@ impl<'a> System<'a> for Sys {
for ( for (
entity, entity,
pos, pos,
vel,
ori, ori,
alignment, alignment,
loadout, loadout,
@ -82,6 +85,7 @@ impl<'a> System<'a> for Sys {
) in ( ) in (
&entities, &entities,
&positions, &positions,
&velocities,
&orientations, &orientations,
alignments.maybe(), alignments.maybe(),
&loadouts, &loadouts,
@ -122,7 +126,7 @@ impl<'a> System<'a> for Sys {
// and so can afford to be less precise when trying to move around // and so can afford to be less precise when trying to move around
// the world (especially since they would otherwise get stuck on // the world (especially since they would otherwise get stuck on
// obstacles that smaller entities would not). // obstacles that smaller entities would not).
let traversal_tolerance = scale; let traversal_tolerance = scale + vel.0.magnitude() * 0.35;
let mut do_idle = false; let mut do_idle = false;
let mut choose_target = false; let mut choose_target = false;

View File

@ -221,8 +221,9 @@ impl Animation for RunAnimation {
skeleton_attr.torso_front.1 + shortalt * 2.5, skeleton_attr.torso_front.1 + shortalt * 2.5,
) * skeleton_attr.scaler ) * skeleton_attr.scaler
/ 11.0; / 11.0;
next.torso_front.ori = Quaternion::rotation_x(x_tilt) * next.torso_front.ori = Quaternion::rotation_x(x_tilt)
Quaternion::rotation_x(short * 0.13) * Quaternion::rotation_z(tilt * -1.5); * Quaternion::rotation_x(short * 0.13)
* Quaternion::rotation_z(tilt * -1.5);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0; next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset = Vec3::new( next.torso_back.offset = Vec3::new(

View File

@ -2253,7 +2253,6 @@ impl<S: Skeleton> FigureState<S> {
visible: false, visible: false,
last_pos: None, last_pos: None,
avg_vel: Vec3::zero(), avg_vel: Vec3::zero(),
} }
} }