From 49e6762ae70c8b74629b7527215c4bdf04ace5ab Mon Sep 17 00:00:00 2001 From: PavelMikus Date: Wed, 11 May 2022 11:12:20 +0200 Subject: [PATCH] replace abs with comparison in the QEC, it is faster --- src/libslic3r/QuadricEdgeCollapse.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/QuadricEdgeCollapse.cpp b/src/libslic3r/QuadricEdgeCollapse.cpp index c5ae0e6056..be0a90ec1a 100644 --- a/src/libslic3r/QuadricEdgeCollapse.cpp +++ b/src/libslic3r/QuadricEdgeCollapse.cpp @@ -614,15 +614,15 @@ bool QuadricEdgeCollapse::is_flipped(const Vec3f & new_vertex, d2.normalize(); float dot = d1.dot(d2); - if (std::abs(dot) > triangle_beauty_threshold) { // OK, the new triangle is suspiciously ugly, but it can still be better than the original + if (dot > triangle_beauty_threshold || dot < -triangle_beauty_threshold) { // OK, the new triangle is suspiciously ugly, but it can still be better than the original const Vec3f &v_orig = its.vertices[t[(e_info.edge) % 3]]; Vec3f d1_orig = vf - v_orig; d1_orig.normalize(); Vec3f d2_orig = vs - v_orig; d2_orig.normalize(); - if (std::abs(d1_orig.dot(d2_orig)) < std::abs(dot)) { // original was not that ugly, so return flipped + if (std::fabs(d1_orig.dot(d2_orig)) < std::fabs(dot)) { // original was not that ugly, so return flipped return true; - } + } // else original triangle was worse than the new, so don't discard the new yet } // IMPROVE: propagate new normal Vec3f n = d1.cross(d2);