mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 07:52:05 +03:00
speed up some stuff indirectly used in bus locations to not be so terrible
This commit is contained in:
parent
6989c72aa1
commit
a4b24c2643
@ -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,
|
||||
|
@ -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()
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user