minor performance increase

This commit is contained in:
Julian Krings 2024-12-23 23:36:25 +01:00
parent e189b2389c
commit 4a1a6b80a6
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2

View File

@ -997,7 +997,12 @@ public class IrisInterpolation {
return getNoise3D(method, x, y, z, rad, rad, rad, n);
}
public static double getNoise(InterpolationMethod method, int x, int z, double h, NoiseProvider n) {
private record Key(double x, double z) {}
public static double getNoise(InterpolationMethod method, int x, int z, double h, NoiseProvider noise) {
HashMap<Key, Double> cache = new HashMap<>(64);
NoiseProvider n = (x1, z1) -> cache.computeIfAbsent(new Key(x1, z1), k -> noise.noise(k.x, k.z));
if (method.equals(InterpolationMethod.BILINEAR)) {
return getBilinearNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.STARCAST_3)) {