mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
FIX: short edge collapse algortihm
so that it does not decimate all triangles on very high detailed models Relevant issue 8834 Access Error when slicing Github: #2283 Change-Id: I047361c88c561962ef4d3cf67bc0126402c41941 (cherry picked from commit f8aaa5c69d59c5fced4b7bb112376e4df94b5ddc)
This commit is contained in:
parent
731035b8b6
commit
a15700e5de
3 changed files with 11 additions and 5 deletions
|
@ -97,7 +97,8 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
|
|||
|
||||
//shuffle the faces and traverse in random order, this MASSIVELY improves the quality of the result
|
||||
std::shuffle(face_indices.begin(), face_indices.end(), generator);
|
||||
|
||||
|
||||
int allowed_face_removals = int(face_indices.size()) - int(target_triangle_count);
|
||||
for (const size_t &face_idx : face_indices) {
|
||||
if (face_removal_flags[face_idx]) {
|
||||
// if face already removed from previous collapses, skip (each collapse removes two triangles [at least] )
|
||||
|
@ -130,10 +131,13 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
|
|||
// remove faces
|
||||
remove_face(face_idx, neighbor_to_remove_face_idx);
|
||||
remove_face(neighbor_to_remove_face_idx, face_idx);
|
||||
allowed_face_removals-=2;
|
||||
|
||||
// break. this triangle is done
|
||||
break;
|
||||
}
|
||||
|
||||
if (allowed_face_removals <= 0) { break; }
|
||||
}
|
||||
|
||||
// filter face_indices, remove those that have been collapsed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue