Browse Source

Class cleanup

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
9e96add299
  1. 20
      src/engine/InterestManagement/Terrain.java

20
src/engine/InterestManagement/Terrain.java

@ -19,9 +19,6 @@ import java.util.HashMap;
import static java.lang.Math.PI; import static java.lang.Math.PI;
public class Terrain { public class Terrain {
// Class variables
public static final HashMap<Integer, short[][]> _heightmap_pixel_cache = new HashMap<>(); public static final HashMap<Integer, short[][]> _heightmap_pixel_cache = new HashMap<>();
public short[][] terrain_pixel_data; public short[][] terrain_pixel_data;
public Vector2f terrain_size = new Vector2f(); public Vector2f terrain_size = new Vector2f();
@ -131,6 +128,8 @@ public class Terrain {
public Vector2f getTerrainCell(Vector2f terrain_loc) { public Vector2f getTerrainCell(Vector2f terrain_loc) {
// Calculate terrain cell with offset
Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y); Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y);
// Clamp values when standing directly on pole // Clamp values when standing directly on pole
@ -152,17 +151,12 @@ public class Terrain {
Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1); Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1);
//get 4 surrounding vertices from the pixel array. // 4 surrounding vertices from the pixel array.
float top_left_pixel;
float top_right_pixel;
float bottom_left_pixel;
float bottom_right_pixel;
top_left_pixel = terrain_pixel_data[pixel_x][pixel_y]; float top_left_pixel = terrain_pixel_data[pixel_x][pixel_y];
top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y]; float top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y];
bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1]; float bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1];
bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; float bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1];
// Interpolate between the 4 vertices // Interpolate between the 4 vertices

Loading…
Cancel
Save