Part 2.5: Add global shear transform, support clipping, and belt UI improvements

- Implement per-object global shear transform in PrintObject with
  layer Z-offset calculation, config invalidation, and fix for
  shared-object layer optimization breaking copied objects
- Clip support layers to the transformed belt floor plane and begin
  work on tree support adaptation for sheared coordinate space
- Improve belt UI: gray out inactive sub-options, add B keyboard
  shortcut for G-code viewer design-view toggle, fix mesh clipping
  through build plate after shear/scale transform

y' = y + z·cot(α),
  while x' = x and z' = z

getting closer to customizable variant

getting closer

X/Y/Z shear initial

clean up UI

add 1/sin(a) transform, idea taken from blackbelt cura plugin

Things work now (turns out I've been using the wrong set of  transforms)
This commit is contained in:
harrierpigeon
2026-04-09 23:07:07 -05:00
parent 501aff7e53
commit 98f4d34dcb
13 changed files with 452 additions and 91 deletions
+20 -14
View File
@@ -23,26 +23,32 @@ bool GCodeWriter::full_gcode_comment = true;
void GCodeWriter::set_belt_angle(double angle_deg)
{
m_belt_angle_rad = Geometry::deg2rad(angle_deg);
m_belt_cos = std::cos(m_belt_angle_rad);
m_belt_sin = std::sin(m_belt_angle_rad);
}
void GCodeWriter::set_axis_remap(int rx, int ry, int rz)
{
m_remap_x = rx;
m_remap_y = ry;
m_remap_z = rz;
}
void GCodeWriter::set_build_volume_max(const Vec3d &max)
{
m_build_vol_max = max;
}
Vec3d GCodeWriter::to_machine_coords(const Vec3d &pos) const
{
if (!is_belt_printer())
return pos;
// Undo the slicing transform to recover machine-frame coordinates.
// Slicing applied: T(0,0,-min_z_rot) * R(-alpha, X) * original_pos
// Inverse: R(+alpha, X) * T(0,0,+min_z_rot) * slicing_pos
//
// First undo the Z-shift, then apply R(+alpha, X).
double sz = pos.z() + m_belt_z_shift; // undo T(0,0,-min_z_rot)
return Vec3d(
pos.x(),
pos.y() * m_belt_cos - sz * m_belt_sin, // R(+alpha, X)
pos.y() * m_belt_sin + sz * m_belt_cos
);
// BeltRemapAxis: 0-2 = +X/+Y/+Z, 3-5 = -X/-Y/-Z, 6-8 = Rev X/Y/Z
auto remap = [this, &pos](int r) -> double {
int axis = r % 3;
if (r < 3) return pos[axis];
if (r < 6) return -pos[axis];
return m_build_vol_max[axis] - pos[axis];
};
return { remap(m_remap_x), remap(m_remap_y), remap(m_remap_z) };
}
bool GCodeWriter::supports_separate_travel_acceleration(GCodeFlavor flavor)