mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 15:02:59 +03:00
When pathfinding with custom routing params (from the debug UI), only rebuild the one graph we need. #746
This commit is contained in:
parent
8c2c0e2e65
commit
add42b6f19
@ -825,10 +825,11 @@ impl Map {
|
||||
self.name.map = format!("minified_{}", self.name.map);
|
||||
|
||||
// Don't need CHs or even the graph for anything except bikes.
|
||||
self.pathfinder = Pathfinder::just_bikes(
|
||||
self.pathfinder = Pathfinder::new_for_one_mode(
|
||||
self,
|
||||
self.routing_params().clone(),
|
||||
crate::pathfind::CreateEngine::Dijkstra,
|
||||
PathConstraints::Bike,
|
||||
timer,
|
||||
);
|
||||
}
|
||||
|
@ -97,16 +97,34 @@ impl Pathfinder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn just_bikes(
|
||||
/// Create a new Pathfinder with custom routing params that can only serve one mode.
|
||||
pub fn new_for_one_mode(
|
||||
map: &Map,
|
||||
params: RoutingParams,
|
||||
engine: CreateEngine,
|
||||
constraints: PathConstraints,
|
||||
timer: &mut Timer,
|
||||
) -> Pathfinder {
|
||||
let mut p = Pathfinder::empty();
|
||||
timer.start("prepare pathfinding for bikes");
|
||||
p.bike_graph = VehiclePathfinder::new(map, PathConstraints::Bike, ¶ms, &engine);
|
||||
timer.stop("prepare pathfinding for bikes");
|
||||
timer.start("prepare pathfinding for just one mode");
|
||||
match constraints {
|
||||
PathConstraints::Pedestrian => {
|
||||
p.walking_graph = SidewalkPathfinder::new(map, None, &engine);
|
||||
}
|
||||
PathConstraints::Car => {
|
||||
p.car_graph = VehiclePathfinder::new(map, constraints, ¶ms, &engine);
|
||||
}
|
||||
PathConstraints::Bike => {
|
||||
p.bike_graph = VehiclePathfinder::new(map, constraints, ¶ms, &engine);
|
||||
}
|
||||
PathConstraints::Bus => {
|
||||
p.bus_graph = VehiclePathfinder::new(map, constraints, ¶ms, &engine);
|
||||
}
|
||||
PathConstraints::Train => {
|
||||
p.train_graph = VehiclePathfinder::new(map, constraints, ¶ms, &engine);
|
||||
}
|
||||
}
|
||||
timer.stop("prepare pathfinding for just one mode");
|
||||
p.params = params;
|
||||
p
|
||||
}
|
||||
@ -128,12 +146,14 @@ impl Pathfinder {
|
||||
// If the params differ from the ones baked into the map, the CHs won't match. This
|
||||
// should only be happening from the debug UI; be very obnoxious if we start calling it
|
||||
// from the simulation or something else.
|
||||
warn!("Pathfinding slowly for {} with custom params", req);
|
||||
let tmp_pathfinder = Pathfinder::new(
|
||||
let mut timer =
|
||||
Timer::new(format!("Pathfinding slowly for {} with custom params", req));
|
||||
let tmp_pathfinder = Pathfinder::new_for_one_mode(
|
||||
map,
|
||||
params.clone(),
|
||||
CreateEngine::Dijkstra,
|
||||
&mut Timer::throwaway(),
|
||||
req.constraints,
|
||||
&mut timer,
|
||||
);
|
||||
return tmp_pathfinder.pathfind_with_params(req, params, map);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user