speed up some stuff indirectly used in bus locations to not be so terrible

This commit is contained in:
Dustin Carlino 2019-10-19 15:00:36 -07:00
parent 6989c72aa1
commit a4b24c2643
3 changed files with 28 additions and 4 deletions

View File

@ -771,6 +771,20 @@ impl DrivingSimState {
result
}
// This is about as expensive as get_draw_cars_on.
pub fn get_single_draw_car(
&self,
id: CarID,
now: Duration,
map: &Map,
transit: &TransitSimState,
) -> Option<DrawCarInput> {
let car = self.cars.get(&id)?;
self.get_draw_cars_on(now, car.router.head(), map, transit)
.into_iter()
.find(|d| d.id == id)
}
pub fn get_draw_cars_on(
&self,
now: Duration,

View File

@ -85,6 +85,15 @@ impl WalkingSimState {
);
}
pub fn get_draw_ped(
&self,
id: PedestrianID,
now: Duration,
map: &Map,
) -> Option<DrawPedestrianInput> {
self.peds.get(&id).map(|p| p.get_draw_ped(now, map))
}
pub fn get_all_draw_peds(&self, now: Duration, map: &Map) -> Vec<DrawPedestrianInput> {
self.peds
.values()

View File

@ -288,13 +288,14 @@ impl GetDrawAgents for Sim {
}
fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput> {
// TODO Faster
self.get_all_draw_cars(map).into_iter().find(|d| d.id == id)
self.parking.get_draw_car(id, map, &self.trips).or_else(|| {
self.driving
.get_single_draw_car(id, self.time, map, &self.transit)
})
}
fn get_draw_ped(&self, id: PedestrianID, map: &Map) -> Option<DrawPedestrianInput> {
// TODO Faster
self.get_all_draw_peds(map).into_iter().find(|d| d.id == id)
self.walking.get_draw_ped(id, self.time, map)
}
fn get_draw_cars(&self, on: Traversable, map: &Map) -> Vec<DrawCarInput> {