forked from MagicBane/Server
Improved clamping
This commit is contained in:
@@ -121,13 +121,10 @@ public class Terrain {
|
||||
|
||||
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 = terrain_cell.x - 1;
|
||||
|
||||
if (terrain_cell.y >= this.cell_count.y)
|
||||
terrain_cell.y = terrain_cell.y - 1;
|
||||
terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 1, terrain_cell.x));
|
||||
terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 1, terrain_cell.y));
|
||||
|
||||
return terrain_cell;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user