Browse Source

Reduce find_closest_mesh_point_of_type a little

Scott Lahteine 8 years ago
parent
commit
4ec4ecff1a
1 changed files with 7 additions and 16 deletions
  1. 7
    16
      Marlin/ubl_G29.cpp

+ 7
- 16
Marlin/ubl_G29.cpp View File

1308
     mesh_index_pair out_mesh;
1308
     mesh_index_pair out_mesh;
1309
     out_mesh.x_index = out_mesh.y_index = -1;
1309
     out_mesh.x_index = out_mesh.y_index = -1;
1310
 
1310
 
1311
-    const float current_x = current_position[X_AXIS],
1312
-                current_y = current_position[Y_AXIS];
1313
-
1314
     // Get our reference position. Either the nozzle or probe location.
1311
     // Get our reference position. Either the nozzle or probe location.
1315
-    const float px = lx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1316
-                py = ly - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
1312
+    const float px = RAW_X_POSITION(lx) - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1313
+                py = RAW_Y_POSITION(ly) - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0),
1314
+                raw_x = RAW_CURRENT_POSITION(X), raw_y = RAW_CURRENT_POSITION(Y);
1317
 
1315
 
1318
     float closest = far_flag ? -99999.99 : 99999.99;
1316
     float closest = far_flag ? -99999.99 : 99999.99;
1319
 
1317
 
1327
 
1325
 
1328
           // We only get here if we found a Mesh Point of the specified type
1326
           // We only get here if we found a Mesh Point of the specified type
1329
 
1327
 
1330
-          const float rawx = pgm_read_float(&ubl.mesh_index_to_xpos[i]), // Check if we can probe this mesh location
1331
-                      rawy = pgm_read_float(&ubl.mesh_index_to_ypos[j]);
1328
+          const float mx = pgm_read_float(&ubl.mesh_index_to_xpos[i]), // Check if we can probe this mesh location
1329
+                      my = pgm_read_float(&ubl.mesh_index_to_ypos[j]);
1332
 
1330
 
1333
           // If using the probe as the reference there are some unreachable locations.
1331
           // If using the probe as the reference there are some unreachable locations.
1334
           // Also for round beds, there are grid points outside the bed that nozzle can't reach.
1332
           // Also for round beds, there are grid points outside the bed that nozzle can't reach.
1335
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
1333
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
1336
 
1334
 
1337
-          bool reachable = probe_as_reference ?
1338
-                             position_is_reachable_by_probe_raw_xy( rawx, rawy ) :
1339
-                             position_is_reachable_raw_xy( rawx, rawy );
1340
-
1341
-          if ( ! reachable )
1335
+          if ((probe_as_reference && position_is_reachable_by_probe_raw_xy(mx, my)) || position_is_reachable_raw_xy(mx, my))
1342
             continue;
1336
             continue;
1343
 
1337
 
1344
           // Reachable. Check if it's the closest location to the nozzle.
1338
           // Reachable. Check if it's the closest location to the nozzle.
1345
           // Add in a weighting factor that considers the current location of the nozzle.
1339
           // Add in a weighting factor that considers the current location of the nozzle.
1346
 
1340
 
1347
-          const float mx = LOGICAL_X_POSITION(rawx), // Check if we can probe this mesh location
1348
-                      my = LOGICAL_Y_POSITION(rawy);
1349
-
1350
-          float distance = HYPOT(px - mx, py - my) + HYPOT(current_x - mx, current_y - my) * 0.1;
1341
+          float distance = HYPOT(px - mx, py - my) + HYPOT(raw_x - mx, raw_y - my) * 0.1;
1351
 
1342
 
1352
           /**
1343
           /**
1353
            * If doing the far_flag action, we want to be as far as possible
1344
            * If doing the far_flag action, we want to be as far as possible

Loading…
Cancel
Save