From 095dfcad9e23a88398c99cf49badb94d9d46066c Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 31 Jan 2019 10:11:37 +0100 Subject: [PATCH] Getting rid of signed distance from collision detection. --- src/libslic3r/SLA/SLASupportTree.cpp | 16 ++++++++++------ src/libslic3r/SLA/SLASupportTree.hpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 4640037bb..54e3a0189 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -659,6 +659,7 @@ double pinhead_mesh_intersect(const Vec3d& s, if(hr.is_inside()) { // the hit is inside the model if(hr.distance() > 2*r_pin) phi = 0; else { + // re-cast the ray from the outside of the object auto hr2 = m.query_ray_hit(ps + (hr.distance() + 2*sd)*n, n); phi = hr2.distance(); } @@ -708,13 +709,16 @@ double bridge_mesh_intersect(const Vec3d& s, s(Y) + rcos * a(Y) + rsin * b(Y), s(Z) + rcos * a(Z) + rsin * b(Z)); - Vec3d sp; - if(ins_check) { - auto result = m.signed_distance(p); - sp = result.value() < 0 ? result.point_on_mesh() : p; - } else sp = p; + auto hr = m.query_ray_hit(p + sd*dir, dir); - phi = m.query_ray_hit(sp + sd*dir, dir).distance(); + if(ins_check && hr.is_inside()) { + if(hr.distance() > 2*r) phi = 0; + else { + // re-cast the ray from the outside of the object + auto hr2 = m.query_ray_hit(p + (hr.distance() + 2*sd)*dir, dir); + phi = hr2.distance(); + } + } else phi = hr.distance(); }); auto mit = std::min_element(phis.begin(), phis.end()); diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index b1e77b056..8de8d2b33 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -78,7 +78,7 @@ struct SupportConfig { 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; + double normal_cutoff_angle = 150.0 * M_PI / 180.0; };