ZAA: Fix Z-contouring raycast reference plane and Eigen UB (#13510)

* Add safety checks and add logic to avoid creating degenerate polygons in contour_extrusion_path

* fix comment

* fix(zaa): cast from slice_z upward only, guard normal on miss

* remove old code

---------

Co-authored-by: Aleksandr Dobkin <alex@dobk.in>
Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
This commit is contained in:
Aleksandr Dobkinimg src=404 onerror=alert(document.domain)
2026-05-08 09:22:00 -07:00
committed by GitHub
parent c9413bb4ef
commit 447d4452e6

View File

@@ -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,13 +74,9 @@ 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 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 d = hit_up.distance() - (layer->print_z - layer->slice_z);
double max_up = min_z;
double min_down = -(height - min_z);
@@ -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;