mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
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:
parent
4046be3966
commit
b1da0f0284
@ -136,6 +136,7 @@ impl Minimap {
|
||||
g,
|
||||
Some(&inner_rect),
|
||||
zoom,
|
||||
Distance::meters(5.0),
|
||||
);
|
||||
|
||||
// The cursor
|
||||
@ -157,7 +158,7 @@ impl Minimap {
|
||||
};
|
||||
if x1 != x2 && y1 != y2 {
|
||||
g.draw_polygon(
|
||||
Color::RED,
|
||||
Color::BLACK,
|
||||
&Ring::new(vec![
|
||||
Pt2D::new(x1, y1),
|
||||
Pt2D::new(x2, y1),
|
||||
|
@ -299,8 +299,8 @@ pub struct AgentCache {
|
||||
// This time applies to agents_per_on. unzoomed has its own possibly separate Time!
|
||||
time: Option<Time>,
|
||||
agents_per_on: HashMap<Traversable, Vec<Box<dyn Renderable>>>,
|
||||
// cam_zoom also matters
|
||||
unzoomed: Option<(Time, f64, Drawable)>,
|
||||
// cam_zoom and agent radius also matters
|
||||
unzoomed: Option<(Time, f64, Distance, Drawable)>,
|
||||
}
|
||||
|
||||
impl AgentCache {
|
||||
@ -346,10 +346,11 @@ impl AgentCache {
|
||||
g: &mut GfxCtx,
|
||||
clip: Option<&ScreenRectangle>,
|
||||
cam_zoom: f64,
|
||||
radius: Distance,
|
||||
) {
|
||||
let now = source.time();
|
||||
if let Some((time, z, ref draw)) = self.unzoomed {
|
||||
if cam_zoom == z && now == time {
|
||||
if let Some((time, z, r, ref draw)) = self.unzoomed {
|
||||
if cam_zoom == z && now == time && radius == r {
|
||||
if let Some(ref rect) = clip {
|
||||
g.redraw_clipped(draw, rect);
|
||||
} else {
|
||||
@ -365,7 +366,7 @@ impl AgentCache {
|
||||
for agent in source.get_unzoomed_agents(map) {
|
||||
batch.push(
|
||||
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 {
|
||||
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 {
|
||||
match self {
|
||||
AgentColorScheme::ByID => rotating_color_agents(input.id.0),
|
||||
@ -472,13 +463,7 @@ impl AgentColorScheme {
|
||||
fn by_metadata(self, md: &AgentMetadata) -> Color {
|
||||
match self {
|
||||
AgentColorScheme::VehicleTypes | AgentColorScheme::ByID => unreachable!(),
|
||||
AgentColorScheme::Delay => {
|
||||
if md.occupying_intersection && md.time_spent_blocked > Duration::minutes(1) {
|
||||
Color::YELLOW
|
||||
} else {
|
||||
delay_color(md.time_spent_blocked)
|
||||
}
|
||||
}
|
||||
AgentColorScheme::Delay => delay_color(md.time_spent_blocked),
|
||||
AgentColorScheme::DistanceCrossedSoFar => percent_color(md.percent_dist_crossed),
|
||||
AgentColorScheme::TripTimeSoFar => delay_color(md.trip_time_so_far),
|
||||
}
|
||||
|
@ -153,6 +153,7 @@ impl UI {
|
||||
g,
|
||||
None,
|
||||
g.canvas.cam_zoom,
|
||||
Distance::meters(10.0),
|
||||
);
|
||||
} else {
|
||||
let mut cache = self.primary.draw_map.agents.borrow_mut();
|
||||
|
@ -181,8 +181,6 @@ impl Car {
|
||||
.unwrap_or(Duration::ZERO),
|
||||
percent_dist_crossed: self.router.get_path().percent_dist_crossed(),
|
||||
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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,6 @@ impl ParkingSimState {
|
||||
time_spent_blocked: Duration::ZERO,
|
||||
percent_dist_crossed: 0.0,
|
||||
trip_time_so_far: Duration::ZERO,
|
||||
occupying_intersection: false,
|
||||
},
|
||||
|
||||
body: map
|
||||
|
@ -552,10 +552,6 @@ impl Pedestrian {
|
||||
.unwrap_or(Duration::ZERO),
|
||||
percent_dist_crossed: self.path.percent_dist_crossed(),
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ pub struct AgentMetadata {
|
||||
pub time_spent_blocked: Duration,
|
||||
pub percent_dist_crossed: f64,
|
||||
pub trip_time_so_far: Duration,
|
||||
pub occupying_intersection: bool,
|
||||
}
|
||||
|
||||
pub struct DrawPedCrowdInput {
|
||||
|
Loading…
Reference in New Issue
Block a user