fixed offset distance of shifted inner seams, improved nearest to be actually nearest

This commit is contained in:
PavelMikus 2022-08-18 13:33:47 +02:00
parent 1c2c9fd5d9
commit 81f07c69e5

View File

@ -786,8 +786,8 @@ struct SeamComparator {
float distance_penalty_a = 0.0f;
float distance_penalty_b = 0.0f;
if (setup == spNearest) {
distance_penalty_a = 1.0f - gauss((a.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.005f);
distance_penalty_b = 1.0f - gauss((b.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.005f);
distance_penalty_a = (a.position.head<2>() - preffered_location).squaredNorm() > 5.0f*5.0f ? 5.0f : 0.0f;
distance_penalty_b = (b.position.head<2>() - preffered_location).squaredNorm() > 5.0f*5.0f ? 5.0f : 0.0f;
}
// the penalites are kept close to range [0-1.x] however, it should not be relied upon
@ -1616,7 +1616,7 @@ void SeamPlacer::place_seam(const Layer *layer, ExtrusionLoop &loop, bool extern
if (po->config().shifted_inner_seams) {
//shifting
//fix depth, it is sometimes strongly underestimated
depth = std::max(loop.paths[projected_point.path_idx].width, depth)+ 0.3*loop.paths[projected_point.path_idx].width;
depth = std::max(loop.paths[projected_point.path_idx].width, (depth + 0.3f*loop.paths[projected_point.path_idx].width) * 1.2f);
Vec2f current_pos = unscale(seam_point).cast<float>();
Vec2f next_pos = unscale(loop.paths[projected_point.path_idx].polyline.points[projected_point.segment_idx + 1]).cast<float>();
Vec2f dir_to_next = (next_pos - current_pos).normalized();