Browse Source

Improved clamping

combat-2
MagicBot 1 year ago
parent
commit
823061c699
  1. 9
      src/engine/InterestManagement/Terrain.java

9
src/engine/InterestManagement/Terrain.java

@ -121,13 +121,10 @@ public class Terrain {
Vector2f terrain_cell = new Vector2f(terrainLoc.x / this.cell_size.x, terrainLoc.y / this.cell_size.y); Vector2f terrain_cell = new Vector2f(terrainLoc.x / this.cell_size.x, terrainLoc.y / this.cell_size.y);
// Clamp values when standing directly on max pole // Clamp values when standing directly on pole
if (terrain_cell.x >= this.cell_count.x) terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 1, terrain_cell.x));
terrain_cell.x = terrain_cell.x - 1; terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 1, terrain_cell.y));
if (terrain_cell.y >= this.cell_count.y)
terrain_cell.y = terrain_cell.y - 1;
return terrain_cell; return terrain_cell;
} }

Loading…
Cancel
Save