mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 17:37:22 +03:00
make some more pedestrian paths possible by forcing turns even when line trimming fails
This commit is contained in:
parent
14eac3c486
commit
a52b966b03
@ -28,8 +28,6 @@
|
||||
|
||||
## pedestrians
|
||||
|
||||
- why so many impossible paths? r350 to r41
|
||||
|
||||
- UI: draw cars and peds in intersections, even at lower zoom levels, just like on roads
|
||||
- make them obey intersections (deterministically!)
|
||||
- make them start and end at buildings
|
||||
|
@ -180,6 +180,20 @@ impl PolyLine {
|
||||
.map(|pts| pts.iter().map(|pt| pt.to_vec()).collect())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn intersects(&self, other: &PolyLine) -> bool {
|
||||
// Quadratic
|
||||
for pair1 in self.pts.windows(2) {
|
||||
let l1 = Line::new(pair1[0], pair1[1]);
|
||||
for pair2 in other.pts.windows(2) {
|
||||
let l2 = Line::new(pair2[0], pair2[1]);
|
||||
if l1.intersects(&l2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for PolyLine {
|
||||
|
@ -99,7 +99,9 @@ pub(crate) fn make_crosswalks(i: &Intersection, m: &Map, mut turn_id_start: usiz
|
||||
}
|
||||
let dst_pt = dst.endpoint(i.id);
|
||||
|
||||
if src_pt != dst_pt {
|
||||
// TODO Just the first check ideally, but until line trimming handles polylines, we
|
||||
// should also do the second check.
|
||||
if src_pt != dst_pt && !src.lane_center_pts.intersects(&dst.lane_center_pts) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user