Merge branch 'ver/6.6.0' into dev/7.0-2

This commit is contained in:
Zoe Gidiere
2024-10-12 15:42:47 -06:00
468 changed files with 931 additions and 554 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
@@ -17,6 +17,7 @@ import com.dfsek.terra.addons.manifest.api.AddonInitializer;
import com.dfsek.terra.addons.noise.config.CubicSplinePointTemplate;
import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
import com.dfsek.terra.addons.noise.config.templates.BinaryArithmeticTemplate;
import com.dfsek.terra.addons.noise.config.templates.CacheSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.DerivativeNoiseSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.DomainWarpTemplate;
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
@@ -150,6 +151,8 @@ public class NoiseAddon implements AddonInitializer {
noiseRegistry.register(addon.key("MAX"), () -> new BinaryArithmeticTemplate<>(MaxSampler::new));
noiseRegistry.register(addon.key("MIN"), () -> new BinaryArithmeticTemplate<>(MinSampler::new));
noiseRegistry.register(addon.key("CACHE"), CacheSamplerTemplate::new);
Map<String, DimensionApplicableNoiseSampler> packSamplers = new LinkedHashMap<>();
Map<String, FunctionTemplate> packFunctions = new LinkedHashMap<>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -0,0 +1,24 @@
package com.dfsek.terra.addons.noise.config.templates;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.terra.addons.noise.samplers.CacheSampler;
import com.dfsek.terra.addons.noise.samplers.LinearHeightmapSampler;
import com.dfsek.terra.api.noise.NoiseSampler;
public class CacheSamplerTemplate extends SamplerTemplate<CacheSampler> {
@Value("sampler")
@Default
private NoiseSampler sampler;
public CacheSamplerTemplate() {
}
@Override
public NoiseSampler get() {
return new CacheSampler(sampler, getDimensions());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -0,0 +1,78 @@
package com.dfsek.terra.addons.noise.samplers;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.util.cache.DoubleSeededVector2Key;
import com.dfsek.terra.api.util.cache.DoubleSeededVector3Key;
import com.dfsek.terra.api.util.generic.pair.Pair;
import com.dfsek.terra.api.util.generic.pair.Pair.Mutable;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.github.benmanes.caffeine.cache.Scheduler;
import static com.dfsek.terra.api.util.cache.CacheUtils.CACHE_EXECUTOR;
public class CacheSampler implements NoiseSampler {
private final NoiseSampler sampler;
private final ThreadLocal<Mutable<DoubleSeededVector2Key, LoadingCache<DoubleSeededVector2Key, Double>>> cache2D;
private final ThreadLocal<Mutable<DoubleSeededVector3Key, LoadingCache<DoubleSeededVector3Key, Double>>> cache3D;
public CacheSampler(NoiseSampler sampler, int dimensions) {
this.sampler = sampler;
if (dimensions == 2) {
this.cache2D = ThreadLocal.withInitial(() -> {
LoadingCache<DoubleSeededVector2Key, Double> cache = Caffeine
.newBuilder()
.executor(CACHE_EXECUTOR)
.scheduler(Scheduler.systemScheduler())
.initialCapacity(256)
.maximumSize(256)
.build(this::sampleNoise);
return Pair.of(new DoubleSeededVector2Key(0, 0, 0), cache).mutable();
});
this.cache3D = null;
} else {
this.cache3D = ThreadLocal.withInitial(() -> {
LoadingCache<DoubleSeededVector3Key, Double> cache = Caffeine
.newBuilder()
.executor(CACHE_EXECUTOR)
.scheduler(Scheduler.systemScheduler())
.initialCapacity(981504)
.maximumSize(981504)
.build(this::sampleNoise);
return Pair.of(new DoubleSeededVector3Key(0, 0, 0, 0), cache).mutable();
});
this.cache2D = null;
}
}
private Double sampleNoise(DoubleSeededVector2Key vec) {
this.cache2D.get().setLeft(new DoubleSeededVector2Key(0, 0, 0));
return this.sampler.noise(vec.seed, vec.x, vec.z);
}
private Double sampleNoise(DoubleSeededVector3Key vec) {
this.cache3D.get().setLeft(new DoubleSeededVector3Key(0, 0, 0, 0));
return this.sampler.noise(vec.seed, vec.x, vec.y, vec.z);
}
@Override
public double noise(long seed, double x, double y) {
Mutable<DoubleSeededVector2Key, LoadingCache<DoubleSeededVector2Key, Double>> cachePair = cache2D.get();
DoubleSeededVector2Key mutableKey = cachePair.getLeft();
mutableKey.set(x, y, seed);
return cachePair.getRight().get(mutableKey);
}
@Override
public double noise(long seed, double x, double y, double z) {
Mutable<DoubleSeededVector3Key, LoadingCache<DoubleSeededVector3Key, Double>> cachePair = cache3D.get();
DoubleSeededVector3Key mutableKey = cachePair.getLeft();
mutableKey.set(x, y, z, seed);
return cachePair.getRight().get(mutableKey);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
@@ -279,7 +279,8 @@ public class CellularSampler extends NoiseFunction {
if(distanceFunction == DistanceFunction.Euclidean && returnType != ReturnType.CellValue) {
distance0 = Math.sqrt(distance0);
if(returnType != ReturnType.CellValue) {
if (returnType != ReturnType.Distance) {
distance1 = Math.sqrt(distance1);
}
}
@@ -370,7 +371,8 @@ public class CellularSampler extends NoiseFunction {
if(distanceFunction == DistanceFunction.Euclidean && returnType != ReturnType.CellValue) {
distance0 = Math.sqrt(distance0);
if(returnType != ReturnType.CellValue) {
if (returnType != ReturnType.Distance) {
distance1 = Math.sqrt(distance1);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 Polyhedral Development
* Copyright (c) 2020-2024 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.