package common.rng;

public class PerlinGenOld {
	private final SimplexGenOld generators[];
	private final int iterations;

	public PerlinGenOld(Random random, int iters) {
		this.iterations = iters;
		this.generators = new SimplexGenOld[iters];
		
		for(int n = 0; n < iters; n++) {
			this.generators[n] = new SimplexGenOld(random);
		}
	}

	public void generate(double noise[], double xoff, double zoff, int xsize, int zsize, double xscale, double zscale, double amp) {
		double mult = 0.5D;
		xscale /= 1.5D;
		zscale /= 1.5D;
//		if(noise == null || noise.length < xsize * zsize) {
//			noise = new double[xsize * zsize];
//		}
//		else {
			for(int n = 0; n < noise.length; n++) {
				noise[n] = 0.0D;
			}
//
//		}
		double div = 1.0D;
		double scale = 1.0D;
		for(int n = 0; n < this.iterations; n++) {
			this.generators[n].generate(noise, xoff, zoff, xsize, zsize, xscale * scale, zscale * scale, 0.55000000000000004D / div);
			scale *= amp;
			div *= mult;
		}

//		return noise;
	}
}
