/** * Finds the closest height point to a position. Will always be left/above * that position. * * @param position * the position to check at * @param patch * the patch to get height values from * @return an index to the height position of the given block. */ protected int findClosestHeightIndex(Vector3f position, TerrainPatch patch) { int x = (int) position.x; int z = (int) position.z; if (x < 0 || x >= patch.getSize() - 1) { return -1; } if (z < 0 || z >= patch.getSize() - 1) { return -1; } return z * patch.getSize() + x; } }
/** * Finds the closest height point to a position. Will always be left/above * that position. * * @param position * the position to check at * @param patch * the patch to get height values from * @return an index to the height position of the given block. */ protected int findClosestHeightIndex(Vector3f position, TerrainPatch patch) { int x = (int) position.x; int z = (int) position.z; if (x < 0 || x >= patch.getSize() - 1) { return -1; } if (z < 0 || z >= patch.getSize() - 1) { return -1; } return z * patch.getSize() + x; } }
int s = this.getSize()-1;
int s = this.getSize()-1;