mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
ped trace_routes were wrong for contraflow steps
This commit is contained in:
parent
a1ac8cf7dd
commit
9c1ae28bf8
@ -21,7 +21,9 @@ impl Plugin for DiffAllState {
|
||||
fn event(&mut self, ctx: PluginCtx) -> bool {
|
||||
let active = match self {
|
||||
DiffAllState::Inactive => {
|
||||
ctx.secondary.is_some() && ctx.input.key_pressed(Key::D, "Diff all trips")
|
||||
ctx.secondary.is_some()
|
||||
&& ctx.primary.current_selection.is_none()
|
||||
&& ctx.input.key_pressed(Key::D, "Diff all trips")
|
||||
}
|
||||
DiffAllState::Active(_) => {
|
||||
!ctx.input.key_pressed(Key::Return, "Stop diffing all trips")
|
||||
|
@ -59,7 +59,7 @@ impl PolyLine {
|
||||
|
||||
// Returns the excess distance left over from the end.
|
||||
pub fn slice(&self, start: si::Meter<f64>, end: si::Meter<f64>) -> (PolyLine, si::Meter<f64>) {
|
||||
if start >= end {
|
||||
if start >= end || start < 0.0 * si::M || end < 0.0 * si::M {
|
||||
panic!("Can't get a polyline slice [{}, {}]", start, end);
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,15 @@ 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);
|
||||
|
||||
match self {
|
||||
&Traversable::Lane(id) => if reverse {
|
||||
let pts = &map.get_l(id).lane_center_pts;
|
||||
let len = pts.length();
|
||||
let (polyline, remainder) = pts.reversed().slice(start, end);
|
||||
let (polyline, remainder) = pts.reversed().slice(len - start, end);
|
||||
let actual_len = polyline.length();
|
||||
(
|
||||
Trace {
|
||||
|
@ -167,9 +167,8 @@ impl Router {
|
||||
map: &Map,
|
||||
dist_along: Distance,
|
||||
) -> Trace {
|
||||
let (mut result, mut dist_left) = start
|
||||
// TODO will this break if we pass in max for dist_along?
|
||||
.slice(false, map, start_dist, start_dist + dist_along);
|
||||
let (mut result, mut dist_left) =
|
||||
start.slice(false, map, start_dist, start_dist + dist_along);
|
||||
|
||||
let mut last_lane = start.maybe_lane();
|
||||
let mut idx = 0;
|
||||
|
@ -566,9 +566,8 @@ 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
|
||||
// TODO will this break if we pass in max for dist_along?
|
||||
.slice(p.contraflow, map, p.dist_along, p.dist_along + dist_ahead);
|
||||
let (mut result, mut dist_left) =
|
||||
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;
|
||||
@ -595,10 +594,8 @@ impl WalkingSimState {
|
||||
|
||||
// TODO ooh this is _really_ cheating. ;) but sometimes we don't cross a lane either
|
||||
// direction. urgh.
|
||||
let (pt1, pt2) = {
|
||||
let l = map.get_l(next_lane);
|
||||
(l.first_pt(), l.last_pt())
|
||||
};
|
||||
let (pt1, pt2) = (l.first_pt(), l.last_pt());
|
||||
let last_pt = result.endpoints().1;
|
||||
if last_pt == pt1 {
|
||||
if contraflow {
|
||||
@ -612,7 +609,7 @@ impl WalkingSimState {
|
||||
} else if last_pt == pt2 {
|
||||
if contraflow {
|
||||
let (piece, new_dist_left) =
|
||||
Traversable::Lane(next_lane).slice(true, map, 0.0 * si::M, dist_left);
|
||||
Traversable::Lane(next_lane).slice(true, map, l.length(), dist_left);
|
||||
result = result.extend(piece);
|
||||
dist_left = new_dist_left;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user