draw peds on one side of the sidewalk

This commit is contained in:
Dustin Carlino 2019-05-05 20:58:54 -07:00
parent 26ee29ff62
commit f31f46e483
2 changed files with 39 additions and 9 deletions

View File

@ -2,11 +2,9 @@ use crate::helpers::{ColorScheme, ID};
use crate::render::{should_draw_blinkers, DrawCtx, DrawOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Circle, Distance, PolyLine, Polygon};
use map_model::Map;
use map_model::{Map, LANE_THICKNESS};
use sim::{DrawPedestrianInput, PedestrianID};
const RADIUS: Distance = Distance::const_meters(1.0);
pub struct DrawPedestrian {
pub id: PedestrianID,
circle: Circle,
@ -23,12 +21,18 @@ impl DrawPedestrian {
prerender: &Prerender,
cs: &ColorScheme,
) -> DrawPedestrian {
// TODO Slight issues with rendering small pedestrians:
// - route visualization is thick
// - there are little skips when making turns
// - front paths are too skinny
let radius = LANE_THICKNESS / 4.0;
let turn_arrow = if let Some(t) = input.waiting_for_turn {
let angle = map.get_t(t).angle();
Some(
PolyLine::new(vec![
input.pos.project_away(RADIUS / 2.0, angle.opposite()),
input.pos.project_away(RADIUS / 2.0, angle),
input.pos.project_away(radius / 2.0, angle.opposite()),
input.pos.project_away(radius / 2.0, angle),
])
.make_arrow(Distance::meters(0.25))
.unwrap(),
@ -37,7 +41,7 @@ impl DrawPedestrian {
None
};
let circle = Circle::new(input.pos, RADIUS);
let circle = Circle::new(input.pos, radius);
let draw_default = prerender.upload(vec![(
if input.preparing_bike {

View File

@ -5,7 +5,7 @@ use crate::{
};
use abstutil::{deserialize_multimap, serialize_multimap, MultiMap};
use geom::{Distance, Duration, Line, PolyLine, Speed};
use map_model::{BuildingID, Map, Path, PathStep, Traversable};
use map_model::{BuildingID, Map, Path, PathStep, Traversable, LANE_THICKNESS};
use serde_derive::{Deserialize, Serialize};
use std::collections::BTreeMap;
@ -296,14 +296,36 @@ impl Pedestrian {
} else {
time_int.percent(time)
};
on.dist_along(dist_int.lerp(percent), map).0
let (pos, angle) = on.dist_along(dist_int.lerp(percent), map);
pos.project_away(
LANE_THICKNESS / 4.0,
if dist_int.start < dist_int.end {
angle.rotate_degs(90.0)
} else {
angle.rotate_degs(-90.0)
},
)
}
PedState::WaitingToTurn(dist) => {
let (pos, angle) = on.dist_along(dist, map);
pos.project_away(
LANE_THICKNESS / 4.0,
if dist == Distance::ZERO {
angle.rotate_degs(-90.0)
} else {
angle.rotate_degs(90.0)
},
)
}
PedState::WaitingToTurn(dist) => on.dist_along(dist, map).0,
PedState::LeavingBuilding(b, ref time_int) => {
let front_path = &map.get_b(b).front_path;
front_path
.line
.dist_along(time_int.percent(time) * front_path.line.length())
.project_away(
LANE_THICKNESS / 4.0,
front_path.line.angle().rotate_degs(90.0),
)
}
PedState::EnteringBuilding(b, ref time_int) => {
let front_path = &map.get_b(b).front_path;
@ -311,6 +333,10 @@ impl Pedestrian {
.line
.reverse()
.dist_along(time_int.percent(time) * front_path.line.length())
.project_away(
LANE_THICKNESS / 4.0,
front_path.line.angle().rotate_degs(-90.0),
)
}
PedState::StartingToBike(_, ref line, ref time_int) => {
line.percent_along(time_int.percent(time))