Skip to content

Commit

Permalink
Merge pull request #3164 from epatel/epatel/RCBugFix
Browse files Browse the repository at this point in the history
Fix for #3160 MESH_BED_LEVELING broke correct G1 movement in Z
  • Loading branch information
thinkyhead committed Mar 16, 2016
2 parents fc04b58 + cb0dbfa commit e8fa843
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6456,32 +6456,36 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
set_current_to_destination();
return;
}
float nx, ny, ne, normalized_dist;
float nx, ny, nz, ne, normalized_dist;
if (ix > pix && TEST(x_splits, ix)) {
nx = mbl.get_x(ix);
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
CBI(x_splits, ix);
}
else if (ix < pix && TEST(x_splits, pix)) {
nx = mbl.get_x(pix);
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
CBI(x_splits, pix);
}
else if (iy > piy && TEST(y_splits, iy)) {
ny = mbl.get_y(iy);
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
CBI(y_splits, iy);
}
else if (iy < piy && TEST(y_splits, piy)) {
ny = mbl.get_y(piy);
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
CBI(y_splits, piy);
}
Expand All @@ -6494,10 +6498,12 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
// Do the split and look for more borders
destination[X_AXIS] = nx;
destination[Y_AXIS] = ny;
destination[Z_AXIS] = nz;
destination[E_AXIS] = ne;
mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
mesh_plan_buffer_line(nx, ny, nz, ne, feed_rate, extruder, x_splits, y_splits);
destination[X_AXIS] = x;
destination[Y_AXIS] = y;
destination[Z_AXIS] = z;
destination[E_AXIS] = e;
mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
}
Expand Down

0 comments on commit e8fa843

Please sign in to comment.