mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-24 03:12:07 +00:00
Merge branch 'main' into zaa
This commit is contained in:
@@ -220,7 +220,13 @@ ConflictComputeOpt ConflictChecker::find_inter_of_lines(const LineWithIDs &lines
|
||||
ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectPtrs objs,
|
||||
std::optional<const FakeWipeTower *> wtdptr) // find the first intersection point of lines in different objects
|
||||
{
|
||||
if (objs.size() <= 1 && !wtdptr) { return {}; }
|
||||
if (objs.empty() && !wtdptr) { return {}; }
|
||||
|
||||
// Orca: check if we have enough items to potentially conflict (instances count)
|
||||
size_t total_instances = 0;
|
||||
for (auto obj : objs) total_instances += obj->instances().size();
|
||||
if (total_instances <= 1 && !wtdptr) return {};
|
||||
|
||||
LinesBucketQueue conflictQueue;
|
||||
|
||||
if (wtdptr.has_value()) { // wipe tower at 0 by default
|
||||
@@ -238,8 +244,19 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP
|
||||
}
|
||||
for (PrintObject *obj : objs) {
|
||||
auto layers = getAllLayersExtrusionPathsFromObject(obj);
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.perimeters), obj, obj->instances().front().shift);
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.support), obj, obj->instances().front().shift);
|
||||
// Orca: check for collisions between all instances
|
||||
const auto& instances = obj->instances();
|
||||
for (size_t inst_idx = 0; inst_idx < instances.size(); ++inst_idx) {
|
||||
const PrintInstance& inst = instances[inst_idx];
|
||||
const bool is_last_instance = inst_idx + 1 == instances.size();
|
||||
if (is_last_instance) {
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.perimeters), &inst, inst.shift);
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.support), &inst, inst.shift);
|
||||
} else {
|
||||
conflictQueue.emplace_back_bucket(ExtrusionLayers(layers.perimeters), &inst, inst.shift);
|
||||
conflictQueue.emplace_back_bucket(ExtrusionLayers(layers.support), &inst, inst.shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<LineWithIDs> layersLines;
|
||||
@@ -272,13 +289,18 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP
|
||||
const FakeWipeTower *wtdp = wtdptr.value();
|
||||
if (ptr1 == wtdp || ptr2 == wtdp) {
|
||||
if (ptr2 == wtdp) { std::swap(ptr1, ptr2); }
|
||||
const PrintObject *obj2 = reinterpret_cast<const PrintObject *>(ptr2);
|
||||
return std::make_optional<ConflictResult>("WipeTower", obj2->model_object()->name, conflictPrintZ, nullptr, ptr2);
|
||||
// ptr1 is now wipe tower, ptr2 is PrintInstance*
|
||||
const PrintInstance *inst2 = reinterpret_cast<const PrintInstance *>(ptr2);
|
||||
const PrintObject *obj2 = inst2->print_object;
|
||||
return std::make_optional<ConflictResult>("WipeTower", obj2->model_object()->name, conflictPrintZ, nullptr, inst2);
|
||||
}
|
||||
}
|
||||
const PrintObject *obj1 = reinterpret_cast<const PrintObject *>(ptr1);
|
||||
const PrintObject *obj2 = reinterpret_cast<const PrintObject *>(ptr2);
|
||||
return std::make_optional<ConflictResult>(obj1->model_object()->name, obj2->model_object()->name, conflictPrintZ, ptr1, ptr2);
|
||||
|
||||
const PrintInstance *inst1 = reinterpret_cast<const PrintInstance *>(ptr1);
|
||||
const PrintInstance *inst2 = reinterpret_cast<const PrintInstance *>(ptr2);
|
||||
const PrintObject *obj1 = inst1->print_object;
|
||||
const PrintObject *obj2 = inst2->print_object;
|
||||
return std::make_optional<ConflictResult>(obj1->model_object()->name, obj2->model_object()->name, conflictPrintZ, inst1, inst2);
|
||||
} else
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ const std::string& FanMover::process_gcode(const std::string& gcode, bool flush)
|
||||
|
||||
if (flush) {
|
||||
while (!m_buffer.empty()) {
|
||||
m_process_output += m_buffer.front().raw + "\n";
|
||||
BufferData &front = m_buffer.front();
|
||||
m_process_output += front.raw + "\n";
|
||||
// Orca: Keep the emitted fan state in sync when flushing buffered fan commands.
|
||||
if (front.fan_speed >= 0)
|
||||
m_front_buffer_fan_speed = front.fan_speed;
|
||||
remove_from_buffer(m_buffer.begin());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5480,6 +5480,37 @@ void GCodeProcessor::process_filament_change(int id)
|
||||
void GCodeProcessor::store_move_vertex(EMoveType type, EMovePathType path_type, bool internal_only)
|
||||
{
|
||||
int filament_id = get_filament_id();
|
||||
const auto normal_mode = PrintEstimatedStatistics::ETimeMode::Normal;
|
||||
const size_t normal_mode_id = static_cast<size_t>(normal_mode);
|
||||
const float delta_x = std::abs(m_end_position[X] - m_start_position[X]);
|
||||
const float delta_y = std::abs(m_end_position[Y] - m_start_position[Y]);
|
||||
const float delta_z = std::abs(m_end_position[Z] - m_start_position[Z]);
|
||||
const float delta_e = std::abs(m_end_position[E] - m_start_position[E]);
|
||||
const bool has_x = delta_x > 0.0f;
|
||||
const bool has_y = delta_y > 0.0f;
|
||||
const bool has_z = delta_z > 0.0f;
|
||||
const bool has_e = delta_e > 0.0f;
|
||||
const float move_acceleration =
|
||||
(type == EMoveType::Travel) ? get_travel_acceleration(normal_mode) :
|
||||
((type == EMoveType::Retract || type == EMoveType::Unretract) ? get_retract_acceleration(normal_mode) :
|
||||
get_acceleration(normal_mode));
|
||||
const float junction_deviation = get_option_value(m_time_processor.machine_limits.machine_max_junction_deviation, normal_mode_id);
|
||||
const bool use_jd_jerk = (m_flavor == gcfMarlinFirmware && junction_deviation > 0.0f);
|
||||
const auto axis_jerk_for_preview = [this, normal_mode, use_jd_jerk, move_acceleration](Axis axis) {
|
||||
return use_jd_jerk ? get_axis_max_jerk_with_jd(normal_mode, axis, move_acceleration) : get_axis_max_jerk(normal_mode, axis);
|
||||
};
|
||||
const float jerk_x = axis_jerk_for_preview(X);
|
||||
const float jerk_y = axis_jerk_for_preview(Y);
|
||||
const float jerk_z = axis_jerk_for_preview(Z);
|
||||
const float jerk_e = axis_jerk_for_preview(E);
|
||||
const float move_jerk =
|
||||
(has_e && !has_x && !has_y && !has_z) ? jerk_e :
|
||||
(has_z && !has_x && !has_y) ? jerk_z :
|
||||
(has_x && has_y) ? std::min(jerk_x, jerk_y) :
|
||||
has_x ? jerk_x :
|
||||
has_y ? jerk_y :
|
||||
has_z ? jerk_z :
|
||||
std::min(jerk_x, jerk_y);
|
||||
m_last_line_id = (type == EMoveType::Color_change || type == EMoveType::Pause_Print || type == EMoveType::Custom_GCode) ?
|
||||
m_line_id + 1 :
|
||||
((type == EMoveType::Seam) ? m_last_line_id : m_line_id);
|
||||
@@ -5503,6 +5534,10 @@ void GCodeProcessor::store_move_vertex(EMoveType type, EMovePathType path_type,
|
||||
m_extruder_temps[filament_id],
|
||||
// ORCA: Add Pressure Advance visualization support
|
||||
m_pressure_advance,
|
||||
// ORCA: Add Acceleration visualization support
|
||||
move_acceleration,
|
||||
// ORCA: Add Jerk visualization support
|
||||
move_jerk,
|
||||
{ 0.0f, 0.0f }, // time
|
||||
static_cast<float>(m_layer_id), //layer_duration: set later
|
||||
std::max<unsigned int>(1, m_layer_id) - 1,
|
||||
@@ -5578,7 +5613,7 @@ float GCodeProcessor::get_axis_max_acceleration(PrintEstimatedStatistics::ETimeM
|
||||
}
|
||||
}
|
||||
|
||||
float GCodeProcessor::get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const
|
||||
float GCodeProcessor::get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis, float acceleration) const
|
||||
{
|
||||
if (axis != X && axis != Y && axis != Z && axis != E)
|
||||
return 0.0f;
|
||||
@@ -5589,12 +5624,22 @@ float GCodeProcessor::get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeM
|
||||
return 0.0f;
|
||||
|
||||
const float axis_max_acc = get_axis_max_acceleration(mode, axis);
|
||||
const float generic_acc = get_acceleration(mode);
|
||||
const float effective_acc = axis_max_acc > 0.0f ? axis_max_acc : generic_acc;
|
||||
float effective_acc = acceleration;
|
||||
if (effective_acc <= 0.0f)
|
||||
effective_acc = get_acceleration(mode);
|
||||
if (axis_max_acc > 0.0f)
|
||||
effective_acc = effective_acc > 0.0f ? std::min(effective_acc, axis_max_acc) : axis_max_acc;
|
||||
if (effective_acc <= 0.0f)
|
||||
return 0.0f;
|
||||
|
||||
return std::sqrt(jd * effective_acc * 2.5f);
|
||||
}
|
||||
|
||||
float GCodeProcessor::get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const
|
||||
{
|
||||
return get_axis_max_jerk_with_jd(mode, axis, get_acceleration(mode));
|
||||
}
|
||||
|
||||
float GCodeProcessor::get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const
|
||||
{
|
||||
const size_t id = static_cast<size_t>(mode);
|
||||
|
||||
@@ -186,6 +186,10 @@ class Print;
|
||||
float temperature{ 0.0f }; // Celsius degrees
|
||||
// ORCA: Add Pressure Advance visualization support
|
||||
float pressure_advance{ 0.0f };
|
||||
// ORCA: Add Acceleration visualization support
|
||||
float acceleration{ 0.0f }; // mm/s^2
|
||||
// ORCA: Add Jerk visualization support
|
||||
float jerk{ 0.0f }; // mm/s
|
||||
std::array<float, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> time{ 0.0f, 0.0f }; // s
|
||||
float layer_duration{ 0.0f }; // s
|
||||
unsigned int layer_id{ 0 };
|
||||
@@ -1074,6 +1078,7 @@ class Print;
|
||||
// per-nozzle machine limits (filament_map_2 / get_config_idx_for_filament).
|
||||
float get_axis_max_feedrate(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||
float get_axis_max_acceleration(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||
float get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis, float acceleration) const;
|
||||
float get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||
float get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||
Vec3f get_xyz_max_jerk(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||
|
||||
Reference in New Issue
Block a user