mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 16:02:23 +03:00
Work around a crash on the intersection demand panel, reproducible by
watching https://www.openstreetmap.org/node/53214134 on the weekday scenario. At some point, an arrow polygon with an inner ring is scaled down, collapsing its points so much that the ring becomes invalid.
This commit is contained in:
parent
25ee39af89
commit
bc858fdbb3
@ -195,7 +195,9 @@ impl GeomBatch {
|
||||
return self;
|
||||
}
|
||||
for (_, poly) in &mut self.list {
|
||||
*poly = poly.scale(factor);
|
||||
// strip_rings first -- sometimes when scaling down, the original rings collapse. Since
|
||||
// this polygon is part of a GeomBatch anyway, not calling to_outline on it.
|
||||
*poly = poly.strip_rings().scale(factor);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
@ -307,6 +307,14 @@ impl Polygon {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the internal rings used for to_outline. This is fine to do if the polygon is being
|
||||
// added to some larger piece of geometry that won't need an outline.
|
||||
pub fn strip_rings(&self) -> Polygon {
|
||||
let mut p = self.clone();
|
||||
p.rings = None;
|
||||
p
|
||||
}
|
||||
|
||||
// Usually m^2, unless the polygon is in screen-space
|
||||
pub fn area(&self) -> f64 {
|
||||
// Polygon orientation messes this up sometimes
|
||||
|
Loading…
Reference in New Issue
Block a user