Ver código fonte

Merge pull request #5095 from thinkyhead/rc_fix_bilinear_math

Fix bilinear grid constraints
Scott Lahteine 8 anos atrás
pai
commit
2e3110539b
1 arquivos alterados com 9 adições e 7 exclusões
  1. 9
    7
      Marlin/Marlin_main.cpp

+ 9
- 7
Marlin/Marlin_main.cpp Ver arquivo

@@ -8310,15 +8310,17 @@ void ok_to_send() {
8310 8310
     float ratio_x = x / bilinear_grid_spacing[X_AXIS],
8311 8311
           ratio_y = y / bilinear_grid_spacing[Y_AXIS];
8312 8312
 
8313
-    // Whole unit is the grid box index
8314
-    const int gridx = constrain(floor(ratio_x), 0, ABL_GRID_POINTS_X - 2),
8315
-              gridy = constrain(floor(ratio_y), 0, ABL_GRID_POINTS_Y - 2),
8316
-              nextx = min(gridx + 1, ABL_GRID_POINTS_X - 2),
8317
-              nexty = min(gridy + 1, ABL_GRID_POINTS_Y - 2);
8313
+    // Whole units for the grid line indices. Constrained within bounds.
8314
+    const int gridx = constrain(floor(ratio_x), 0, ABL_GRID_POINTS_X - 1),
8315
+              gridy = constrain(floor(ratio_y), 0, ABL_GRID_POINTS_Y - 1),
8316
+              nextx = min(gridx + 1, ABL_GRID_POINTS_X - 1),
8317
+              nexty = min(gridy + 1, ABL_GRID_POINTS_Y - 1);
8318 8318
 
8319 8319
     // Subtract whole to get the ratio within the grid box
8320
-    ratio_x = constrain(ratio_x - gridx, 0.0, 1.0);
8321
-    ratio_y = constrain(ratio_y - gridy, 0.0, 1.0);
8320
+    ratio_x -= gridx; ratio_y -= gridy;
8321
+
8322
+    // Never less than 0.0. (Over 1.0 is fine due to previous contraints.)
8323
+    NOLESS(ratio_x, 0); NOLESS(ratio_y, 0);
8322 8324
 
8323 8325
     // Z at the box corners
8324 8326
     const float z1 = bed_level_grid[gridx][gridy],  // left-front

Carregando…
Cancelar
Salvar