コード例 #1
0
  private final void iteration_h(
      Array2D windMap,
      Array2D heightMap,
      int x,
      int z,
      float dx,
      float dz,
      int xIt,
      float windDescentRate) {
    // Assume either dx or dz is 1f and the other is less.
    float z_precise = z;
    float elevation = initialElevation;

    int lastZ;

    dz /= Math.abs(dx);
    windDescentRate /= Math.abs(dx);

    iteration:
    while (true) {
      lastZ = z;

      while (z == lastZ) {
        elevation = Math.max(minWindHeight, elevation - windDescentRate);

        float height = heightMap.get(x, z);

        if (elevation < height) elevation = height;

        windMap.set(x, z, elevation - heightMap.get(x, z));

        x += xIt;
        z_precise += dz;
        z = (int) z_precise;

        if (x < 0 || x >= windMap.width || z < 0 || z >= windMap.height) break iteration;
      }
    }
  }
コード例 #2
0
  private final void iteration_v(
      Array2D windMap,
      Array2D heightMap,
      int x,
      int z,
      float dx,
      float dz,
      int zIt,
      float windDescentRate) {
    // Assume either dx or dz is 1f and the other is less.
    float x_precise = x;
    float elevation = initialElevation;

    int lastX;

    dx /= Math.abs(dz);
    windDescentRate /= Math.abs(dz);

    iteration:
    while (true) {
      lastX = x;

      while (x == lastX) {
        elevation = Math.max(minWindHeight, elevation - windDescentRate);

        float height = heightMap.get(x, z);

        if (elevation < height) elevation = height;

        windMap.set(x, z, elevation - heightMap.get(x, z));

        z += zIt;
        x_precise += dx;
        x = (int) x_precise;

        if (x < 0 || x >= windMap.width || z < 0 || z >= windMap.height) break iteration;
      }
    }
  }