implement SamplerCache for drastically increased structure perf

This commit is contained in:
dfsek
2021-01-03 13:24:17 -07:00
parent fed24920f8
commit 315230af27
10 changed files with 44 additions and 27 deletions
@@ -145,8 +145,9 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
public @Nullable ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
return new BukkitChunkGeneratorWrapper(generatorMap.computeIfAbsent(worldName, name -> {
if(!registry.contains(id)) throw new IllegalArgumentException("No such config pack \"" + id + "\"");
worlds.put(worldName, registry.get(id));
return new MasterChunkGenerator(registry.get(id), this);
ConfigPack pack = registry.get(id);
worlds.put(worldName, pack);
return new MasterChunkGenerator(registry.get(id), this, pack.getSamplerCache());
}));
}
@@ -33,7 +33,7 @@ public class SpawnCommand extends WorldCommand implements DebugCommand {
int z = p.getBlockZ();
Position dummy = new Position(0, 0);
com.dfsek.terra.api.platform.world.World w = BukkitAdapter.adapt(world);
String check = new CheckFunction(getMain(), new NumericConstant(0, dummy), new NumericConstant(0, dummy), new NumericConstant(0, dummy), getMain().getWorld(w).getConfig().getCheckCache(), dummy).apply(new TerraImplementationArguments(new StructureBuffer(
String check = new CheckFunction(getMain(), new NumericConstant(0, dummy), new NumericConstant(0, dummy), new NumericConstant(0, dummy), getMain().getWorld(w).getConfig().getSamplerCache(), dummy).apply(new TerraImplementationArguments(new StructureBuffer(
new com.dfsek.terra.api.math.vector.Location(w, x, y, z)
), Rotation.NONE, new FastRandom(), 0));
@@ -5,6 +5,6 @@ dump-default: true
biome-search-resolution: 4
cache:
carver: 512
structure: 128
structure: 1024
master-disable:
caves: false
@@ -76,7 +76,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
super(biomeSource, new StructuresConfig(false));
this.pack = configPack;
this.delegate = new MasterChunkGenerator(configPack, TerraFabricPlugin.getInstance());
this.delegate = new MasterChunkGenerator(configPack, TerraFabricPlugin.getInstance(), pack.getSamplerCache());
delegate.getMain().getLogger().info("Loading world...");
this.biomeSource = biomeSource;