mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
squish_polygons_together infinite loops sometimes. until a proper fix, just limit it to 100 relaxations
This commit is contained in:
parent
bef3434ac8
commit
7d460f27c8
@ -928,6 +928,7 @@ fn squish_polygons_together(mut polygons: Vec<Polygon>) -> Vec<(f64, f64)> {
|
||||
// Once a polygon hits another while moving, stop adjusting it. Otherwise, go round-robin.
|
||||
let mut indices: VecDeque<usize> = (0..polygons.len()).collect();
|
||||
|
||||
let mut attempts = 0;
|
||||
while !indices.is_empty() {
|
||||
let idx = indices.pop_front().unwrap();
|
||||
let center = Pt2D::center(&polygons.iter().map(|p| p.center()).collect());
|
||||
@ -948,6 +949,11 @@ fn squish_polygons_together(mut polygons: Vec<Polygon>) -> Vec<(f64, f64)> {
|
||||
polygons[idx] = translated;
|
||||
indices.push_back(idx);
|
||||
}
|
||||
|
||||
attempts += 1;
|
||||
if attempts == 100 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
translations
|
||||
|
Loading…
Reference in New Issue
Block a user