mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-28 17:04:20 +03:00
workaround for awful intersection geometry causing get_outline's that
explode out to some corner and get constantly rendered
This commit is contained in:
parent
db04553626
commit
ec015624c0
@ -1,42 +1,21 @@
|
||||
75b7f158d24cb3d61e36dd0e25fb08c6 ../data/screenshots/pending_montlake/01x01_i85.png
|
||||
80e5ccac8b7a30e7c8e0251d117e98ae ../data/screenshots/pending_montlake/02x01_i64.png
|
||||
5a38a69e4d66ec283d414a4135ae10d1 ../data/screenshots/pending_montlake/03x01_i6.png
|
||||
5efa5b5e1b81d312ad2e75535bda4ecf ../data/screenshots/pending_montlake/04x01_i4.png
|
||||
5c87d111e9afdec0d19ffd452b4fbd34 ../data/screenshots/pending_montlake/05x01_i208.png
|
||||
6575e92717461fa83a30d81e87914ae2 ../data/screenshots/pending_montlake/06x01_i193.png
|
||||
878ae97141bbb14bd347ce5a4982d97c ../data/screenshots/pending_montlake/01x02_i15.png
|
||||
87aef48c87031454c69cb3be930b3ebd ../data/screenshots/pending_montlake/02x02_i49.png
|
||||
6c537f7c3e8677edc1c3fc5f2040926a ../data/screenshots/pending_montlake/03x02_i233.png
|
||||
4ef4c6cd26790798de945d81028bfab5 ../data/screenshots/pending_montlake/04x02_i44.png
|
||||
1e19e6bd832184fbeb5f197f96593836 ../data/screenshots/pending_montlake/05x02_i13.png
|
||||
d36de1650d145bf8e848df92ab3602b7 ../data/screenshots/pending_montlake/06x02_i48.png
|
||||
d4acb3a16f7a2d173cbc733eab9eb0ca ../data/screenshots/pending_montlake/01x03_i111.png
|
||||
73521ae565b4437bd279b404fcbcce59 ../data/screenshots/pending_montlake/02x03_i80.png
|
||||
85f73456bb625660ae9be1280e991e6e ../data/screenshots/pending_montlake/03x03_i10.png
|
||||
ac7baf5f8d8ba43beac331dabce43b05 ../data/screenshots/pending_montlake/04x03_i11.png
|
||||
4abc70f06782a0a4135436ec83932b40 ../data/screenshots/pending_montlake/05x03_i218.png
|
||||
651708525fcb99e14cbd7722aff3df62 ../data/screenshots/pending_montlake/06x03_i21.png
|
||||
d814831a4f725877f71869d9be0e3723 ../data/screenshots/pending_montlake/01x04_i22.png
|
||||
93e8d9cb1d10a223fe82036177e4d98a ../data/screenshots/pending_montlake/02x04_i8.png
|
||||
42584d685bb8de3dc6eb88f0d3d04818 ../data/screenshots/pending_montlake/03x04_i0.png
|
||||
92810426ed765ff73c3419631bf6812c ../data/screenshots/pending_montlake/04x04_i99.png
|
||||
cc5aeeca165ebe2b5e235d55c8b220f1 ../data/screenshots/pending_montlake/05x04_i35.png
|
||||
926f8d686c110aaec2798a3daf2045eb ../data/screenshots/pending_montlake/06x04_i20.png
|
||||
853ac5ee9033fd5385a0fa6d41a4be3d ../data/screenshots/pending_montlake/01x05_i54.png
|
||||
395e8b3860a545086a334c39b3e0fe4e ../data/screenshots/pending_montlake/02x05_i8.png
|
||||
5026ceb7c440d698197da4c530651e4b ../data/screenshots/pending_montlake/03x05_i115.png
|
||||
c35ce1868ac710113898f908096dc44c ../data/screenshots/pending_montlake/04x05_i56.png
|
||||
2523529762f8e2ee403378d9c0873c1e ../data/screenshots/pending_montlake/05x05_i30.png
|
||||
ccae56fb001cbb74a155f27c965f3fae ../data/screenshots/pending_montlake/06x05.png
|
||||
81e66a7b84b3229fcf9b2d53f99313ee ../data/screenshots/pending_montlake/01x06_i18.png
|
||||
f43b63d7a2c101e5fcc1192fdb61128a ../data/screenshots/pending_montlake/02x06_i82.png
|
||||
d7d8de99b46b804855bcfca292411ed3 ../data/screenshots/pending_montlake/03x06_i16.png
|
||||
6d662acde92ceb2ad731b464e999462a ../data/screenshots/pending_montlake/04x06_i33.png
|
||||
486223fba22d766980b065eb19e90b06 ../data/screenshots/pending_montlake/05x06_i1.png
|
||||
5773308a76bf8d165eec07ccbc30a41e ../data/screenshots/pending_montlake/06x06_i146.png
|
||||
ab87926fd932469cefc3dc9e9b413c8d ../data/screenshots/pending_montlake/01x07_i121.png
|
||||
2fa844b8cbbdf84b71fbfb28933aadd6 ../data/screenshots/pending_montlake/02x07_i288.png
|
||||
f82cfa63ece790bf8d1f26bd5dd8caf0 ../data/screenshots/pending_montlake/03x07_i28.png
|
||||
82e6af8c89fb95dd6a2db293fac2805e ../data/screenshots/pending_montlake/04x07_i24.png
|
||||
ebe75953002a2370ff4a67c8161c28ea ../data/screenshots/pending_montlake/05x07_i25.png
|
||||
bf5befd60f7509faabea570ac76a8d01 ../data/screenshots/pending_montlake/06x07_i109.png
|
||||
30974091f1f479bde2ef38ca8c531191 ../data/screenshots/pending_montlake/01x01_i64.png
|
||||
768309d7f9d0fe147b398de3208ad1f4 ../data/screenshots/pending_montlake/02x01_i6.png
|
||||
f58cf3be474c543cf7945450a533d83d ../data/screenshots/pending_montlake/03x01_i4.png
|
||||
8bb7bd8d7ea828c505714b8f54215d86 ../data/screenshots/pending_montlake/01x02_i14.png
|
||||
579d9169e621b7ced54940b65e2ee965 ../data/screenshots/pending_montlake/02x02_i144.png
|
||||
7e485afed06f85c8502c867183a19128 ../data/screenshots/pending_montlake/03x02_i44.png
|
||||
8c103049009019892e547fc2fec8c3c4 ../data/screenshots/pending_montlake/01x03_i111.png
|
||||
dde24d03a4b3a0c051d0721d720eb8c8 ../data/screenshots/pending_montlake/02x03_i10.png
|
||||
e81077ba2615f9183b605662044f9ad6 ../data/screenshots/pending_montlake/03x03_i21.png
|
||||
4120636dff151a87c11f2c13a8cc6a68 ../data/screenshots/pending_montlake/01x04_i8.png
|
||||
fb176e55ed4aff96cae3e6eacbe962b1 ../data/screenshots/pending_montlake/02x04_i0.png
|
||||
47a908fb01793372e519aebf3ce1331c ../data/screenshots/pending_montlake/03x04_i20.png
|
||||
56ab5c97e826fcda2d61f01ef9098316 ../data/screenshots/pending_montlake/01x05_i54.png
|
||||
353fa3e6a5147fc43fbd9df77341e48b ../data/screenshots/pending_montlake/02x05_i52.png
|
||||
2b3d9b662d554264e26fb2a65b852cb6 ../data/screenshots/pending_montlake/03x05_i30.png
|
||||
9806e3f0e42cd50f2499412ece773472 ../data/screenshots/pending_montlake/01x06_i18.png
|
||||
90266304da3f2926fa4a6965aeeffa4b ../data/screenshots/pending_montlake/02x06_i16.png
|
||||
d6572135349481048d7455fe094b5e72 ../data/screenshots/pending_montlake/03x06_i1.png
|
||||
b89d68bc6b945609b7ea166e14f61670 ../data/screenshots/pending_montlake/01x07_i121.png
|
||||
74de0ca9fb695c6230e91c50795a8ed5 ../data/screenshots/pending_montlake/02x07_i28.png
|
||||
5767e34c7299f799bf4da9cc6c1cb805 ../data/screenshots/pending_montlake/03x07_i25.png
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
before=$1;
|
||||
after=$2;
|
||||
name=$1;
|
||||
before=../data/screenshots/pending_$name;
|
||||
after=../data/screenshots/$name;
|
||||
|
||||
rm -rf diff
|
||||
mkdir diff
|
||||
@ -14,12 +15,10 @@ for file in `ls $before | grep -v full.png | grep -v combine.sh | grep -v MANIFE
|
||||
diff $before/${prefix}* $after/${prefix}*;
|
||||
if [ $? -eq 1 ]; then
|
||||
compare $before/${prefix}* $after/${prefix}* diff/${prefix}.png;
|
||||
if [ "$3" == "-i" ]; then
|
||||
feh diff/${prefix}.png $before/${prefix}* $after/${prefix}*;
|
||||
# Handle interrupts by killing the script entirely
|
||||
if [ $? -ne 0 ]; then
|
||||
exit;
|
||||
fi
|
||||
feh diff/${prefix}.png $before/${prefix}* $after/${prefix}*;
|
||||
# Handle interrupts by killing the script entirely
|
||||
if [ $? -ne 0 ]; then
|
||||
exit;
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@ -11,7 +11,6 @@ use ordered_float::NotNan;
|
||||
|
||||
pub struct DrawIntersection {
|
||||
pub id: IntersectionID,
|
||||
pub polygon: Polygon,
|
||||
pub crosswalks: Vec<DrawCrosswalk>,
|
||||
intersection_type: IntersectionType,
|
||||
zorder: isize,
|
||||
@ -67,7 +66,6 @@ impl DrawIntersection {
|
||||
|
||||
DrawIntersection {
|
||||
id: i.id,
|
||||
polygon: i.polygon.clone(),
|
||||
crosswalks: calculate_crosswalks(i.id, map, prerender, cs),
|
||||
intersection_type: i.intersection_type,
|
||||
zorder: i.get_zorder(map),
|
||||
@ -92,7 +90,7 @@ impl Renderable for DrawIntersection {
|
||||
fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, ctx: &DrawCtx) {
|
||||
if let Some(color) = opts.color(self.get_id()) {
|
||||
// Don't draw the sidewalk corners
|
||||
g.draw_polygon(color, &self.polygon);
|
||||
g.draw_polygon(color, &ctx.map.get_i(self.id).polygon);
|
||||
} else {
|
||||
g.redraw(&self.draw_default);
|
||||
|
||||
@ -108,12 +106,15 @@ impl Renderable for DrawIntersection {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_outline(&self, _: &Map) -> Polygon {
|
||||
PolyLine::make_polygons_for_boundary(self.polygon.points().clone(), OUTLINE_THICKNESS)
|
||||
fn get_outline(&self, map: &Map) -> Polygon {
|
||||
PolyLine::make_polygons_for_boundary(
|
||||
map.get_i(self.id).polygon.points().clone(),
|
||||
OUTLINE_THICKNESS,
|
||||
)
|
||||
}
|
||||
|
||||
fn contains_pt(&self, pt: Pt2D, _: &Map) -> bool {
|
||||
self.polygon.contains_pt(pt)
|
||||
fn contains_pt(&self, pt: Pt2D, map: &Map) -> bool {
|
||||
map.get_i(self.id).polygon.contains_pt(pt)
|
||||
}
|
||||
|
||||
fn get_zorder(&self) -> isize {
|
||||
|
@ -61,22 +61,11 @@ pub fn intersection_polygon(
|
||||
l.pt1().angle_to(intersection_center).normalized_degrees() as i64
|
||||
});
|
||||
|
||||
let mut endpoints = if lines.len() == 1 {
|
||||
if lines.len() == 1 {
|
||||
deadend(roads, i.id, &lines).get(timer)
|
||||
} else {
|
||||
generalized_trim_back(roads, i.id, &lines, timer)
|
||||
};
|
||||
|
||||
// Close off the polygon
|
||||
if endpoints
|
||||
.last()
|
||||
.unwrap()
|
||||
.approx_eq(endpoints[0], Distance::meters(0.1))
|
||||
{
|
||||
endpoints.pop();
|
||||
}
|
||||
endpoints.push(endpoints[0]);
|
||||
endpoints
|
||||
}
|
||||
|
||||
fn generalized_trim_back(
|
||||
@ -284,8 +273,27 @@ fn generalized_trim_back(
|
||||
timer.warn(format!("Excluding collision between original polylines of {} and something, because stuff's too short", id));
|
||||
}
|
||||
}
|
||||
// TODO Caller will close off the polygon. Does that affect our dedupe?
|
||||
Pt2D::approx_dedupe(endpoints, Distance::meters(0.1))
|
||||
let main_result = close_off_polygon(Pt2D::approx_dedupe(endpoints, Distance::meters(0.1)));
|
||||
|
||||
// There are bad polygons caused by weird short roads. As a temporary workaround, detect cases
|
||||
// where polygons dramatically double back on themselves and force the polygon to proceed
|
||||
// around its center.
|
||||
let mut deduped = main_result.clone();
|
||||
deduped.pop();
|
||||
deduped.sort_by_key(|pt| HashablePt2D::from(*pt));
|
||||
deduped = Pt2D::approx_dedupe(deduped, Distance::meters(0.1));
|
||||
let center = Pt2D::center(&deduped);
|
||||
deduped.sort_by_key(|pt| pt.angle_to(center).normalized_degrees() as i64);
|
||||
deduped = close_off_polygon(deduped);
|
||||
if main_result.len() == deduped.len() {
|
||||
main_result
|
||||
} else {
|
||||
timer.warn(format!(
|
||||
"{}'s polygon has weird repeats, forcibly removing points",
|
||||
i
|
||||
));
|
||||
deduped
|
||||
}
|
||||
}
|
||||
|
||||
fn deadend(
|
||||
@ -316,15 +324,15 @@ fn deadend(
|
||||
);
|
||||
}
|
||||
|
||||
Warn::ok(vec![
|
||||
Warn::ok(close_off_polygon(vec![
|
||||
pt1.unwrap(),
|
||||
pt2.unwrap(),
|
||||
pl_b.last_pt(),
|
||||
pl_a.last_pt(),
|
||||
])
|
||||
]))
|
||||
} else {
|
||||
Warn::warn(
|
||||
vec![pl_a.last_pt(), pl_b.last_pt()],
|
||||
vec![pl_a.last_pt(), pl_b.last_pt(), pl_a.last_pt()],
|
||||
format!(
|
||||
"{} is a dead-end for {}, which is too short to make degenerate intersection geometry",
|
||||
i, id
|
||||
@ -332,3 +340,11 @@ fn deadend(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn close_off_polygon(mut pts: Vec<Pt2D>) -> Vec<Pt2D> {
|
||||
if pts.last().unwrap().approx_eq(pts[0], Distance::meters(0.1)) {
|
||||
pts.pop();
|
||||
}
|
||||
pts.push(pts[0]);
|
||||
pts
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user