diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 046f8db862..47868bb0c6 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -199,6 +199,10 @@ void plan_arc( ADJUST_DELTA(raw); planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder); oldA = delta[A_AXIS]; oldB = delta[B_AXIS]; + #elif HAS_UBL_AND_CURVES + float pos[XYZ] = { raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS] }; + planner.apply_leveling(pos); + planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], raw[E_AXIS], fr_mm_s, active_extruder); #else planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder); #endif @@ -211,6 +215,10 @@ void plan_arc( const float diff2 = HYPOT2(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB); if (diff2) planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], cart[Z_AXIS], cart[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder); + #elif HAS_UBL_AND_CURVES + float pos[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] }; + planner.apply_leveling(pos); + planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], cart[E_AXIS], fr_mm_s, active_extruder); #else planner.buffer_line_kinematic(cart, fr_mm_s, active_extruder); #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 0845dd54eb..5428d423ff 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1058,6 +1058,7 @@ #define HAS_MESH (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING)) #define PLANNER_LEVELING (OLDSCHOOL_ABL || ENABLED(MESH_BED_LEVELING) || UBL_SEGMENTED || ENABLED(SKEW_CORRECTION)) #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)) +#define HAS_UBL_AND_CURVES (ENABLED(AUTO_BED_LEVELING_UBL) && !PLANNER_LEVELING && (ENABLED(ARC_SUPPORT) || ENABLED(BEZIER_CURVE_SUPPORT))) #if ENABLED(AUTO_BED_LEVELING_UBL) #undef LCD_BED_LEVELING diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 109e745526..abbf9e4723 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1190,7 +1190,7 @@ void Planner::check_axes_activity() { } #endif -#if PLANNER_LEVELING +#if PLANNER_LEVELING || HAS_UBL_AND_CURVES /** * rx, ry, rz - Cartesian positions in mm * Leveled XYZ on completion @@ -1242,6 +1242,10 @@ void Planner::check_axes_activity() { #endif } +#endif + +#if PLANNER_LEVELING + void Planner::unapply_leveling(float raw[XYZ]) { if (leveling_active) { diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index eceb31f3a1..46950528a4 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -404,19 +404,24 @@ class Planner { #endif // SKEW_CORRECTION - #if PLANNER_LEVELING - - #define ARG_X float rx - #define ARG_Y float ry - #define ARG_Z float rz + #if PLANNER_LEVELING || HAS_UBL_AND_CURVES /** * Apply leveling to transform a cartesian position * as it will be given to the planner and steppers. */ static void apply_leveling(float &rx, float &ry, float &rz); - static void apply_leveling(float (&raw)[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); } - static void unapply_leveling(float raw[XYZ]); + FORCE_INLINE static void apply_leveling(float (&raw)[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); } + + #if PLANNER_LEVELING + + #define ARG_X float rx + #define ARG_Y float ry + #define ARG_Z float rz + + static void unapply_leveling(float raw[XYZ]); + + #endif #else diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index 14ac645bc9..4bba9850b7 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -190,7 +190,14 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS] bez_target[Z_AXIS] = interp(position[Z_AXIS], target[Z_AXIS], t); bez_target[E_AXIS] = interp(position[E_AXIS], target[E_AXIS], t); clamp_to_software_endstops(bez_target); - planner.buffer_line_kinematic(bez_target, fr_mm_s, extruder); + + #if HAS_UBL_AND_CURVES + float pos[XYZ] = { bez_target[X_AXIS], bez_target[Y_AXIS], bez_target[Z_AXIS] }; + planner.apply_leveling(pos); + planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], bez_target[E_AXIS], fr_mm_s, active_extruder); + #else + planner.buffer_line_kinematic(bez_target, fr_mm_s, extruder); + #endif } }