ソースを参照

Apply const args, clean up find_closest_circle_to_print

Scott Lahteine 8年前
コミット
34e2420b9b
1個のファイルの変更15行の追加16行の削除
  1. 15
    16
      Marlin/G26_Mesh_Validation_Tool.cpp

+ 15
- 16
Marlin/G26_Mesh_Validation_Tool.cpp ファイルの表示

@@ -156,7 +156,7 @@
156 156
                               // won't leave us in a bad state.
157 157
 
158 158
   float valid_trig_angle(float);
159
-  mesh_index_pair find_closest_circle_to_print(float, float);
159
+  mesh_index_pair find_closest_circle_to_print(const float&, const float&);
160 160
 
161 161
   static float extrusion_multiplier = EXTRUSION_MULTIPLIER,
162 162
                retraction_multiplier = RETRACTION_MULTIPLIER,
@@ -391,8 +391,8 @@
391 391
     return d;
392 392
   }
393 393
 
394
-  mesh_index_pair find_closest_circle_to_print( float X, float Y) {
395
-    float f, mx, my, dx, dy, closest = 99999.99;
394
+  mesh_index_pair find_closest_circle_to_print(const float &X, const float &Y) {
395
+    float closest = 99999.99;
396 396
     mesh_index_pair return_val;
397 397
 
398 398
     return_val.x_index = return_val.y_index = -1;
@@ -400,28 +400,27 @@
400 400
     for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
401 401
       for (uint8_t j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
402 402
         if (!is_bit_set(circle_flags, i, j)) {
403
-          mx = ubl.mesh_index_to_xpos[i];  // We found a circle that needs to be printed
404
-          my = ubl.mesh_index_to_ypos[j];
403
+          const float mx = ubl.mesh_index_to_xpos[i],  // We found a circle that needs to be printed
404
+                      my = ubl.mesh_index_to_ypos[j];
405 405
 
406
-          dx = X - mx;        // Get the distance to this intersection
407
-          dy = Y - my;
408
-          f = HYPOT(dx, dy);
406
+          // Get the distance to this intersection
407
+          float f = HYPOT(X - mx, Y - my);
409 408
 
410
-          dx = x_pos - mx;                  // It is possible that we are being called with the values
411
-          dy = y_pos - my;                  // to let us find the closest circle to the start position.
412
-          f += HYPOT(dx, dy) / 15.0;        // But if this is not the case,
413
-                                            // we are going to add in a small
414
-                                            // weighting to the distance calculation to help it choose
415
-                                            // a better place to continue.
409
+          // It is possible that we are being called with the values
410
+          // to let us find the closest circle to the start position.
411
+          // But if this is not the case, add a small weighting to the
412
+          // distance calculation to help it choose a better place to continue.
413
+          f += HYPOT(x_pos - mx, y_pos - my) / 15.0;
416 414
 
415
+          // Add in the specified amount of Random Noise to our search
417 416
           if (random_deviation > 1.0)
418
-            f += random(0.0, random_deviation); // Add in the specified amount of Random Noise to our search
417
+            f += random(0.0, random_deviation);
419 418
 
420 419
           if (f < closest) {
421 420
             closest = f;              // We found a closer location that is still
422 421
             return_val.x_index = i;   // un-printed  --- save the data for it
423 422
             return_val.y_index = j;
424
-            return_val.distance= closest;
423
+            return_val.distance = closest;
425 424
           }
426 425
         }
427 426
       }

読み込み中…
キャンセル
保存