mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
terminating ped trace_route at the right SidewalkSpot
This commit is contained in:
parent
9c1ae28bf8
commit
b8fa12d0d5
@ -55,9 +55,12 @@ impl Traversable {
|
||||
start: si::Meter<f64>,
|
||||
end: si::Meter<f64>,
|
||||
) -> (Trace, si::Meter<f64>) {
|
||||
assert!(start <= end);
|
||||
assert!(start >= 0.0 * si::M);
|
||||
assert!(end >= 0.0 * si::M);
|
||||
if start > end || start < 0.0 * si::M || end < 0.0 * si::M {
|
||||
panic!(
|
||||
"Can't do slice [{}, {}] with reverse={} on {:?}",
|
||||
start, end, reverse, self
|
||||
);
|
||||
}
|
||||
|
||||
match self {
|
||||
&Traversable::Lane(id) => if reverse {
|
||||
|
@ -566,8 +566,13 @@ impl WalkingSimState {
|
||||
pub fn trace_route(&self, id: PedestrianID, map: &Map, dist_ahead: Distance) -> Option<Trace> {
|
||||
let p = self.peds.get(&id)?;
|
||||
|
||||
let (mut result, mut dist_left) =
|
||||
p.on.slice(p.contraflow, map, p.dist_along, p.dist_along + dist_ahead);
|
||||
let (mut result, mut dist_left) = {
|
||||
if p.path.is_empty() && p.on.maybe_lane().is_some() {
|
||||
p.on.slice(p.contraflow, map, p.dist_along, p.goal.dist_along)
|
||||
} else {
|
||||
p.on.slice(p.contraflow, map, p.dist_along, p.dist_along + dist_ahead)
|
||||
}
|
||||
};
|
||||
|
||||
let mut last_lane = p.on.maybe_lane();
|
||||
let mut idx = 0;
|
||||
@ -585,11 +590,12 @@ impl WalkingSimState {
|
||||
}
|
||||
}
|
||||
|
||||
let contraflow = if idx + 1 < p.path.len() {
|
||||
is_contraflow(map, next_lane, p.path[idx + 1])
|
||||
let (contraflow, last_step) = if idx + 1 < p.path.len() {
|
||||
(is_contraflow(map, next_lane, p.path[idx + 1]), false)
|
||||
} else {
|
||||
// TODO goal dist along
|
||||
false
|
||||
dist_left = p.goal.dist_along;
|
||||
// Value of contraflow doesn't matter
|
||||
(false, true)
|
||||
};
|
||||
|
||||
// TODO ooh this is _really_ cheating. ;) but sometimes we don't cross a lane either
|
||||
@ -607,7 +613,7 @@ impl WalkingSimState {
|
||||
dist_left = new_dist_left;
|
||||
}
|
||||
} else if last_pt == pt2 {
|
||||
if contraflow {
|
||||
if contraflow || last_step {
|
||||
let (piece, new_dist_left) =
|
||||
Traversable::Lane(next_lane).slice(true, map, l.length(), dist_left);
|
||||
result = result.extend(piece);
|
||||
|
Loading…
Reference in New Issue
Block a user