mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-29 12:43:38 +03:00
dont cancel diff worlds when an agent is mode-switching
This commit is contained in:
parent
8a474e16b0
commit
dd0578d504
@ -8,8 +8,9 @@ use sim::TripID;
|
||||
|
||||
pub enum DiffWorldsState {
|
||||
Inactive,
|
||||
// The Line just points from the agent in the primary sim to the agent in the secondary.
|
||||
Active(TripID, Line),
|
||||
// The Line just points from the agent in the primary sim to the agent in the secondary. It
|
||||
// might be temporarily not present during mode changes.
|
||||
Active(TripID, Option<Line>),
|
||||
}
|
||||
|
||||
impl DiffWorldsState {
|
||||
@ -54,13 +55,13 @@ impl Plugin for DiffWorldsState {
|
||||
.as_ref()
|
||||
.and_then(|(s, _)| s.sim.get_canonical_point_for_trip(id, &s.map));
|
||||
if pt1.is_some() && pt2.is_some() {
|
||||
*self = DiffWorldsState::Active(id, Line::new(pt1.unwrap(), pt2.unwrap()));
|
||||
*self = DiffWorldsState::Active(id, Some(Line::new(pt1.unwrap(), pt2.unwrap())));
|
||||
} else {
|
||||
warn!(
|
||||
"{} isn't present in both sims, cancelling DiffWorldsState",
|
||||
"{} isn't present in both sims",
|
||||
id
|
||||
);
|
||||
*self = DiffWorldsState::Inactive;
|
||||
*self = DiffWorldsState::Active(id, None);
|
||||
}
|
||||
} else {
|
||||
*self = DiffWorldsState::Inactive;
|
||||
@ -73,7 +74,7 @@ impl Plugin for DiffWorldsState {
|
||||
}
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, _ctx: Ctx) {
|
||||
if let DiffWorldsState::Active(_, ref line) = self {
|
||||
if let DiffWorldsState::Active(_, Some(ref line)) = self {
|
||||
// TODO move constants
|
||||
g.draw_line([1.0, 1.0, 0.0, 1.0], LANE_THICKNESS, line);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ impl Pathfinder {
|
||||
end: LaneID,
|
||||
is_bike: bool,
|
||||
) -> Option<VecDeque<LaneID>> {
|
||||
// TODO using first_pt here and in heuristic_dist is particularly bad for walking
|
||||
// directions
|
||||
let goal_pt = map.get_l(end).first_pt();
|
||||
Pathfinder::ShortestDistance { goal_pt, is_bike }.pathfind(map, start, end)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user