diff --git a/src/libslic3r/ContourZ.cpp b/src/libslic3r/ContourZ.cpp index 50a3417c22..f4a5fc049a 100644 --- a/src/libslic3r/ContourZ.cpp +++ b/src/libslic3r/ContourZ.cpp @@ -37,7 +37,7 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh & } Layer *layer = region->layer(); - coordf_t mesh_z = layer->print_z + mesh.ground_level(); + coordf_t mesh_slice_z = layer->slice_z + mesh.ground_level(); coordf_t min_z = region->region().config().zaa_min_z; const Points3 &points = path.polyline.points; @@ -74,14 +74,10 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh & coordf_t x = p.x(); coordf_t y = p.y(); - sla::IndexedMesh::hit_result hit_up = mesh.query_ray_hit({x, y, mesh_z}, {0.0, 0.0, 1.0}); - sla::IndexedMesh::hit_result hit_down = mesh.query_ray_hit({x, y, mesh_z}, {0.0, 0.0, -1.0}); + sla::IndexedMesh::hit_result hit_up = mesh.query_ray_hit({x, y, mesh_slice_z}, {0.0, 0.0, 1.0}); + + double d = hit_up.distance() - (layer->print_z - layer->slice_z); - double up = hit_up.distance(); - double down = hit_down.distance(); - double d = up < down ? up : -down; - const Vec3d &normal = (up < down ? hit_up : hit_down).normal(); - double max_up = min_z; double min_down = -(height - min_z); double half_width = path.width / 2.0; @@ -90,7 +86,8 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh & min_down = -(height + 0.1); } - if (is_perimeter(path.role())) { + if (is_perimeter(path.role()) && hit_up.is_hit()) { + const Vec3d &normal = hit_up.normal(); double slope_rad = slope_from_normal(normal); double slope_degrees = slope_rad * 180.0 / M_PI;