diff --git a/Marlin/mesh_bed_leveling.h b/Marlin/mesh_bed_leveling.h index 9aa575015..217cd6034 100644 --- a/Marlin/mesh_bed_leveling.h +++ b/Marlin/mesh_bed_leveling.h @@ -83,7 +83,11 @@ return z1 + delta_a * delta_z; } - float get_z(float x0, float y0) { + float get_z(const float &x0, const float &y0 + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + , const float &factor + #endif + ) const { int8_t cx = cell_index_x(x0), cy = cell_index_y(y0); if (cx < 0 || cy < 0) return z_offset; @@ -96,7 +100,12 @@ float z0 = calc_z0(y0, get_probe_y(cy), z1, get_probe_y(cy + 1), z2); - return z0 + z_offset; + + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + return z0 * factor + z_offset; + #else + return z0 + z_offset; + #endif } }; diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index ea9dcf284..80cfb550f 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -559,7 +559,7 @@ void Planner::check_axes_activity() { #if ENABLED(MESH_BED_LEVELING) if (mbl.active()) - lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)) * z_fade_factor; + lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly), z_fade_factor); #elif ABL_PLANAR @@ -595,7 +595,7 @@ void Planner::check_axes_activity() { if (mbl.active()) { #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); + const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]), 1.0); logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c); #else logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));