mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
fix: Eliminate redundant Z coordinates in ZAA gcode output
extrude_to_xyz() unconditionally emitted Z on every extrusion move via emit_xyz(), even when Z hadn't changed. With ZAA enabled, this produced ~987K redundant Z coordinates (98.2% of all Z emissions), causing 10-20% file bloat. Now compares quantized Z values before and after, and only emits Z when it actually differs at export precision (0.001mm). Reduces ZAA gcode Z emissions from 1,038,468 to 50,022 while preserving all legitimate contouring Z changes.
This commit is contained in:
@@ -911,6 +911,11 @@ std::string GCodeWriter::extrude_arc_to_xy(const Vec2d& point, const Vec2d& cent
|
|||||||
|
|
||||||
std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std::string &comment, bool force_no_extrusion)
|
std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std::string &comment, bool force_no_extrusion)
|
||||||
{
|
{
|
||||||
|
// Check if Z actually changes (at export precision) before emitting it.
|
||||||
|
// ZAA sloped extrusions call this for every segment, but many consecutive
|
||||||
|
// segments share the same quantized Z — emitting it every time is redundant.
|
||||||
|
bool z_changed = (GCodeG1Formatter::quantize_xyzf(point(2)) != GCodeG1Formatter::quantize_xyzf(m_pos(2)));
|
||||||
|
|
||||||
m_pos = point;
|
m_pos = point;
|
||||||
m_lifted = 0;
|
m_lifted = 0;
|
||||||
if (!force_no_extrusion)
|
if (!force_no_extrusion)
|
||||||
@@ -920,7 +925,10 @@ std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std
|
|||||||
Vec3d point_on_plate = { point(0) - m_x_offset, point(1) - m_y_offset, point(2) };
|
Vec3d point_on_plate = { point(0) - m_x_offset, point(1) - m_y_offset, point(2) };
|
||||||
|
|
||||||
GCodeG1Formatter w;
|
GCodeG1Formatter w;
|
||||||
w.emit_xyz(point_on_plate);
|
if (z_changed)
|
||||||
|
w.emit_xyz(point_on_plate);
|
||||||
|
else
|
||||||
|
w.emit_xy(Vec2d(point_on_plate.x(), point_on_plate.y()));
|
||||||
if (!force_no_extrusion)
|
if (!force_no_extrusion)
|
||||||
w.emit_e(filament()->E());
|
w.emit_e(filament()->E());
|
||||||
//BBS
|
//BBS
|
||||||
|
|||||||
Reference in New Issue
Block a user