Browse Source

Minor DELTA segmentation speedup

Minor DELTA segmentation speedup by pulling calculations out of the loop.
AnHardt 9 years ago
parent
commit
41e9569dbc
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      Marlin/Marlin_main.cpp

+ 5
- 3
Marlin/Marlin_main.cpp View File

@@ -7314,8 +7314,10 @@ void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate,
7314 7314
     float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
7315 7315
     if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
7316 7316
     if (cartesian_mm < 0.000001) return false;
7317
-    float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
7317
+    float _feedrate = feedrate * feedrate_multiplier / 6000.0;
7318
+    float seconds = cartesian_mm / _feedrate;
7318 7319
     int steps = max(1, int(delta_segments_per_second * seconds));
7320
+    float inv_steps = 1.0/steps;
7319 7321
 
7320 7322
     // SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
7321 7323
     // SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
@@ -7323,7 +7325,7 @@ void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate,
7323 7325
 
7324 7326
     for (int s = 1; s <= steps; s++) {
7325 7327
 
7326
-      float fraction = float(s) / float(steps);
7328
+      float fraction = float(s) * inv_steps;
7327 7329
 
7328 7330
       for (int8_t i = 0; i < NUM_AXIS; i++)
7329 7331
         target[i] = current_position[i] + difference[i] * fraction;
@@ -7337,7 +7339,7 @@ void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate,
7337 7339
       //DEBUG_POS("prepare_move_delta", target);
7338 7340
       //DEBUG_POS("prepare_move_delta", delta);
7339 7341
 
7340
-      planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate / 60 * feedrate_multiplier / 100.0, active_extruder);
7342
+      planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], _feedrate, active_extruder);
7341 7343
     }
7342 7344
     return true;
7343 7345
   }

Loading…
Cancel
Save