示例#1
0
  public static double[] getFastNoise1D(
      Noise noise, int xSize, int samplingRate, int x, int y, int z) {
    if (samplingRate == 0) {
      throw new IllegalArgumentException("samplingRate cannot be 0");
    }
    if (xSize % samplingRate != 0) {
      throw new IllegalArgumentException("xSize % samplingRate must return 0");
    }
    double[] noiseArray = new double[xSize + 1];

    for (int xx = 0; xx <= xSize; xx += samplingRate) {
      noiseArray[xx] = noise.noise3D(xx + x, y, z);
    }

    for (int xx = 0; xx < xSize; ++xx) {
      if (xx % samplingRate != 0) {
        int nx = xx / samplingRate * samplingRate;
        noiseArray[nx] =
            Noise.linearLerp(
                xx, nx, nx + samplingRate, noiseArray[nx], noiseArray[nx + samplingRate]);
      }
    }

    return noiseArray;
  }