diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 60915c2ad..11ffc33b0 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -1085,7 +1085,8 @@ bool SLASupportTree::generate(const PointSet &points, double polar = std::acos(z / r); double azimuth = std::atan2(n(1), n(0)); - if(polar >= PI / 2) { // skip if the tilt is not sane + // skip if the tilt is not sane + if(polar >= PI - cfg.normal_cutoff_angle) { // We saturate the polar angle to 3pi/4 polar = std::max(polar, 3*PI / 4); diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index e19f263b6..c187cf5b3 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -67,6 +67,10 @@ struct SupportConfig { // The elevation in Z direction upwards. This is the space between the pad // and the model object's bounding box bottom. double object_elevation_mm = 10; + + // The max Z angle for a normal at which it will get completely ignored. + double normal_cutoff_angle = 110.0 * M_PI / 180.0; + }; struct PoolConfig; diff --git a/src/libslic3r/SLA/SLASupportTreeIGL.cpp b/src/libslic3r/SLA/SLASupportTreeIGL.cpp index 8971b6ede..0cc9f14e0 100644 --- a/src/libslic3r/SLA/SLASupportTreeIGL.cpp +++ b/src/libslic3r/SLA/SLASupportTreeIGL.cpp @@ -188,7 +188,15 @@ PointSet normals(const PointSet& points, const EigenMesh3D& emesh, neighnorms.emplace_back(U.cross(V).normalized()); } - // Throw out duplicates. They would case trouble with summing. + // Throw out duplicates. They would cause trouble with summing. We will + // use std::unique which works on sorted ranges. We will sort by the + // coefficient-wise sum of the normals. It should force the same + // elements to be consecutive. + std::sort(neighnorms.begin(), neighnorms.end(), + [](const Vec3d& v1, const Vec3d& v2){ + return v1.sum() < v2.sum(); + }); + auto lend = std::unique(neighnorms.begin(), neighnorms.end(), [](const Vec3d& n1, const Vec3d& n2) { // Compare normals for equivalence. This is controvers stuff.