diff --git a/src/algorithms/fiduccia_mattheyses.rs b/src/algorithms/fiduccia_mattheyses.rs index a9cd064a..b3f33e04 100644 --- a/src/algorithms/fiduccia_mattheyses.rs +++ b/src/algorithms/fiduccia_mattheyses.rs @@ -122,10 +122,10 @@ fn fiduccia_mattheyses( // number of vertices in the mesh. However, if too many subsequent // bad flips are performed, the loop will break early for _ in 0..max_moves_per_pass { - let (moved_vertex, move_gain) = match gain_to_vertex + let (moved_vertex, move_gain) = match gain_to_vertex[gain_table_idx(1)..] .iter() - .rev() - .zip((-max_possible_gain..=max_possible_gain).rev()) + .chain(gain_to_vertex[..gain_table_idx(1)].iter().rev()) + .zip((1..=max_possible_gain).chain((-max_possible_gain..1).rev())) .find_map(|(vertices, gain)| { let (best_vertex, _) = vertices .iter()