mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-18 06:22:56 +00:00
Part 2.6: Add belt floor support clipping for all support types
- Fix support clipping z-shift calculation by removing coordinate-space mismatch and sync belt_floor_z_shift with global_z_offset; fix invalidation so posSupportMaterial no longer resets slicing params - Add belt floor polygon clipping to non-organic tree support (slim/strong/hybrid) with collision surface integration in TreeSupportData, belt extension layers, and first-layer brim suppression - Add belt floor clipping to organic tree support pipeline with virtual belt raft layers, per-layer polygons in TreeModelVolumes, and post-generation layer trimming; fix pre-existing processing_last_mesh bug in calculateCollision() Fix belt floor support clipping: z-shift, invalidation, and global offset - Fix support clipping z-shift calculation by removing coordinate-space mismatch (raw_bounding_box min.z vs trafo_centered m_belt_min_z) and sync belt_floor_z_shift with global_z_offset in global shear mode - Fix invalidation so posSupportMaterial no longer resets slicing params, preventing the exact posSlice z-shift from being overwritten by the bounding-box approximation on support-only setting changes - Remove double-counting of global z_offset on support layers — support already inherits the offset from object layers during generation This Work Was Co-Authored-By Claude Opus 4.6 (1M context) <noreply@anthropic.com> UI: gray out inactive belt sub-options, rename to mesh transforms, move to Advanced Fix mesh clipping through build plate after belt shear/scale transform Generalize G-code viewer designed-view toggle for full belt transform Clip support layers to transformed belt floor plane Supports below the tilted build plate (Z = shear_factor * from_axis - min_z) are now clipped via half-plane intersection after generation. Belt floor parameters stored in SlicingParameters and populated in both update_slicing_parameters() and the static slicing_parameters() overload. Make belt G-code viewer toggle more prominent, add B keyboard shortcut - Add separator + teal "Belt Printer" header in legend panel - Append [B] hint to checkbox label - Add B key shortcut in GLCanvas3D to toggle designed/machine view - Read belt_printer_angle from loaded G-code headers to enable belt view Add per-axis global transform option for belt printer shear New belt_shear_{x,y,z}_global bool configs. When enabled, shear incorporates instance shift so objects at different bed positions get position-aware transform (Z += factor * instance_shift_on_from_axis). Fix global shear: use layer Z offset instead of mesh transform, add config invalidation - Global shear offset applied as post-slicing layer print_z adjustment instead of mesh transform (which was absorbed by min_z normalization or shifted mesh out of slice range) - Register all belt transform options in Print::invalidate_state_by_config_options to trigger posSlice re-slicing (the fallback only invalidated Print steps, not PrintObject steps — belt changes had no effect without manual re-slice) - Belt gcode remap options added to steps_gcode (gcode-export only) - Skip empty-first-layer check for belt objects with global Z offset WIP: split instances for global shear, relative Z offsets, debug logging - PrintApply: when belt global mode active, prevent instance grouping by adding unique Z perturbation to trafo — each copy becomes its own PrintObject with independent layers - PrintObjectSlice: compute global Z offset relative to minimum Y shift across all PrintObjects (lowest-Y object stays at Z=0) - Debug logging (warning level) for belt global shift values and offsets Known issues: - Cached posSlice results cause stale offsets when mixing copies with individually-added objects — need to compute min baseline outside slice() - Supports still generate to Z=0 instead of object's global Z offset Fix global shear for copied objects: disable shared-object layer optimization When belt global Z shear is active, each object needs unique layer Z values based on its bed position. The shared-object optimization was causing copies to reuse the source object's layers (and its Z offset) instead of computing their own position-based offset. started work on getting supports to work properly one step forward, one step back this version didn't quite work. Getting somewhere though about to add UI controllable tests added configuration options for supports tweak CLAUDE.md to be more aggressive for my machine. This commit should probably be pulled out before contributing upstream still chasing down some bugs moving objects between slices no longer results in improper Z-height because of caching added more data to the debug logs Z offset is getting more global again still not quite there, I think there's a fundamental logic flaw? hunting for bugs finally have a functional fix Add belt floor clipping to tree supports (organic and non-organic) - Add belt floor polygon clipping to non-organic tree support (slim/strong/hybrid) in draw_circles() and terminate nodes at the belt surface instead of the horizontal build plate - Add belt floor clipping to organic tree support pipeline with virtual belt raft layers for sub-floor branch generation, per-layer belt floor polygons in TreeModelVolumes, and post-generation layer trimming - Fix pre-existing processing_last_mesh bug in TreeModelVolumes that prevented m_anti_overhang (support blockers) from ever being applied; skip empty first layer check for belt printers Commits: current approach: make a face surface to build supports to closer! supports now terminate on shear plane, now need to get shear plane to correct Z height nearly there chasing down logic issues still committing for checkpoint, this still does not work still got logic problems... cull support clipping stashing changes for now. Going to focus on getting the global shear OFF support generation dialed first. beginning per object shear calcs Local shear transform is on correct Z offset now local shear finally works now and needs more testing global shear works now, needs thorough testing debugging non-45 degree angles debugging part 2 supports at all angles work now remove debug logging Add belt floor collision to non-organic tree support pipeline - Integrate belt floor as a collision surface in TreeSupportData so branches route around the belt naturally, replacing the explicit termination checks in drop_nodes() - Add belt extension layers below the object after draw_circles() to allow support geometry to extend to the diagonal belt surface instead of terminating at a horizontal first layer - Fix coordinate overflow in belt floor polygons (scale_(1e4) exceeds int32), skip first-layer brim expansion for belt printers, and extend empty first layer check bypass to all belt modes add debug logging, Z translate for tree supports still not seeing any cutoff surface yet adding debug options attempt #2 at trees if hit Z buildplate stop but don't set to_buildplate true getting closer tree support almost there, just need to get rid of the circles at the beginning getting closer belt / shear plane clip works, need to figure out the buidlplate plane issues more logic, added debugging logs supports now extend somewhat below Z=0 in global shear mode fix bad alloc, add 10mm below build plate fully works now shear transform + prusa tree support generation works now. pull out debug logging
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <limits>
|
||||
|
||||
#include <tbb/parallel_for.h>
|
||||
|
||||
@@ -125,7 +126,8 @@ static std::vector<VolumeSlices> slice_volumes_inner(
|
||||
ModelVolumePtrs model_volumes,
|
||||
const std::vector<PrintObjectRegions::LayerRangeRegions> &layer_ranges,
|
||||
const std::vector<float> &zs,
|
||||
const std::function<void()> &throw_on_cancel_callback)
|
||||
const std::function<void()> &throw_on_cancel_callback,
|
||||
double *out_belt_min_z = nullptr)
|
||||
{
|
||||
model_volumes_sort_by_id(model_volumes);
|
||||
|
||||
@@ -202,8 +204,32 @@ static std::vector<VolumeSlices> slice_volumes_inner(
|
||||
}
|
||||
|
||||
// Apply: scale * shear * trafo (shear first, then scale).
|
||||
if (has_shear || has_scale)
|
||||
if (has_shear || has_scale) {
|
||||
params_base.trafo = belt_scale * belt_shear * params_base.trafo;
|
||||
|
||||
// After the shear/scale transform, the mesh may clip through the
|
||||
// build plate (Z < 0). Detect this and shift the mesh up.
|
||||
Transform3d combined = params_base.trafo;
|
||||
double min_z = std::numeric_limits<double>::max();
|
||||
for (const ModelVolume *mv : model_volumes) {
|
||||
if (!mv->is_model_part()) continue;
|
||||
for (const stl_vertex &v : mv->mesh().its.vertices) {
|
||||
Vec3d pt = combined * v.cast<double>();
|
||||
min_z = std::min(min_z, pt.z());
|
||||
}
|
||||
}
|
||||
double belt_z_shift_val = (min_z < 0. && min_z != std::numeric_limits<double>::max()) ? -min_z : 0.;
|
||||
BOOST_LOG_TRIVIAL(warning) << "Belt Z-shift: min_z=" << min_z
|
||||
<< " z_shift=" << belt_z_shift_val
|
||||
<< " trafo_z=" << object_trafo.matrix()(2, 3);
|
||||
if (belt_z_shift_val > 0.) {
|
||||
Transform3d z_shift = Transform3d::Identity();
|
||||
z_shift.matrix()(2, 3) = belt_z_shift_val;
|
||||
params_base.trafo = z_shift * params_base.trafo;
|
||||
}
|
||||
if (out_belt_min_z)
|
||||
*out_belt_min_z = (min_z != std::numeric_limits<double>::max()) ? min_z : 0.;
|
||||
}
|
||||
}
|
||||
//BBS: 0.0025mm is safe enough to simplify the data to speed slicing up for high-resolution model.
|
||||
//Also has on influence on arc fitting which has default resolution 0.0125mm.
|
||||
@@ -866,6 +892,20 @@ void PrintObject::slice()
|
||||
m_layers = new_layers(this, generate_object_layers(m_slicing_params, layer_height_profile, m_config.precise_z_height.value));
|
||||
this->slice_volumes();
|
||||
m_print->throw_if_canceled();
|
||||
|
||||
// After slicing, m_belt_min_z holds the exact post-shear minimum Z
|
||||
// in trafo_centered space (which includes the ensure_on_bed Z offset).
|
||||
// The belt surface is at Z=0 in trafo_centered space; after shear it
|
||||
// becomes Z = sf*Y, and after the z-shift that keeps the mesh above
|
||||
// Z=0 it becomes Z = sf*Y + z_shift_val. So belt_floor_z_shift is
|
||||
// simply the z-shift applied, i.e. max(0, -m_belt_min_z).
|
||||
// NOTE: do NOT add raw_bounding_box().min.z() here — m_belt_min_z
|
||||
// already includes the ensure_on_bed offset, unlike the min_rz used
|
||||
// in update_slicing_parameters() which needs that compensation.
|
||||
if (std::abs(m_slicing_params.belt_floor_shear_factor) > EPSILON) {
|
||||
m_slicing_params.belt_floor_z_shift = (m_belt_min_z < 0.) ? -m_belt_min_z : 0.;
|
||||
}
|
||||
|
||||
int firstLayerReplacedBy = 0;
|
||||
|
||||
#if 0
|
||||
@@ -904,6 +944,83 @@ void PrintObject::slice()
|
||||
if (m_layers.empty())
|
||||
throw Slic3r::SlicingError(L("No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n"));
|
||||
|
||||
// Belt printer global mode: offset all layer Z values so objects at
|
||||
// different bed positions print at different heights on the tilted belt.
|
||||
// This is a post-slicing adjustment — the sliced geometry is identical
|
||||
// regardless of global mode, only the output Z coordinates change.
|
||||
{
|
||||
const auto &pcfg = this->print()->config();
|
||||
BOOST_LOG_TRIVIAL(warning) << "Belt global check: belt_printer=" << pcfg.belt_printer.value
|
||||
<< " belt_shear_z=" << int(pcfg.belt_shear_z.value)
|
||||
<< " belt_shear_z_global=" << pcfg.belt_shear_z_global.value
|
||||
<< " object=" << this->model_object()->name;
|
||||
if (pcfg.belt_printer.value) {
|
||||
auto compute_shear_factor = [](BeltShearMode mode, double angle_deg) -> double {
|
||||
double angle_rad = Geometry::deg2rad(angle_deg);
|
||||
double sin_a = std::sin(angle_rad);
|
||||
double cos_a = std::cos(angle_rad);
|
||||
switch (mode) {
|
||||
case BeltShearMode::PosCot: return (sin_a > EPSILON) ? cos_a / sin_a : 0.;
|
||||
case BeltShearMode::NegCot: return (sin_a > EPSILON) ? -cos_a / sin_a : 0.;
|
||||
case BeltShearMode::PosTan: return (cos_a > EPSILON) ? sin_a / cos_a : 0.;
|
||||
case BeltShearMode::NegTan: return (cos_a > EPSILON) ? -sin_a / cos_a : 0.;
|
||||
default: return 0.;
|
||||
}
|
||||
};
|
||||
|
||||
Point inst_shift = this->instances().empty() ? Point(0, 0)
|
||||
: this->instances().front().shift - this->center_offset();
|
||||
BOOST_LOG_TRIVIAL(warning) << "Belt global: object " << this->model_object()->name
|
||||
<< " instances=" << this->instances().size()
|
||||
<< " shift=(" << unscale<double>(inst_shift.x()) << ", " << unscale<double>(inst_shift.y()) << ")";
|
||||
double global_z_offset = 0.;
|
||||
|
||||
struct GAxis { BeltShearMode mode; double angle; int from; bool global; };
|
||||
GAxis gaxes[3] = {
|
||||
{ pcfg.belt_shear_x.value, pcfg.belt_shear_x_angle.value, int(pcfg.belt_shear_x_from.value), pcfg.belt_shear_x_global.value },
|
||||
{ pcfg.belt_shear_y.value, pcfg.belt_shear_y_angle.value, int(pcfg.belt_shear_y_from.value), pcfg.belt_shear_y_global.value },
|
||||
{ pcfg.belt_shear_z.value, pcfg.belt_shear_z_angle.value, int(pcfg.belt_shear_z_from.value), pcfg.belt_shear_z_global.value },
|
||||
};
|
||||
|
||||
// Only the Z-row shear contributes a Z offset from global mode.
|
||||
// (X/Y row shears with global would offset X/Y, not Z — not useful here.)
|
||||
// Offsets are RELATIVE: we subtract the minimum shift across all
|
||||
// PrintObjects so the lowest-positioned object stays at Z=0.
|
||||
const auto &za = gaxes[2]; // Z row
|
||||
if (za.global && za.mode != BeltShearMode::None && za.from < 2) {
|
||||
double factor = compute_shear_factor(za.mode, za.angle);
|
||||
// The Z-shift brought the mesh's lowest sheared vertex to
|
||||
// Z=0. That vertex's physical Y determines the belt contact
|
||||
// point. With trafo_z preserved (ensure_on_bed offset),
|
||||
// min_z = Y_at_contact * factor for bottom-face vertices,
|
||||
// so: z_offset = center_Y * factor + min_z.
|
||||
Point phys = inst_shift; // already has center_offset subtracted
|
||||
double center_on_axis = (za.from == 0) ? unscale<double>(phys.x()) : unscale<double>(phys.y());
|
||||
global_z_offset += center_on_axis * factor + m_belt_min_z;
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(warning) << "Belt global: z_offset=" << global_z_offset
|
||||
<< " za.global=" << za.global << " za.mode=" << int(za.mode) << " za.from=" << za.from
|
||||
<< " (relative to min across " << this->print()->objects().size() << " objects)";
|
||||
m_belt_global_z_offset = global_z_offset;
|
||||
if (std::abs(global_z_offset) > EPSILON) {
|
||||
for (Layer *layer : m_layers)
|
||||
layer->print_z += global_z_offset;
|
||||
// Keep belt floor clipping in sync with the shifted print_z
|
||||
// values — the support generator sees globally-offset object
|
||||
// layer print_z, so belt_floor_z_shift must match.
|
||||
m_slicing_params.belt_floor_z_shift += global_z_offset;
|
||||
}
|
||||
if (!m_layers.empty()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Belt global: first_layer_z=" << m_layers.front()->print_z
|
||||
<< " last_layer_z=" << m_layers.back()->print_z
|
||||
<< " num_layers=" << m_layers.size()
|
||||
<< " center_offset=(" << unscale<double>(m_center_offset.x())
|
||||
<< ", " << unscale<double>(m_center_offset.y()) << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BBS
|
||||
this->set_done(posSlice);
|
||||
}
|
||||
@@ -1208,7 +1325,8 @@ void PrintObject::slice_volumes()
|
||||
if (!slice_zs.empty()) {
|
||||
objSliceByVolume = slice_volumes_inner(
|
||||
print->config(), this->config(), this->trafo_centered(),
|
||||
this->model_object()->volumes, m_shared_regions->layer_ranges, slice_zs, throw_on_cancel_callback);
|
||||
this->model_object()->volumes, m_shared_regions->layer_ranges, slice_zs, throw_on_cancel_callback,
|
||||
&m_belt_min_z);
|
||||
}
|
||||
|
||||
//BBS: "model_part" volumes are grouded according to their connections
|
||||
|
||||
Reference in New Issue
Block a user