mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-18 22:30:12 +00:00
Fix Interpolation
This commit is contained in:
@@ -24,6 +24,7 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisContext;
|
||||
import com.volmit.iris.IrisDataManager;
|
||||
import com.volmit.iris.IrisMetrics;
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.gen.atomics.AtomicMulticache;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
@@ -36,7 +37,6 @@ import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -57,6 +57,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
protected ChronoLatch perSecond;
|
||||
protected ChronoLatch tickLatch;
|
||||
protected ChronoLatch pushLatch;
|
||||
private AtomicCache<IrisDimension> dimCache;
|
||||
protected IrisMetrics metrics;
|
||||
protected World world;
|
||||
protected int generated;
|
||||
@@ -80,6 +81,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
initialized = false;
|
||||
failing = false;
|
||||
pregenDone = false;
|
||||
dimCache = new AtomicCache<>();
|
||||
dev = false;
|
||||
}
|
||||
|
||||
@@ -123,7 +125,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
|
||||
public IrisDimension loadDimension(String i)
|
||||
{
|
||||
return (getData() == null ? Iris.globaldata : getData()).getDimensionLoader().load(i);
|
||||
return dimCache.aquire(() -> (getData() == null ? Iris.globaldata : getData()).getDimensionLoader().load(i));
|
||||
}
|
||||
|
||||
public IrisGenerator loadGenerator(String i)
|
||||
@@ -322,8 +324,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
fastPregen = false;
|
||||
}
|
||||
|
||||
PrecisionStopwatch sx = PrecisionStopwatch.start();
|
||||
|
||||
if(failing)
|
||||
{
|
||||
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
||||
@@ -331,7 +331,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
|
||||
try
|
||||
{
|
||||
PrecisionStopwatch s = PrecisionStopwatch.start();
|
||||
RNG random = new RNG(world.getSeed());
|
||||
init(world, random.nextParallelRNG(0));
|
||||
|
||||
@@ -347,12 +346,10 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
onGenerate(random, x, z, c, biomeGrid);
|
||||
}
|
||||
|
||||
metrics.getTotal().put(s.getMilliseconds());
|
||||
generated++;
|
||||
long hits = CNG.hits;
|
||||
CNG.hits = 0;
|
||||
Iris.instance.hit(hits);
|
||||
metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds());
|
||||
setHotloadable(true);
|
||||
return c;
|
||||
}
|
||||
@@ -405,6 +402,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
public void onHotload()
|
||||
{
|
||||
hlast = M.ms();
|
||||
dimCache.reset();
|
||||
}
|
||||
|
||||
protected void fail(Throwable e)
|
||||
|
||||
@@ -27,6 +27,7 @@ public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
||||
protected static final BlockData AIR = Material.AIR.createBlockData();
|
||||
protected static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||
protected static final BlockData BEDROCK = Material.BEDROCK.createBlockData();
|
||||
protected static final BlockData WATER = Material.WATER.createBlockData();
|
||||
|
||||
public DimensionChunkGenerator(String dimensionName)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.volmit.iris.gen;
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -22,6 +23,7 @@ import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -65,6 +67,16 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random no, int x, int z, BiomeGrid biomeGrid)
|
||||
{
|
||||
PrecisionStopwatch s = PrecisionStopwatch.start();
|
||||
ChunkData c = super.generateChunkData(world, no, x, z, biomeGrid);
|
||||
s.end();
|
||||
metrics.getTotal().put(s.getMilliseconds());
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||
{
|
||||
|
||||
@@ -46,10 +46,10 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
private long lastChunkLoad = M.ms();
|
||||
private GenLayerCave glCave;
|
||||
private GenLayerCarve glCarve;
|
||||
protected GenLayerBiome glBiome;
|
||||
private RNG rockRandom;
|
||||
protected IrisLock regLock;
|
||||
private KMap<String, IrisGenerator> generators;
|
||||
protected GenLayerBiome glBiome;
|
||||
protected CNG masterFracture;
|
||||
protected ChronoLatch cwarn = new ChronoLatch(1000);
|
||||
|
||||
@@ -113,15 +113,19 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
boolean caverning = false;
|
||||
KList<Integer> cavernHeights = new KList<>();
|
||||
int lastCavernHeight = -1;
|
||||
boolean bxx = false;
|
||||
boolean biomeAssigned = false;
|
||||
int max = Math.max(height, fluidHeight);
|
||||
int biomeMax = Math.min(max + 16, 255);
|
||||
|
||||
// From Height to Bedrock
|
||||
for(int k = Math.max(height, fluidHeight); k >= 0; k--)
|
||||
for(int k = max; k >= 0; k--)
|
||||
{
|
||||
boolean cavernSurface = false;
|
||||
boolean bedrock = k == 0;
|
||||
boolean underwater = k > height && k <= fluidHeight;
|
||||
|
||||
// Bedrock
|
||||
if(k == 0)
|
||||
if(bedrock)
|
||||
{
|
||||
if(biomeMap != null)
|
||||
{
|
||||
@@ -145,6 +149,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
continue;
|
||||
}
|
||||
|
||||
// Carved Surface
|
||||
else if(carvable && caverning)
|
||||
{
|
||||
lastCavernHeight = k;
|
||||
@@ -153,16 +158,14 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
caverning = false;
|
||||
}
|
||||
|
||||
boolean underwater = k > height && k <= fluidHeight;
|
||||
|
||||
// Set Biome
|
||||
if(!bxx && biomeMap != null)
|
||||
if(!biomeAssigned && biomeMap != null)
|
||||
{
|
||||
bxx = true;
|
||||
biomeAssigned = true;
|
||||
sliver.set(k, biome.getGroundBiome(masterRandom, rz, k, rx));
|
||||
biomeMap.setBiome(x, z, biome);
|
||||
|
||||
for(int kv = Math.max(height, fluidHeight); kv < Math.min(Math.max(height, fluidHeight) + 16, 255); kv++)
|
||||
for(int kv = max; kv < biomeMax; kv++)
|
||||
{
|
||||
Biome skyBiome = biome.getSkyBiome(masterRandom, rz, kv, rx);
|
||||
sliver.set(kv, skyBiome);
|
||||
@@ -275,14 +278,14 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
for(IrisDepositGenerator k : getDimension().getDeposits())
|
||||
{
|
||||
k.generate(data, ro, this);
|
||||
k.generate(data, ro, this, x, z);
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : region.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
k.generate(data, ro, this);
|
||||
k.generate(data, ro, this, x, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +293,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
k.generate(data, ro, this);
|
||||
k.generate(data, ro, this, x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -493,9 +496,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
private double getNoiseHeight(int rx, int rz)
|
||||
{
|
||||
double wx = getZoomed(rx);
|
||||
double wz = getZoomed(rz);
|
||||
double h = getBiomeHeight(wx, wz, rx, rz);
|
||||
double h = getBiomeHeight(rx, rz);
|
||||
|
||||
return h;
|
||||
}
|
||||
@@ -670,8 +671,10 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
return generators;
|
||||
}
|
||||
|
||||
protected double getBiomeHeight(double rx, double rz, int x, int z)
|
||||
protected double getBiomeHeight(double rrx, double rrz)
|
||||
{
|
||||
double rx = rrx;
|
||||
double rz = rrz;
|
||||
double h = 0;
|
||||
|
||||
for(IrisGenerator i : getGenerators().values())
|
||||
|
||||
Reference in New Issue
Block a user