get rid of unzoomed_radius, used to highlight agents stuck in intersections. there are better gridlock debug tools now, and this complicates the minimap

This commit is contained in:
Dustin Carlino 2019-12-16 18:51:29 -08:00
parent 4046be3966
commit b1da0f0284
7 changed files with 11 additions and 32 deletions

View File

@ -136,6 +136,7 @@ impl Minimap {
g, g,
Some(&inner_rect), Some(&inner_rect),
zoom, zoom,
Distance::meters(5.0),
); );
// The cursor // The cursor
@ -157,7 +158,7 @@ impl Minimap {
}; };
if x1 != x2 && y1 != y2 { if x1 != x2 && y1 != y2 {
g.draw_polygon( g.draw_polygon(
Color::RED, Color::BLACK,
&Ring::new(vec![ &Ring::new(vec![
Pt2D::new(x1, y1), Pt2D::new(x1, y1),
Pt2D::new(x2, y1), Pt2D::new(x2, y1),

View File

@ -299,8 +299,8 @@ pub struct AgentCache {
// This time applies to agents_per_on. unzoomed has its own possibly separate Time! // This time applies to agents_per_on. unzoomed has its own possibly separate Time!
time: Option<Time>, time: Option<Time>,
agents_per_on: HashMap<Traversable, Vec<Box<dyn Renderable>>>, agents_per_on: HashMap<Traversable, Vec<Box<dyn Renderable>>>,
// cam_zoom also matters // cam_zoom and agent radius also matters
unzoomed: Option<(Time, f64, Drawable)>, unzoomed: Option<(Time, f64, Distance, Drawable)>,
} }
impl AgentCache { impl AgentCache {
@ -346,10 +346,11 @@ impl AgentCache {
g: &mut GfxCtx, g: &mut GfxCtx,
clip: Option<&ScreenRectangle>, clip: Option<&ScreenRectangle>,
cam_zoom: f64, cam_zoom: f64,
radius: Distance,
) { ) {
let now = source.time(); let now = source.time();
if let Some((time, z, ref draw)) = self.unzoomed { if let Some((time, z, r, ref draw)) = self.unzoomed {
if cam_zoom == z && now == time { if cam_zoom == z && now == time && radius == r {
if let Some(ref rect) = clip { if let Some(ref rect) = clip {
g.redraw_clipped(draw, rect); g.redraw_clipped(draw, rect);
} else { } else {
@ -365,7 +366,7 @@ impl AgentCache {
for agent in source.get_unzoomed_agents(map) { for agent in source.get_unzoomed_agents(map) {
batch.push( batch.push(
acs.unzoomed_color(&agent, cs), acs.unzoomed_color(&agent, cs),
Circle::new(agent.pos, acs.unzoomed_radius(&agent) / cam_zoom).to_polygon(), Circle::new(agent.pos, radius / cam_zoom).to_polygon(),
); );
} }
@ -375,7 +376,7 @@ impl AgentCache {
} else { } else {
g.redraw(&draw); g.redraw(&draw);
} }
self.unzoomed = Some((now, cam_zoom, draw)); self.unzoomed = Some((now, cam_zoom, radius, draw));
} }
} }
@ -416,16 +417,6 @@ impl AgentColorScheme {
} }
} }
pub fn unzoomed_radius(self, agent: &UnzoomedAgent) -> Distance {
if self == AgentColorScheme::Delay
&& agent.metadata.occupying_intersection
&& agent.metadata.time_spent_blocked > Duration::minutes(1)
{
return Distance::meters(20.0);
}
Distance::meters(10.)
}
pub fn zoomed_color_car(self, input: &DrawCarInput, cs: &ColorScheme) -> Color { pub fn zoomed_color_car(self, input: &DrawCarInput, cs: &ColorScheme) -> Color {
match self { match self {
AgentColorScheme::ByID => rotating_color_agents(input.id.0), AgentColorScheme::ByID => rotating_color_agents(input.id.0),
@ -472,13 +463,7 @@ impl AgentColorScheme {
fn by_metadata(self, md: &AgentMetadata) -> Color { fn by_metadata(self, md: &AgentMetadata) -> Color {
match self { match self {
AgentColorScheme::VehicleTypes | AgentColorScheme::ByID => unreachable!(), AgentColorScheme::VehicleTypes | AgentColorScheme::ByID => unreachable!(),
AgentColorScheme::Delay => { AgentColorScheme::Delay => delay_color(md.time_spent_blocked),
if md.occupying_intersection && md.time_spent_blocked > Duration::minutes(1) {
Color::YELLOW
} else {
delay_color(md.time_spent_blocked)
}
}
AgentColorScheme::DistanceCrossedSoFar => percent_color(md.percent_dist_crossed), AgentColorScheme::DistanceCrossedSoFar => percent_color(md.percent_dist_crossed),
AgentColorScheme::TripTimeSoFar => delay_color(md.trip_time_so_far), AgentColorScheme::TripTimeSoFar => delay_color(md.trip_time_so_far),
} }

View File

@ -153,6 +153,7 @@ impl UI {
g, g,
None, None,
g.canvas.cam_zoom, g.canvas.cam_zoom,
Distance::meters(10.0),
); );
} else { } else {
let mut cache = self.primary.draw_map.agents.borrow_mut(); let mut cache = self.primary.draw_map.agents.borrow_mut();

View File

@ -181,8 +181,6 @@ impl Car {
.unwrap_or(Duration::ZERO), .unwrap_or(Duration::ZERO),
percent_dist_crossed: self.router.get_path().percent_dist_crossed(), percent_dist_crossed: self.router.get_path().percent_dist_crossed(),
trip_time_so_far: now - self.started_at, trip_time_so_far: now - self.started_at,
occupying_intersection: self.router.head().maybe_turn().is_some()
|| self.last_steps.iter().any(|s| s.maybe_turn().is_some()),
} }
} }
} }

View File

@ -176,7 +176,6 @@ impl ParkingSimState {
time_spent_blocked: Duration::ZERO, time_spent_blocked: Duration::ZERO,
percent_dist_crossed: 0.0, percent_dist_crossed: 0.0,
trip_time_so_far: Duration::ZERO, trip_time_so_far: Duration::ZERO,
occupying_intersection: false,
}, },
body: map body: map

View File

@ -552,10 +552,6 @@ impl Pedestrian {
.unwrap_or(Duration::ZERO), .unwrap_or(Duration::ZERO),
percent_dist_crossed: self.path.percent_dist_crossed(), percent_dist_crossed: self.path.percent_dist_crossed(),
trip_time_so_far: now - self.started_at, trip_time_so_far: now - self.started_at,
// TODO Slight lie. Pedestrians might be sitting at the end of a turn, but it's
// technically been finished. Maybe use WaitingToTurn to detect. Not important, since
// pedestrians can't get stuck in an intersection.
occupying_intersection: false,
} }
} }

View File

@ -19,7 +19,6 @@ pub struct AgentMetadata {
pub time_spent_blocked: Duration, pub time_spent_blocked: Duration,
pub percent_dist_crossed: f64, pub percent_dist_crossed: f64,
pub trip_time_so_far: Duration, pub trip_time_so_far: Duration,
pub occupying_intersection: bool,
} }
pub struct DrawPedCrowdInput { pub struct DrawPedCrowdInput {