diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 89c47fbb2..1028feea8 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -663,8 +663,8 @@ void compute_global_occlusion(GlobalModelInfo &result, const PrintObject *po, BOOST_LOG_TRIVIAL(debug) << "SeamPlacer: decimate: start"; - its_short_edge_collpase(triangle_set, 25000); - its_short_edge_collpase(negative_volumes_set, 25000); + its_short_edge_collpase(triangle_set, SeamPlacer::fast_decimation_triangle_count_target); + its_short_edge_collpase(negative_volumes_set, SeamPlacer::fast_decimation_triangle_count_target); size_t negative_volumes_start_index = triangle_set.indices.size(); its_merge(triangle_set, negative_volumes_set); diff --git a/src/libslic3r/GCode/SeamPlacer.hpp b/src/libslic3r/GCode/SeamPlacer.hpp index 696bbdf61..2e5996905 100644 --- a/src/libslic3r/GCode/SeamPlacer.hpp +++ b/src/libslic3r/GCode/SeamPlacer.hpp @@ -123,6 +123,7 @@ class SeamPlacer { public: // Number of samples generated on the mesh. There are sqr_rays_per_sample_point*sqr_rays_per_sample_point rays casted from each samples static constexpr size_t raycasting_visibility_samples_count = 30000; + static constexpr size_t fast_decimation_triangle_count_target = 16000; //square of number of rays per sample point static constexpr size_t sqr_rays_per_sample_point = 5; diff --git a/src/libslic3r/ShortEdgeCollapse.cpp b/src/libslic3r/ShortEdgeCollapse.cpp index b36278c37..0c940cb47 100644 --- a/src/libslic3r/ShortEdgeCollapse.cpp +++ b/src/libslic3r/ShortEdgeCollapse.cpp @@ -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