mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
new colorscheme showing trip time so far
This commit is contained in:
parent
f3f4f98290
commit
2fe2559f67
@ -381,6 +381,8 @@ impl AgentCache {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO The perf is a little slow compared to when we just returned a bunch of Pt2Ds
|
||||
// without the extra data. Try plumbing a callback that directly populates batch.
|
||||
let mut batch = GeomBatch::new();
|
||||
let radius = Distance::meters(10.0) / g.canvas.cam_zoom;
|
||||
for agent in primary.sim.get_unzoomed_agents(&primary.map) {
|
||||
@ -411,11 +413,13 @@ fn osm_rank_to_color(cs: &ColorScheme, rank: usize) -> Color {
|
||||
}
|
||||
|
||||
// TODO Show a little legend when it's first activated.
|
||||
// TODO ETA till goal...
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub enum AgentColorScheme {
|
||||
VehicleTypes,
|
||||
Delay,
|
||||
RemainingDistance,
|
||||
TripTimeSoFar,
|
||||
}
|
||||
|
||||
impl Cloneable for AgentColorScheme {}
|
||||
@ -431,6 +435,7 @@ impl AgentColorScheme {
|
||||
},
|
||||
AgentColorScheme::Delay => delay_color(agent.time_spent_blocked),
|
||||
AgentColorScheme::RemainingDistance => percent_color(agent.percent_dist_crossed),
|
||||
AgentColorScheme::TripTimeSoFar => delay_color(agent.trip_time_so_far),
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,6 +455,7 @@ impl AgentColorScheme {
|
||||
}
|
||||
AgentColorScheme::Delay => delay_color(input.time_spent_blocked),
|
||||
AgentColorScheme::RemainingDistance => percent_color(input.percent_dist_crossed),
|
||||
AgentColorScheme::TripTimeSoFar => delay_color(input.trip_time_so_far),
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,6 +470,7 @@ impl AgentColorScheme {
|
||||
},
|
||||
AgentColorScheme::Delay => delay_color(input.time_spent_blocked),
|
||||
AgentColorScheme::RemainingDistance => percent_color(input.percent_dist_crossed),
|
||||
AgentColorScheme::TripTimeSoFar => delay_color(input.trip_time_so_far),
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,6 +485,7 @@ impl AgentColorScheme {
|
||||
}
|
||||
AgentColorScheme::Delay => delay_color(input.time_spent_blocked),
|
||||
AgentColorScheme::RemainingDistance => percent_color(input.percent_dist_crossed),
|
||||
AgentColorScheme::TripTimeSoFar => delay_color(input.trip_time_so_far),
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,6 +503,10 @@ impl AgentColorScheme {
|
||||
AgentColorScheme::RemainingDistance,
|
||||
"by distance remaining to goal".to_string(),
|
||||
),
|
||||
(
|
||||
AgentColorScheme::TripTimeSoFar,
|
||||
"by trip time so far".to_string(),
|
||||
),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ pub struct Car {
|
||||
pub router: Router,
|
||||
pub trip: TripID,
|
||||
pub blocked_since: Option<Duration>,
|
||||
pub started_at: Duration,
|
||||
|
||||
// In reverse order -- most recently left is first. The sum length of these must be >=
|
||||
// vehicle.length.
|
||||
@ -146,6 +147,7 @@ impl Car {
|
||||
.map(|t| now - t)
|
||||
.unwrap_or(Duration::ZERO),
|
||||
percent_dist_crossed: path.crossed_so_far() / path.total_length(),
|
||||
trip_time_so_far: now - self.started_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ impl DrivingSimState {
|
||||
state: CarState::Queued,
|
||||
last_steps: VecDeque::new(),
|
||||
blocked_since: None,
|
||||
started_at: now,
|
||||
trip: params.trip,
|
||||
};
|
||||
if params.maybe_parked_car.is_some() {
|
||||
@ -672,6 +673,7 @@ impl DrivingSimState {
|
||||
.map(|t| now - t)
|
||||
.unwrap_or(Duration::ZERO),
|
||||
percent_dist_crossed: path.crossed_so_far() / path.total_length(),
|
||||
trip_time_so_far: now - car.started_at,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -760,6 +762,7 @@ impl DrivingSimState {
|
||||
"Blocked for {}",
|
||||
car.blocked_since.map(|t| now - t).unwrap_or(Duration::ZERO)
|
||||
),
|
||||
format!("Trip time so far: {}", now - car.started_at),
|
||||
format!("{:?}", car.state),
|
||||
])
|
||||
}
|
||||
|
@ -110,6 +110,7 @@ impl ParkingSimState {
|
||||
label: None,
|
||||
time_spent_blocked: Duration::ZERO,
|
||||
percent_dist_crossed: 0.0,
|
||||
trip_time_so_far: Duration::ZERO,
|
||||
|
||||
body: map
|
||||
.get_l(lane)
|
||||
|
@ -54,6 +54,7 @@ impl WalkingSimState {
|
||||
),
|
||||
speed: params.speed,
|
||||
blocked_since: None,
|
||||
started_at: now,
|
||||
path: params.path,
|
||||
goal: params.goal,
|
||||
trip: params.trip,
|
||||
@ -239,6 +240,7 @@ impl WalkingSimState {
|
||||
"Blocked for {}",
|
||||
p.blocked_since.map(|t| now - t).unwrap_or(Duration::ZERO)
|
||||
),
|
||||
format!("Trip time so far: {}", now - p.started_at),
|
||||
format!("{:?}", p.state),
|
||||
]
|
||||
}
|
||||
@ -271,6 +273,7 @@ impl WalkingSimState {
|
||||
pos: ped.get_draw_ped(now, map).pos,
|
||||
time_spent_blocked: ped.blocked_since.map(|t| now - t).unwrap_or(Duration::ZERO),
|
||||
percent_dist_crossed: ped.path.crossed_so_far() / ped.path.total_length(),
|
||||
trip_time_so_far: now - ped.started_at,
|
||||
});
|
||||
}
|
||||
|
||||
@ -380,6 +383,8 @@ struct Pedestrian {
|
||||
state: PedState,
|
||||
speed: Speed,
|
||||
blocked_since: Option<Duration>,
|
||||
// TODO organize analytics better.
|
||||
started_at: Duration,
|
||||
|
||||
path: Path,
|
||||
goal: SidewalkSpot,
|
||||
@ -505,6 +510,7 @@ impl Pedestrian {
|
||||
.map(|t| now - t)
|
||||
.unwrap_or(Duration::ZERO),
|
||||
percent_dist_crossed: self.path.crossed_so_far() / self.path.total_length(),
|
||||
trip_time_so_far: now - self.started_at,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ pub struct DrawPedestrianInput {
|
||||
pub on: Traversable,
|
||||
pub time_spent_blocked: Duration,
|
||||
pub percent_dist_crossed: f64,
|
||||
pub trip_time_so_far: Duration,
|
||||
}
|
||||
|
||||
pub struct DrawPedCrowdInput {
|
||||
@ -32,6 +33,7 @@ pub struct DrawCarInput {
|
||||
pub label: Option<String>,
|
||||
pub time_spent_blocked: Duration,
|
||||
pub percent_dist_crossed: f64,
|
||||
pub trip_time_so_far: Duration,
|
||||
|
||||
// Starts at the BACK of the car.
|
||||
pub body: PolyLine,
|
||||
@ -51,6 +53,7 @@ pub struct UnzoomedAgent {
|
||||
pub pos: Pt2D,
|
||||
pub time_spent_blocked: Duration,
|
||||
pub percent_dist_crossed: f64,
|
||||
pub trip_time_so_far: Duration,
|
||||
}
|
||||
|
||||
// TODO Can we return borrows instead? Nice for time travel, not for main sim?
|
||||
|
Loading…
Reference in New Issue
Block a user