diff --git a/src/libslic3r/TriangleSelector.cpp b/src/libslic3r/TriangleSelector.cpp index 0ac985fdf..31d1b166a 100644 --- a/src/libslic3r/TriangleSelector.cpp +++ b/src/libslic3r/TriangleSelector.cpp @@ -254,8 +254,7 @@ void TriangleSelector::select_patch(int facet_start, std::unique_ptr &&c } } - const float highlight_angle_limit = cos(Geometry::deg2rad(highlight_by_angle_deg)); - Vec3f vec_down = (trafo_no_translate.inverse() * -Vec3d::UnitZ()).normalized().cast(); + const float highlight_angle_limit = -cos(Geometry::deg2rad(highlight_by_angle_deg)); // BBS std::vector start_facets; @@ -291,7 +290,8 @@ void TriangleSelector::select_patch(int facet_start, std::unique_ptr &&c while (facet_idx < int(facets_to_check.size())) { int facet = facets_to_check[facet_idx]; const Vec3f& facet_normal = m_face_normals[m_triangles[facet].source_triangle]; - if (!visited[facet] && (highlight_by_angle_deg == 0.f || vec_down.dot(facet_normal) >= highlight_angle_limit)) { + float world_normal_z = (trafo_no_translate.inverse() * facet_normal.cast()).normalized().cast().z(); + if (!visited[facet] && (highlight_by_angle_deg == 0.f || world_normal_z < highlight_angle_limit)) { if (select_triangle(facet, new_state, triangle_splitting)) { // add neighboring facets to list to be processed later for (int neighbor_idx : m_neighbors[facet]) @@ -331,8 +331,7 @@ void TriangleSelector::seed_fill_select_triangles(const Vec3f &hit, int facet_st facet_queue.push(facet_start); const double facet_angle_limit = cos(Geometry::deg2rad(seed_fill_angle)) - EPSILON; - const float highlight_angle_limit = cos(Geometry::deg2rad(highlight_by_angle_deg)); - Vec3f vec_down = (trafo_no_translate.inverse() * -Vec3d::UnitZ()).normalized().cast(); + const float highlight_angle_limit = -cos(Geometry::deg2rad(highlight_by_angle_deg)); // Depth-first traversal of neighbors of the face hit by the ray thrown from the mouse cursor. while (!facet_queue.empty()) { @@ -340,7 +339,8 @@ void TriangleSelector::seed_fill_select_triangles(const Vec3f &hit, int facet_st facet_queue.pop(); const Vec3f &facet_normal = m_face_normals[m_triangles[current_facet].source_triangle]; - if (!visited[current_facet] && (highlight_by_angle_deg == 0.f || vec_down.dot(facet_normal) >= highlight_angle_limit)) { + float world_normal_z = (trafo_no_translate.inverse() * facet_normal.cast()).normalized().cast().z(); + if (!visited[current_facet] && (highlight_by_angle_deg == 0.f || world_normal_z < highlight_angle_limit)) { if (m_triangles[current_facet].is_split()) { for (int split_triangle_idx = 0; split_triangle_idx <= m_triangles[current_facet].number_of_split_sides(); ++split_triangle_idx) { assert(split_triangle_idx < int(m_triangles[current_facet].children.size()));