fix(build): convert ProcessedPoint.p (Point3) to 2D for gradient Line/Point ops in GCode.cpp

This commit is contained in:
thysson2701
2026-07-21 22:19:06 +02:00
parent 868858eaa5
commit 795c47c2c2

View File

@@ -13623,14 +13623,14 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
// Calculate total extrusion length
Points p;
p.reserve(new_points.size());
std::transform(new_points.begin(), new_points.end(), std::back_inserter(p), [](const ProcessedPoint& pp) { return pp.p; });
std::transform(new_points.begin(), new_points.end(), std::back_inserter(p), [](const ProcessedPoint& pp) { return pp.p.to_point(); });
Polyline l(p);
total_length = l.length() * SCALING_FACTOR;
}
gcode += m_writer.set_speed(last_set_speed, "", comment);
Point prev_point_model = new_points[0].p;
Point prev_point_model = new_points[0].p.to_point();
if (outer_wall_gradient_modulated_path && new_points.size() > 1) {
const Line first_line(new_points[0].p, new_points[1].p);
const Line first_line(new_points[0].p.to_point(), new_points[1].p.to_point());
const OuterWallGradientSurfaceCoord first_surface_coord =
halftone_surface_coord_for_source_distance(first_line.length() * SCALING_FACTOR * 0.5);
const OuterWallGradientSegmentMod first_mod =
@@ -13668,7 +13668,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
for (size_t i = 1; i < new_points.size(); ++i) {
const ProcessedPoint &processed_point = new_points[i];
const ProcessedPoint &pre_processed_point = new_points[i - 1];
const Line parent_source_line(pre_processed_point.p, processed_point.p);
const Line parent_source_line(pre_processed_point.p.to_point(), processed_point.p.to_point());
const double parent_source_length_mm = parent_source_line.length() * SCALING_FACTOR;
const double safe_parent_source_length_mm =
std::isfinite(parent_source_length_mm) ? std::max(0.0, parent_source_length_mm) : 0.0;
@@ -13879,7 +13879,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
std::string tempDescription = description;
const ProcessedPoint &processed_point = new_points[i];
const ProcessedPoint &pre_processed_point = new_points[i-1];
const Line parent_source_line(pre_processed_point.p, processed_point.p);
const Line parent_source_line(pre_processed_point.p.to_point(), processed_point.p.to_point());
const double parent_source_length_mm = parent_source_line.length() * SCALING_FACTOR;
const double safe_parent_source_length_mm =
std::isfinite(parent_source_length_mm) ? std::max(0.0, parent_source_length_mm) : 0.0;
@@ -13896,7 +13896,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
dynamic_line_modulation ?
dynamic_modulation_for_line(parent_source_line, segment_surface_coord) :
segment_modulation_at(i - 1);
const Point processed_target_point = make_shifted_point(processed_point.p, segment_mod.shift_dx, segment_mod.shift_dy);
const Point processed_target_point = make_shifted_point(processed_point.p.to_point(), segment_mod.shift_dx, segment_mod.shift_dy);
Vec2d p = this->point_to_gcode_quantized(processed_target_point);
if (!is_reasonable_quantized_gcode_point_for_gcode(p))
continue;
@@ -13987,7 +13987,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
outer_wall_gradient_dynamic_ctx.vertex_color_match_mode &&
outer_wall_gradient_dynamic_ctx.high_resolution_texture_sampling;
if (high_res_dynamic_subsegments) {
const Line parent_line(pre_processed_point.p, processed_point.p);
const Line parent_line(pre_processed_point.p.to_point(), processed_point.p.to_point());
const double modulation_step_mm =
outer_wall_gradient_dynamic_ctx.dithering_enabled ?
std::clamp(double(outer_wall_gradient_dynamic_ctx.dither_pitch_mm), 0.04, 0.12) :