cache last noise result for rule sequences
This commit is contained in:
parent
e8a40246b4
commit
338aee76e9
1 changed files with 8 additions and 0 deletions
|
@ -13,16 +13,24 @@ public class SulphuricSurfaceNoiseCondition extends SurfaceNoiseCondition {
|
||||||
this.threshold = threshold;
|
this.threshold = threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int lastX = Integer.MIN_VALUE;
|
||||||
|
private int lastZ = Integer.MIN_VALUE;
|
||||||
|
private double lastValue = 0;
|
||||||
@Override
|
@Override
|
||||||
public boolean test(SurfaceRulesContextAccessor context) {
|
public boolean test(SurfaceRulesContextAccessor context) {
|
||||||
final int x = context.getBlockX();
|
final int x = context.getBlockX();
|
||||||
final int z = context.getBlockZ();
|
final int z = context.getBlockZ();
|
||||||
|
if (lastX==x && lastZ==z) return lastValue < threshold;
|
||||||
|
|
||||||
double value = NOISE.eval(x * 0.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + MHelper.randRange(
|
double value = NOISE.eval(x * 0.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + MHelper.randRange(
|
||||||
-0.1,
|
-0.1,
|
||||||
0.1,
|
0.1,
|
||||||
MHelper.RANDOM
|
MHelper.RANDOM
|
||||||
);
|
);
|
||||||
|
|
||||||
|
lastX=x;
|
||||||
|
lastZ=z;
|
||||||
|
lastValue=value;
|
||||||
return value < threshold;
|
return value < threshold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue