Reduce code size of mesh_buffer_line

master
Scott Lahteine 9 years ago
parent 103d312f6d
commit 697373b071

@ -7850,44 +7850,31 @@ void mesh_buffer_line(float x, float y, float z, const float e, float fr_mm_s, c
NOMORE(pcy, MESH_NUM_Y_POINTS - 2); NOMORE(pcy, MESH_NUM_Y_POINTS - 2);
NOMORE(cx, MESH_NUM_X_POINTS - 2); NOMORE(cx, MESH_NUM_X_POINTS - 2);
NOMORE(cy, MESH_NUM_Y_POINTS - 2); NOMORE(cy, MESH_NUM_Y_POINTS - 2);
if (pcx == cx && pcy == cy) { if (pcx == cx && pcy == cy) {
// Start and end on same mesh square // Start and end on same mesh square
planner.buffer_line(x, y, z, e, fr_mm_s, extruder); planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
set_current_to_destination(); set_current_to_destination();
return; return;
} }
float nx, ny, nz, ne, normalized_dist; float nx, ny, nz, ne, normalized_dist;
if (cx > pcx && TEST(x_splits, cx)) { int8_t gcx = max(pcx, cx), gcy = max(pcy, cy);
nx = mbl.get_probe_x(cx) + home_offset[X_AXIS] + position_shift[X_AXIS]; if (cx != pcx && TEST(x_splits, gcx)) {
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]); nx = mbl.get_probe_x(gcx) + home_offset[X_AXIS] + position_shift[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, cx);
}
else if (cx < pcx && TEST(x_splits, pcx)) {
nx = mbl.get_probe_x(pcx) + home_offset[X_AXIS] + position_shift[X_AXIS];
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]); normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist; ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
nz = current_position[Z_AXIS] + (z - current_position[Z_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; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
CBI(x_splits, pcx); CBI(x_splits, gcx);
}
else if (cy > pcy && TEST(y_splits, cy)) {
ny = mbl.get_probe_y(cy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
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, cy);
} }
else if (cy < pcy && TEST(y_splits, pcy)) { else if (cy != pcy && TEST(y_splits, gcy)) {
ny = mbl.get_probe_y(pcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS]; ny = mbl.get_probe_y(gcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]); normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist; nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
nz = current_position[Z_AXIS] + (z - current_position[Z_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; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
CBI(y_splits, pcy); CBI(y_splits, gcy);
} }
else { else {
// Already split on a border // Already split on a border

Loading…
Cancel
Save