Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavelMikus <pavel.mikus.mail@seznam.cz>2022-06-08 11:04:37 +0300
committerPavelMikus <pavel.mikus.mail@seznam.cz>2022-06-08 11:04:37 +0300
commitf1cc29656ea233d4ba90def567ef3c4b19e08ffc (patch)
treea6c6b5d622e0286c943465bdbf713c4b45656b2b
parent2bb5ec6e2143debd2542c38acb2455f00943a3a3 (diff)
improve visibility estimation via distance to plane weighting.pm_stable_port_seams
increase angle importance, improve alignment
-rw-r--r--src/libslic3r/GCode/SeamPlacer.cpp36
-rw-r--r--src/libslic3r/GCode/SeamPlacer.hpp6
2 files changed, 26 insertions, 16 deletions
diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp
index f2d386c05..5ca34573a 100644
--- a/src/libslic3r/GCode/SeamPlacer.cpp
+++ b/src/libslic3r/GCode/SeamPlacer.cpp
@@ -178,7 +178,7 @@ std::vector<float> raycast_visibility(const AABBTreeIndirect::Tree<3, float> &ra
// FIXME: This AABBTTreeIndirect query will not compile for float ray origin and
// direction.
Vec3d final_ray_dir_d = final_ray_dir.cast<double>();
- Vec3d ray_origin_d = (center + normal * 0.03).cast<double>(); // start above surface.
+ Vec3d ray_origin_d = (center + normal * 1.0f).cast<double>(); // start above surface.
bool hit = AABBTreeIndirect::intersect_ray_first_hit(triangles.vertices,
triangles.indices, raycasting_tree, ray_origin_d, final_ray_dir_d, hitpoint);
if (hit && its_face_normal(triangles, hitpoint.id).dot(final_ray_dir) <= 0) {
@@ -188,10 +188,10 @@ std::vector<float> raycast_visibility(const AABBTreeIndirect::Tree<3, float> &ra
bool casting_from_negative_volume = samples.triangle_indices[s_idx]
>= negative_volumes_start_index;
- Vec3d ray_origin_d = (center + normal * 0.1).cast<double>(); // start above surface.
+ Vec3d ray_origin_d = (center + normal * 1.0f).cast<double>(); // start above surface.
if (casting_from_negative_volume) { // if casting from negative volume face, invert direction, change start pos
final_ray_dir = -1.0 * final_ray_dir;
- ray_origin_d = (center - normal * 0.03).cast<double>();
+ ray_origin_d = (center - normal * 1.0f).cast<double>();
}
Vec3d final_ray_dir_d = final_ray_dir.cast<double>();
bool some_hit = AABBTreeIndirect::intersect_ray_all_hits(triangles.vertices,
@@ -327,12 +327,22 @@ struct GlobalModelInfo {
return 1.0f;
}
+ auto compute_dist_to_plane = [](const Vec3f& position, const Vec3f& plane_origin, const Vec3f& plane_normal) {
+ Vec3f orig_to_point = position - plane_origin;
+ return std::abs(orig_to_point.dot(plane_normal));
+ };
+
+
float total_weight = 0;
float total_visibility = 0;
for (size_t i = 0; i < points.size(); ++i) {
size_t sample_idx = points[i];
- float weight = 1.0f; // SeamPlacer::visibility_samples_radius * SeamPlacer::visibility_samples_radius -
- //(position - mesh_samples.positions[sample_idx]).squaredNorm();
+
+ Vec3f sample_point = this->mesh_samples.positions[sample_idx];
+ Vec3f sample_normal = this->mesh_samples.normals[sample_idx];
+
+ float weight = mesh_samples_radius - compute_dist_to_plane(position, sample_point, sample_normal);
+ weight += (mesh_samples_radius - (position - sample_point).norm());
total_visibility += weight * mesh_samples_visibility[sample_idx];
total_weight += weight;
}
@@ -449,9 +459,9 @@ void process_perimeter_polygon(const Polygon &orig_polygon, float z_coord, const
std::vector<float> lengths { };
for (size_t point_idx = 0; point_idx < polygon.size() - 1; ++point_idx) {
- lengths.push_back(std::max((unscale(polygon[point_idx]) - unscale(polygon[point_idx + 1])).norm(), 0.01));
+ lengths.push_back(std::max((unscale(polygon[point_idx]) - unscale(polygon[point_idx + 1])).norm(), 0.001));
}
- lengths.push_back(std::max((unscale(polygon[0]) - unscale(polygon[polygon.size() - 1])).norm(), 0.01));
+ lengths.push_back(std::max((unscale(polygon[0]) - unscale(polygon[polygon.size() - 1])).norm(), 0.001));
std::vector<float> local_angles = calculate_polygon_angles_at_vertices(polygon, lengths,
SeamPlacer::polygon_local_angles_arm_distance);
@@ -712,11 +722,11 @@ struct SeamComparator {
return a.overhang < b.overhang;
}
- // prefer hidden points (more than 1 mm inside)
- if (a.embedded_distance < -1.0f && b.embedded_distance > -1.0f) {
+ // prefer hidden points (more than 0.5 mm inside)
+ if (a.embedded_distance < -0.5f && b.embedded_distance > -0.5f) {
return true;
}
- if (b.embedded_distance < -1.0f && a.embedded_distance > -1.0f) {
+ if (b.embedded_distance < -0.5f && a.embedded_distance > -0.5f) {
return false;
}
@@ -773,11 +783,11 @@ struct SeamComparator {
return a.overhang < b.overhang;
}
- // prefer hidden points (more than 1 mm inside)
- if (a.embedded_distance < -1.0f && b.embedded_distance > -1.0f) {
+ // prefer hidden points (more than 0.5 mm inside)
+ if (a.embedded_distance < -0.5f && b.embedded_distance > -0.5f) {
return true;
}
- if (b.embedded_distance < -1.0f && a.embedded_distance > -1.0f) {
+ if (b.embedded_distance < -0.5f && a.embedded_distance > -0.5f) {
return false;
}
diff --git a/src/libslic3r/GCode/SeamPlacer.hpp b/src/libslic3r/GCode/SeamPlacer.hpp
index e297497d1..fdd46dd12 100644
--- a/src/libslic3r/GCode/SeamPlacer.hpp
+++ b/src/libslic3r/GCode/SeamPlacer.hpp
@@ -133,7 +133,7 @@ public:
static constexpr float overhang_distance_tolerance_factor = 0.5f;
// determines angle importance compared to visibility ( neutral value is 1.0f. )
- static constexpr float angle_importance_aligned = 0.6f;
+ static constexpr float angle_importance_aligned = 1.0f;
static constexpr float angle_importance_nearest = 2.0f; // use much higher angle importance for nearest mode, to combat the visiblity info noise
// If enforcer or blocker is closer to the seam candidate than this limit, the seam candidate is set to Blocker or Enforcer
@@ -143,8 +143,8 @@ public:
// When searching for seam clusters for alignment:
// following value describes, how much worse score can point have and still be picked into seam cluster instead of original seam point on the same layer
- static constexpr float seam_align_score_tolerance = 0.27f;
- // seam_align_tolerable_dist - if next layer closes point is too far away, break string
+ static constexpr float seam_align_score_tolerance = 0.45f;
+ // seam_align_tolerable_dist - if next layer closest point is too far away, skip layer
static constexpr float seam_align_tolerable_dist = 1.0f;
// if the seam of the current layer is too far away, and the closest seam candidate is not very good, layer is skipped.
// this param limits the number of allowed skips