On wide or narrow sidewalks, draw pedestrians at the edges -- stop

hardcoding a sidewalk thickness
This commit is contained in:
Dustin Carlino 2022-04-24 09:55:24 +01:00
parent 5890e600d3
commit 91ccd29f6d
2 changed files with 10 additions and 7 deletions

View File

@ -66,11 +66,8 @@ impl Pt2D {
self.y self.y
} }
// TODO better name /// If distance is negative, this projects a point in theta.opposite()
pub fn project_away(self, dist: Distance, theta: Angle) -> Pt2D { pub fn project_away(self, dist: Distance, theta: Angle) -> Pt2D {
// If negative, caller should use theta.opposite()
assert!(dist >= Distance::ZERO);
let (sin, cos) = theta.normalized_radians().sin_cos(); let (sin, cos) = theta.normalized_radians().sin_cos();
Pt2D::new( Pt2D::new(
self.x() + dist.inner_meters() * cos, self.x() + dist.inner_meters() * cos,

View File

@ -721,7 +721,13 @@ impl Pedestrian {
} else { } else {
270.0 270.0
}; };
let project_away = match on {
Traversable::Lane(l) => map.get_l(l).width / 2.0 - pedestrian_body_radius(),
// Width of a crossing is fuzzy, but this could likely be improved
Traversable::Turn(_) => pedestrian_body_radius(),
};
let mut intent = None; let mut intent = None;
let (pos, facing) = match self.state { let (pos, facing) = match self.state {
PedState::Crossing { PedState::Crossing {
ref dist_int, ref dist_int,
@ -746,7 +752,7 @@ impl Pedestrian {
intent = Some(Intent::SteepUphill); intent = Some(Intent::SteepUphill);
} }
( (
pos.project_away(pedestrian_body_radius(), facing.rotate_degs(angle_offset)), pos.project_away(project_away, facing.rotate_degs(angle_offset)),
facing, facing,
) )
} }
@ -758,7 +764,7 @@ impl Pedestrian {
orig_angle orig_angle
}; };
( (
pos.project_away(pedestrian_body_radius(), facing.rotate_degs(angle_offset)), pos.project_away(project_away, facing.rotate_degs(angle_offset)),
facing, facing,
) )
} }
@ -812,7 +818,7 @@ impl Pedestrian {
let (pt, angle) = self.goal.sidewalk_pos.pt_and_angle(map); let (pt, angle) = self.goal.sidewalk_pos.pt_and_angle(map);
// Stand on the far side of the sidewalk (by the bus stop), facing the road // Stand on the far side of the sidewalk (by the bus stop), facing the road
( (
pt.project_away(pedestrian_body_radius(), angle.rotate_degs(angle_offset)), pt.project_away(project_away, angle.rotate_degs(angle_offset)),
angle.rotate_degs(-angle_offset), angle.rotate_degs(-angle_offset),
) )
} }