mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-28 08:53:26 +03:00
fix rendering crash
This commit is contained in:
parent
6304abdcc8
commit
95626d5b64
@ -284,7 +284,7 @@ pub fn draw_signal_phase(
|
|||||||
fn crosswalk_icon(geom: &PolyLine) -> (Pt2D, Angle) {
|
fn crosswalk_icon(geom: &PolyLine) -> (Pt2D, Angle) {
|
||||||
let l = Line::new(geom.points()[1], geom.points()[2]);
|
let l = Line::new(geom.points()[1], geom.points()[2]);
|
||||||
(
|
(
|
||||||
l.dist_along(Distance::meters(1.0)),
|
l.safe_dist_along(Distance::meters(1.0)).unwrap_or(l.pt1()),
|
||||||
l.angle().shortest_rotation_towards(Angle::new_degs(90.0)),
|
l.angle().shortest_rotation_towards(Angle::new_degs(90.0)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,14 @@ impl Line {
|
|||||||
self.percent_along(dist / len)
|
self.percent_along(dist / len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn safe_dist_along(&self, dist: Distance) -> Option<Pt2D> {
|
||||||
|
if dist > self.length() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(self.dist_along(dist))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn middle(&self) -> Pt2D {
|
pub fn middle(&self) -> Pt2D {
|
||||||
self.dist_along(self.length() / 2.0)
|
self.dist_along(self.length() / 2.0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user