New biome system

This commit is contained in:
Daniel Mills 2020-01-22 18:55:53 -05:00
parent 199a26afbc
commit 5d6348b83c
9 changed files with 115 additions and 25 deletions

View File

@ -7,6 +7,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -12,7 +12,7 @@ public class Settings
public static class PerformanceSettings
{
public PerformanceMode performanceMode = PerformanceMode.DOUBLE_CPU;
public ObjectMode objectMode = ObjectMode.NONE;
public ObjectMode objectMode = ObjectMode.PARALLAX;
public boolean fastMode = false;
public int threadPriority = Thread.MAX_PRIORITY;
public int threadCount = 4;

View File

@ -126,11 +126,19 @@ public class PackController implements IrisController
if(j.isSnowy())
{
GenObjectGroup ggx = genObjectGroups.get(k).copy("-snowy-" + j.getSnow());
ggx.applySnowFilter((int) (j.getSnow() * 4));
d.registerObject(ggx);
j.getSchematicGroups().put(ggx.getName(), j.getSchematicGroups().get(k));
j.getSchematicGroups().remove(k);
try
{
GenObjectGroup ggx = genObjectGroups.get(k).copy("-snowy-" + j.getSnow());
ggx.applySnowFilter((int) (j.getSnow() * 4));
d.registerObject(ggx);
j.getSchematicGroups().put(ggx.getName(), j.getSchematicGroups().get(k));
j.getSchematicGroups().remove(k);
}
catch(Throwable e)
{
e.printStackTrace();
}
}
}
}

View File

@ -31,7 +31,6 @@ import ninja.bytecode.iris.util.InterpolationMode;
import ninja.bytecode.iris.util.IrisInterpolation;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.ObjectMode;
import ninja.bytecode.iris.util.PolygonGenerator;
import ninja.bytecode.iris.util.SChunkVector;
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
import ninja.bytecode.shuriken.collections.GList;
@ -122,8 +121,8 @@ public class IrisGenerator extends ParallaxWorldGenerator
}
random = new Random(world.getSeed());
rTerrain = new RNG(world.getSeed());
swirl = new CNG(rTerrain.nextParallelRNG(0), 40, 1).scale(0.012);
beach = new CNG(rTerrain.nextParallelRNG(0), 6, 1).scale(0.15);
swirl = new CNG(rTerrain.nextParallelRNG(0), 40, 1).scale(0.007);
beach = new CNG(rTerrain.nextParallelRNG(0), 3, 1).scale(0.15);
glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2));
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
glSnow = new GenLayerSnow(this, world, random, rTerrain.nextParallelRNG(5));
@ -282,7 +281,46 @@ public class IrisGenerator extends ParallaxWorldGenerator
return hits;
}
PolygonGenerator pg = new PolygonGenerator(RNG.r, 2, 0.013, 1, (g) -> g);
public IrisBiome getBiome(int x, int z)
{
IrisBiome biome = glBiome.getBiome(x, z);
int height = computeHeight((int) x, (int) z, new ChunkPlan(), biome);
biome = getBiome((int) x, height, (int) z);
return biome;
}
private IrisBiome getBiome(int x, int y, int z)
{
int seaLevel = Iris.settings.gen.seaLevel;
boolean land = y >= seaLevel;
int beachHeight = land ? 1 + (int) Math.round(seaLevel + beach.noise(x, z)) : seaLevel;
boolean beach = y <= beachHeight && land;
IrisBiome biome = glBiome.getBiome(x, z);
IrisBiome realBiome = glBiome.getBiome(x, z, true);
boolean nearAquatic = glBiome.isNearAquatic(x, z);
IrisRegion region = getRegion(realBiome);
// Remove Oceans from biomes above sea level
if(land && biome.getType().equals(BiomeType.FLUID))
{
biome = realBiome;
}
// Add Beaches & Shores
if(beach && biome.getType().equals(BiomeType.LAND))
{
biome = nearAquatic ? region.getBeach() : region.getShore();
}
// // Replace biomes under sea level with lakes
if(!land && biome.getType().equals(BiomeType.LAND))
{
biome = region.getLake();
}
return biome;
}
@Override
public Biome onGenColumn(int wxxf, int wzxf, int x, int z, ChunkPlan plan, AtomicChunkData data, boolean surfaceOnly)
@ -301,19 +339,10 @@ public class IrisGenerator extends ParallaxWorldGenerator
int highest = 0;
int seaLevel = Iris.settings.gen.seaLevel;
IrisBiome biome = glBiome.getBiome(wxx, wzx);
IrisBiome realBiome = glBiome.getBiome(wxx, wzx, true);
IrisRegion region = getRegion(realBiome);
MB FLUID = biome.getFluid();
int height = computeHeight(wxx, wzx, plan, biome);
int max = Math.max(height, seaLevel);
boolean land = height >= seaLevel;
int beachHeight = land ? (int) Math.round(seaLevel + beach.noise(wx, wz)) : seaLevel;
boolean beach = height <= beachHeight + 2 && land;
biome = land && biome.getType().equals(BiomeType.FLUID) ? region.getBeach() : biome;
biome = !land && biome.getType().equals(BiomeType.LAND) ? region.getLake() : biome;
biome = beach && !land && biome.getType().equals(BiomeType.FLUID) ? region.getShore() : biome;
// biome = !beach && land && biome.getType().equals(BiomeType.FRONT) ? realBiome
// : biome;
biome = getBiome(wxx, height, wzx);
MB FLUID = biome.getFluid();
for(int i = surfaceOnly ? max > seaLevel ? max - 2 : height - 2 : 0; i < max; i++)
{

View File

@ -20,6 +20,7 @@ import ninja.bytecode.shuriken.collections.GMap;
public class WorldReactor
{
private static GList<ChronoQueue> q = new GList<>();
private final World world;
public WorldReactor(World world)
@ -29,7 +30,15 @@ public class WorldReactor
public void generateRegionNormal(Player p, boolean force, double mst, Consumer<Double> progress, Runnable done)
{
for(ChronoQueue i : WorldReactor.q)
{
i.close();
}
WorldReactor.q.clear();
ChronoQueue q = new ChronoQueue(mst, 10240);
WorldReactor.q.add(q);
FinalDouble of = new FinalDouble(0D);
FinalDouble max = new FinalDouble(0D);
GMap<SMCAVector, Double> d = new GMap<>();

View File

@ -584,7 +584,7 @@ public class GenObject
{
BlockVector mbv = highest.toBlockVector().add(new Vector(0, 1, 0)).toBlockVector();
added = true;
getSchematic().put(new SBlockVector(mbv), MB.of(Material.SNOW, RNG.r.nextInt((int) M.clip(factor, 0, 8))));
getSchematic().put(new SBlockVector(mbv), MB.of(Material.SNOW, RNG.r.nextInt((int) M.clip(factor, 1, 8))));
}
}
}

View File

@ -37,7 +37,7 @@ public class GenLayerBiome extends GenLayer
.scale(0.01), 30));
ocean = new PolygonGenerator(rng.nextParallelRNG(-11), 6, 0.005, 1, (g)->g.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2)
.scale(0.01), 150));
fuzz = new CNG(rng.nextParallelRNG(9112), 1D * 8 * Iris.settings.gen.biomeEdgeFuzzScale, 1).scale(6.5);
fuzz = new CNG(rng.nextParallelRNG(9112), 1D * 12 * Iris.settings.gen.biomeEdgeFuzzScale, 1).scale(6.5);
fracture = new CNG(rng.nextParallelRNG(28), 1D, 4).scale(0.0021 * Iris.settings.gen.biomeEdgeScrambleScale)
.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2)
.scale(0.01), 12250);
@ -89,6 +89,48 @@ public class GenLayerBiome extends GenLayer
return getBiome(wxx, wzx, false);
}
public boolean isNearAquatic(int wxx, int wzx)
{
double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;
double wz = Math.round((double) wzx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;
double xf = wx + ((fracture.noise(wx, wz) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange);
double zf = wz - ((fracture.noise(wz, wx) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange);
double x = xf - fuzz.noise(wx, wz);
double z = zf + fuzz.noise(wz, wx);
if(ocean.getIndex(x, z) == 0)
{
return true;
}
if(channel.hasBorder(3, 44, xf, zf))
{
return true;
}
if(ocean.getClosestNeighbor(x, z) > 0.2)
{
return true;
}
if(channel.getClosestNeighbor(x, z) > 0.2)
{
return true;
}
if(ocean.hasBorder(3, 7, x, z) || ocean.hasBorder(3, 3, x, z))
{
return true;
}
if(channel.hasBorder(3, 7, xf, zf) || channel.hasBorder(3, 3, xf, zf))
{
return true;
}
return false;
}
public IrisBiome getBiome(double wxx, double wzx, boolean real)
{
double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;

View File

@ -38,7 +38,7 @@ public class IrisRegion
J.attempt(() -> ocean = Iris.getController(PackController.class).getBiomeById(o.getString("ocean")));
J.attempt(() -> beach = Iris.getController(PackController.class).getBiomeById(o.getString("beach")));
J.attempt(() -> lake = Iris.getController(PackController.class).getBiomeById(o.getString("lake")));
J.attempt(() -> lakeBeach = Iris.getController(PackController.class).getBiomeById(o.getString("lakeBeach")));
J.attempt(() -> lakeBeach = Iris.getController(PackController.class).getBiomeById(o.getString("shore")));
J.attempt(() -> channel = Iris.getController(PackController.class).getBiomeById(o.getString("channel")));
});
}

View File

@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.execution.Queue;
import ninja.bytecode.shuriken.execution.ShurikenQueue;
import ninja.bytecode.shuriken.logging.L;
@ -29,7 +30,7 @@ public class ChronoQueue
public void close()
{
Bukkit.getScheduler().cancelTask(j);
J.attempt(() -> Bukkit.getScheduler().cancelTask(j));
}
public void dieSlowly()