diff --git a/docs/TODO_phase3.md b/docs/TODO_phase3.md index 6c55072e8d..27ac8ed162 100644 --- a/docs/TODO_phase3.md +++ b/docs/TODO_phase3.md @@ -7,7 +7,6 @@ - when parking is full or no parking at goal road, roam until parking is found - code cleanup - - try to simplify straw_model step (less phases?) - figure out responsibility btwn agents and managers, then fix up visibility - rng should live in a scenario spec layer, not in the sim itself @@ -27,9 +26,9 @@ ## pedestrians -- make them obey intersections (deterministically!) - make them start and end at buildings - trim the sidewalk path to the edge of a building +- render overlapping peds reasonably ## General diff --git a/sim/src/draw_ped.rs b/sim/src/draw_ped.rs index 07ac7816c0..503bd5e29f 100644 --- a/sim/src/draw_ped.rs +++ b/sim/src/draw_ped.rs @@ -1,28 +1,47 @@ use ezgui::GfxCtx; use geom::Pt2D; use graphics; -use map_model::geometry; +use map_model::{geometry, Turn}; use PedestrianID; const RADIUS: f64 = 1.0; // TODO should this live in editor/render? -// TODO show turns waited for pub struct DrawPedestrian { pub id: PedestrianID, circle: [f64; 4], + turn_arrow: Option<[f64; 4]>, } impl DrawPedestrian { - pub fn new(id: PedestrianID, pos: Pt2D) -> DrawPedestrian { + pub fn new(id: PedestrianID, pos: Pt2D, waiting_for_turn: Option<&Turn>) -> DrawPedestrian { + let turn_arrow = if let Some(t) = waiting_for_turn { + // TODO this isn't quite right, but good enough for now + let angle = t.line.angle(); + let arrow_pt = pos.project_away(RADIUS, angle.opposite()); + Some([arrow_pt.x(), arrow_pt.y(), pos.x(), pos.y()]) + } else { + None + }; + DrawPedestrian { id, circle: geometry::circle(pos.x(), pos.y(), RADIUS), + turn_arrow, } } pub fn draw(&self, g: &mut GfxCtx, color: graphics::types::Color) { g.draw_ellipse(color, self.circle); + + // TODO tune color, sizes + if let Some(a) = self.turn_arrow { + g.draw_arrow( + &graphics::Line::new_round([0.0, 1.0, 1.0, 1.0], 0.25), + a, + 0.3, + ); + } } pub fn contains_pt(&self, x: f64, y: f64) -> bool { diff --git a/sim/src/sim.rs b/sim/src/sim.rs index 880cc7008a..221e3ba265 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -289,7 +289,7 @@ impl Sim { } pub fn get_draw_peds_on_lane(&self, l: LaneID, map: &Map) -> Vec { - self.walking_state.get_draw_peds_on_lane(map.get_l(l)) + self.walking_state.get_draw_peds_on_lane(map.get_l(l), map) } pub fn get_draw_peds_on_turn(&self, t: TurnID, map: &Map) -> Vec { diff --git a/sim/src/walking.rs b/sim/src/walking.rs index 7cd91fa3f4..a96f82f43a 100644 --- a/sim/src/walking.rs +++ b/sim/src/walking.rs @@ -239,15 +239,19 @@ impl WalkingSimState { Some(DrawPedestrian::new( id, ped.on.dist_along(ped.dist_along * si::M, map).0, + // TODO this isnt correct, but works right now because this is only called by warp + None, )) } - pub fn get_draw_peds_on_lane(&self, l: &Lane) -> Vec { + pub fn get_draw_peds_on_lane(&self, l: &Lane, map: &Map) -> Vec { let mut result = Vec::new(); for id in self.peds_per_sidewalk.get_vec(&l.id).unwrap_or(&Vec::new()) { + let ped = &self.peds[id]; result.push(DrawPedestrian::new( *id, - l.dist_along(self.peds[id].dist_along * si::M).0, + l.dist_along(ped.dist_along * si::M).0, + ped.waiting_for.map(|on| map.get_t(on.as_turn())), )); } result @@ -259,6 +263,7 @@ impl WalkingSimState { result.push(DrawPedestrian::new( *id, t.dist_along(self.peds[id].dist_along * si::M).0, + None, )); } result