|
|
|
@ -59,6 +59,9 @@ public class Terrain {
@@ -59,6 +59,9 @@ public class Terrain {
|
|
|
|
|
this.cell_count.x = this.image_size.x; |
|
|
|
|
this.cell_count.y = this.image_size.y; |
|
|
|
|
|
|
|
|
|
this.cell_size.x = terrain_size.x / this.cell_count.x; |
|
|
|
|
this.cell_size.y = terrain_size.y / this.cell_count.y; |
|
|
|
|
|
|
|
|
|
// Blending configuration. These ratios are used to calculate
|
|
|
|
|
// the blending area between child and parent terrains when
|
|
|
|
|
// they are stitched together.
|
|
|
|
@ -157,12 +160,12 @@ public class Terrain {
@@ -157,12 +160,12 @@ public class Terrain {
|
|
|
|
|
|
|
|
|
|
// Calculate terrain cell with offset
|
|
|
|
|
|
|
|
|
|
Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_count.x, terrain_loc.y / this.cell_count.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
|
|
|
|
|
|
|
|
|
|
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)); |
|
|
|
|
terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 2, terrain_cell.x)); |
|
|
|
|
terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 2, terrain_cell.y)); |
|
|
|
|
|
|
|
|
|
return terrain_cell; |
|
|
|
|
} |
|
|
|
|