Decouple Slicing From Machine Frame Logic (#21)

* minor logic swap

* first attempt, has a race condition

* fixed the offset issue

* found a solution, I think things work now (at least once I quash this race condition)

* still chasing down race conditions

* add manual shear / scale order strategy swap

* tweak manual shear, fix ui uninitialization crash

* fix z height / g-code desync issue

* fix shear then scale cutoff planes

* getting closer

* fix support termination planes

* fix incorrect offsets in shear-then-scale mode

* test - fix overextrusion due to model/layer scale
This commit is contained in:
Joseph Robertson authored and GitHub committed 2026-05-18 19:01:43 -05:00
1 parent 8fa6a4602b
commit 6a2d690f45
19 files changed
+621 -46

No files matched your search

+20 -6
View File
@@ -34,6 +34,11 @@ void BeltGCodeWriter::set_belt_back_transform(const PrintConfig &config)
m_belt_back_transform.init_from_config(config);
}
void BeltGCodeWriter::set_machine_frame_transform(const PrintConfig &config)
{
m_machine_frame_transform.init_from_config(config);
}
void BeltGCodeWriter::set_origin_snap(int axis, bool enable, double offset, double bbox_min)
{
if (axis >= 0 && axis < 3) {
@@ -43,17 +48,26 @@ void BeltGCodeWriter::set_origin_snap(int axis, bool enable, double offset, doub
}
}
Vec3d BeltGCodeWriter::to_cartesian(const Vec3d &pos) const
{
// back_transform → axis_remap, no origin_snap, no machine_frame_transform.
return apply_axis_remap(m_belt_back_transform.apply(pos));
}
Vec3d BeltGCodeWriter::to_machine_coords(const Vec3d &pos) const
{
// Step 1: Undo the shear/scale applied during slicing.
Vec3d p = m_belt_back_transform.apply(pos);
// Step 2: Apply axis remap (uses inherited base class method).
Vec3d result = apply_axis_remap(p);
// Step 3: Per-axis origin snap.
// Step 1+2: To Cartesian (back_transform + axis_remap).
Vec3d result = to_cartesian(pos);
// Step 3: Per-axis origin snap (computed in the Cartesian frame).
for (int i = 0; i < 3; ++i)
if (m_origin_snap[i])
result[i] -= (m_origin_bbox_min[i] - m_origin_offset[i]);
return result;
// Step 4: Machine-frame transform (gcode_shear / gcode_scale / post_gcode_remap)
// applied LAST so it acts as a global linear transform on the placed coords.
// Order matters: putting it before origin_snap would feed sheared bbox corners
// into the snap's per-object min calculation, mis-normalizing non-cubic geometries
// (the corners of the original bbox aren't extreme points of the sheared shape).
return m_machine_frame_transform.apply(result);
}
// ---- Overridden movement methods ------------------------------------------