|
@@ -56,39 +56,32 @@
|
56
|
56
|
// A move within the same cell needs no splitting
|
57
|
57
|
if (istart == iend) {
|
58
|
58
|
|
59
|
|
- // For a move off the bed, use a constant Z raise
|
60
|
|
- if (!WITHIN(iend.x, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(iend.y, 0, GRID_MAX_POINTS_Y - 1)) {
|
|
59
|
+ FINAL_MOVE:
|
61
|
60
|
|
62
|
|
- // Note: There is no Z Correction in this case. We are off the grid and don't know what
|
63
|
|
- // a reasonable correction would be. If the user has specified a UBL_Z_RAISE_WHEN_OFF_MESH
|
64
|
|
- // value, that will be used instead of a calculated (Bi-Linear interpolation) correction.
|
|
61
|
+ // When UBL_Z_RAISE_WHEN_OFF_MESH is disabled Z correction is extrapolated from the edge of the mesh
|
|
62
|
+ #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
|
|
63
|
+ // For a move off the UBL mesh, use a constant Z raise
|
|
64
|
+ if (!cell_index_x_valid(end.x) || !cell_index_y_valid(end.y)) {
|
65
|
65
|
|
66
|
|
- #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
|
67
|
|
- end.z += UBL_Z_RAISE_WHEN_OFF_MESH;
|
68
|
|
- #endif
|
69
|
|
- planner.buffer_segment(end, scaled_fr_mm_s, extruder);
|
70
|
|
- current_position = destination;
|
71
|
|
- return;
|
72
|
|
- }
|
|
66
|
+ // Note: There is no Z Correction in this case. We are off the mesh and don't know what
|
|
67
|
+ // a reasonable correction would be, UBL_Z_RAISE_WHEN_OFF_MESH will be used instead of
|
|
68
|
+ // a calculated (Bi-Linear interpolation) correction.
|
73
|
69
|
|
74
|
|
- FINAL_MOVE:
|
|
70
|
+ end.z += UBL_Z_RAISE_WHEN_OFF_MESH;
|
|
71
|
+ planner.buffer_segment(end, scaled_fr_mm_s, extruder);
|
|
72
|
+ current_position = destination;
|
|
73
|
+ return;
|
|
74
|
+ }
|
|
75
|
+ #endif
|
75
|
76
|
|
76
|
77
|
// The distance is always MESH_X_DIST so multiply by the constant reciprocal.
|
77
|
|
- const float xratio = (end.x - mesh_index_to_xpos(iend.x)) * RECIPROCAL(MESH_X_DIST);
|
78
|
|
-
|
79
|
|
- float z1, z2;
|
80
|
|
- if (iend.x >= GRID_MAX_POINTS_X - 1)
|
81
|
|
- z1 = z2 = 0.0;
|
82
|
|
- else {
|
83
|
|
- z1 = z_values[iend.x ][iend.y ] + xratio *
|
84
|
|
- (z_values[iend.x + 1][iend.y ] - z_values[iend.x][iend.y ]),
|
85
|
|
- z2 = z_values[iend.x ][iend.y + 1] + xratio *
|
86
|
|
- (z_values[iend.x + 1][iend.y + 1] - z_values[iend.x][iend.y + 1]);
|
87
|
|
- }
|
|
78
|
+ const float xratio = (end.x - mesh_index_to_xpos(iend.x)) * RECIPROCAL(MESH_X_DIST),
|
|
79
|
+ yratio = (end.y - mesh_index_to_ypos(iend.y)) * RECIPROCAL(MESH_Y_DIST),
|
|
80
|
+ z1 = z_values[iend.x][iend.y ] + xratio * (z_values[iend.x + 1][iend.y ] - z_values[iend.x][iend.y ]),
|
|
81
|
+ z2 = z_values[iend.x][iend.y + 1] + xratio * (z_values[iend.x + 1][iend.y + 1] - z_values[iend.x][iend.y + 1]);
|
88
|
82
|
|
89
|
83
|
// X cell-fraction done. Interpolate the two Z offsets with the Y fraction for the final Z offset.
|
90
|
|
- const float yratio = (end.y - mesh_index_to_ypos(iend.y)) * RECIPROCAL(MESH_Y_DIST),
|
91
|
|
- z0 = iend.y < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end.z) : 0.0;
|
|
84
|
+ const float z0 = (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end.z);
|
92
|
85
|
|
93
|
86
|
// Undefined parts of the Mesh in z_values[][] are NAN.
|
94
|
87
|
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|