fixing path trace cases that wind up with points too squished together

This commit is contained in:
Dustin Carlino 2019-01-29 16:11:30 -08:00
parent a98383db8f
commit ca058331e5
4 changed files with 32 additions and 14 deletions

View File

@ -5,6 +5,7 @@
- try fixed pt again, for determinism purposes mostly
- successful: Lines of ~0 length gone
- but due to bad polyline shifting, some things would loudly break if we squished pts down always
- might be cleaner to make polyline slice return Optional
- underlying problems
- bad polyline shifting remains

View File

@ -162,6 +162,15 @@ impl PolyLine {
self.length()
);
}
if result.len() == 1 {
panic!(
"Slice [{}, {}] didn't work on a polyline of length {} with points {}",
start,
end,
self.length(),
self
);
}
(PolyLine::new(result), end - dist_so_far)
}

View File

@ -1,6 +1,6 @@
use crate::{BusRouteID, BusStopID, LaneID, LaneType, Map, Position, Traversable, TurnID};
use dimensioned::si;
use geom::{PolyLine, Pt2D};
use geom::{PolyLine, Pt2D, EPSILON_DIST};
use ordered_float::NotNan;
use serde_derive::{Deserialize, Serialize};
use std::collections::{BinaryHeap, HashMap, VecDeque};
@ -85,14 +85,14 @@ impl PathStep {
PathStep::Lane(id) => {
let l = map.get_l(*id);
// Might have a pedestrian at a front_path lined up with the end of a lane
if start == l.length() {
if start >= l.length() - EPSILON_DIST {
None
} else {
Some(l.lane_center_pts.slice(start, start + dist_ahead))
}
}
PathStep::ContraflowLane(id) => {
if start == 0.0 * si::M {
if start < EPSILON_DIST {
None
} else {
let pts = map.get_l(*id).lane_center_pts.reversed();
@ -102,7 +102,7 @@ impl PathStep {
}
PathStep::Turn(id) => {
let geom = &map.get_t(*id).geom;
if geom.length() == 0.0 * si::M {
if start >= geom.length() - EPSILON_DIST {
None
} else {
Some(geom.slice(start, start + dist_ahead))
@ -227,6 +227,7 @@ impl Path {
PathStep::ContraflowLane(l) => map.get_l(l).lane_center_pts.reversed().length(),
_ => 0.0 * si::M,
};
if dist_remaining - start_dist_this_step > EPSILON_DIST {
if let Some((new_pts, dist)) =
self.steps[i].slice(map, start_dist_this_step, dist_remaining)
{
@ -239,6 +240,7 @@ impl Path {
dist_remaining = dist;
}
}
}
Some(pts_so_far.unwrap())
}

View File

@ -851,7 +851,13 @@ impl DrivingSimState {
)
.unwrap()
} else {
if c.dist_along > EPSILON_DIST {
c.on.slice(0.0 * si::M, c.dist_along, map).0
} else {
// TODO Kinda weird to consider the car not present, but eventually cars spawning
// at borders should appear fully anyway.
return None;
}
};
let body = if let Some(ref parking) = c.parking {