Drop intermediate nx, ny, and set destination directly

2.0.x
Scott Lahteine 9 years ago
parent 07a735ad22
commit 493d30cd97

@ -7860,18 +7860,22 @@ void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_
#define MBL_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist) #define MBL_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
float nx, ny, normalized_dist; float normalized_dist, end[NUM_AXIS];
// Split at the left/front border of the right/top square
int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2); int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
if (cx2 != cx1 && TEST(x_splits, gcx)) { if (cx2 != cx1 && TEST(x_splits, gcx)) {
nx = mbl.get_probe_x(gcx) + home_offset[X_AXIS] + position_shift[X_AXIS]; memcpy(end, destination, sizeof(end));
normalized_dist = (nx - current_position[X_AXIS]) / (destination[X_AXIS] - current_position[X_AXIS]); destination[X_AXIS] = mbl.get_probe_x(gcx) + home_offset[X_AXIS] + position_shift[X_AXIS];
ny = MBL_SEGMENT_END(Y); normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
destination[Y_AXIS] = MBL_SEGMENT_END(Y);
CBI(x_splits, gcx); CBI(x_splits, gcx);
} }
else if (cy2 != cy1 && TEST(y_splits, gcy)) { else if (cy2 != cy1 && TEST(y_splits, gcy)) {
ny = mbl.get_probe_y(gcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS]; memcpy(end, destination, sizeof(end));
normalized_dist = (ny - current_position[Y_AXIS]) / (destination[Y_AXIS] - current_position[Y_AXIS]); destination[Y_AXIS] = mbl.get_probe_y(gcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
nx = MBL_SEGMENT_END(X); normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
destination[X_AXIS] = MBL_SEGMENT_END(X);
CBI(y_splits, gcy); CBI(y_splits, gcy);
} }
else { else {
@ -7881,12 +7885,6 @@ void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_
return; return;
} }
// Save given destination for after recursion
float end[NUM_AXIS];
memcpy(end, destination, sizeof(end));
destination[X_AXIS] = nx;
destination[Y_AXIS] = ny;
destination[Z_AXIS] = MBL_SEGMENT_END(Z); destination[Z_AXIS] = MBL_SEGMENT_END(Z);
destination[E_AXIS] = MBL_SEGMENT_END(E); destination[E_AXIS] = MBL_SEGMENT_END(E);

Loading…
Cancel
Save