mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Perf
This commit is contained in:
parent
e8addbc954
commit
9be6e12a5c
@ -11,7 +11,6 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.BoardManager;
|
||||
import com.volmit.iris.util.BoardProvider;
|
||||
import com.volmit.iris.util.BoardSettings;
|
||||
@ -99,8 +98,7 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
int x = player.getLocation().getBlockX();
|
||||
int y = player.getLocation().getBlockY();
|
||||
int z = player.getLocation().getBlockZ();
|
||||
BiomeResult er = g.sampleTrueBiome(x, y, z);
|
||||
IrisBiome b = er != null ? er.getBiome() : null;
|
||||
IrisBiome b = g.sampleTrueBiome(x, y, z);
|
||||
IrisStructureResult st = g.getStructure(x, y, z);
|
||||
|
||||
tp.put(g.getMetrics().getSpeed());
|
||||
@ -114,7 +112,7 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
v.add("&7&m------------------");
|
||||
v.add(C.GREEN + "Heightmap" + C.GRAY + ": " + (int) g.getTerrainHeight(x, z));
|
||||
|
||||
if(er != null && b != null)
|
||||
if(b != null)
|
||||
{
|
||||
v.add(C.GREEN + "Biome" + C.GRAY + ": " + b.getName());
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.volmit.iris;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.KMap;
|
||||
|
||||
public interface IrisContext
|
||||
@ -21,7 +21,7 @@ public interface IrisContext
|
||||
return contexts.get(world);
|
||||
}
|
||||
|
||||
public BiomeResult getBiome(int x, int z);
|
||||
public IrisBiome getBiome(int x, int z);
|
||||
|
||||
public IrisDimension getDimension();
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class CommandIrisEditBiome extends MortarCommand
|
||||
|
||||
try
|
||||
{
|
||||
File f = Iris.proj.getCurrentProject().sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getBiome().getLoadFile();
|
||||
File f = Iris.proj.getCurrentProject().sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getLoadFile();
|
||||
Desktop.getDesktop().open(f);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class CommandIrisGoto extends MortarCommand
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome biome = args[0].equals("this") ? g.sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockZ()).getBiome() : g.loadBiome(args[0]);
|
||||
IrisBiome biome = args[0].equals("this") ? g.sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockZ()) : g.loadBiome(args[0]);
|
||||
|
||||
if(biome == null)
|
||||
{
|
||||
@ -86,7 +86,7 @@ public class CommandIrisGoto extends MortarCommand
|
||||
|
||||
int xx = (int) (RNG.r.i(-29999970, 29999970));
|
||||
int zz = (int) (RNG.r.i(-29999970, 29999970));
|
||||
if((cave ? g.sampleCaveBiome(xx, zz) : g.sampleTrueBiome(xx, zz)).getBiome().getLoadKey().equals(biome.getLoadKey()))
|
||||
if((cave ? g.sampleCaveBiome(xx, zz) : g.sampleTrueBiome(xx, zz)).getLoadKey().equals(biome.getLoadKey()))
|
||||
{
|
||||
if(biome2 != null)
|
||||
{
|
||||
@ -95,7 +95,7 @@ public class CommandIrisGoto extends MortarCommand
|
||||
int ax = xx + RNG.r.i(-64, 32);
|
||||
int az = zz + RNG.r.i(-64, 32);
|
||||
|
||||
if((cave ? g.sampleCaveBiome(ax, az) : g.sampleTrueBiome(ax, az)).getBiome().getLoadKey().equals(biome2.getLoadKey()))
|
||||
if((cave ? g.sampleCaveBiome(ax, az) : g.sampleTrueBiome(ax, az)).getLoadKey().equals(biome2.getLoadKey()))
|
||||
{
|
||||
tries--;
|
||||
p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz));
|
||||
|
@ -13,7 +13,6 @@ import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
@ -87,7 +86,7 @@ public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
||||
return d;
|
||||
}
|
||||
|
||||
protected BiomeResult focus()
|
||||
protected IrisBiome focus()
|
||||
{
|
||||
IrisBiome biome = loadBiome(getDimension().getFocus());
|
||||
|
||||
@ -114,7 +113,7 @@ public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
return new BiomeResult(biome, 0);
|
||||
return biome;
|
||||
}
|
||||
|
||||
public double getModifiedX(int rx, int rz)
|
||||
|
@ -25,7 +25,6 @@ import com.volmit.iris.object.IrisBlockDrops;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.object.IrisEffect;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
@ -103,7 +102,7 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeResult getBiome(int x, int z)
|
||||
public IrisBiome getBiome(int x, int z)
|
||||
{
|
||||
return sampleBiome(x, z);
|
||||
}
|
||||
@ -128,7 +127,7 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
{
|
||||
Location l = i.getLocation();
|
||||
IrisRegion r = sampleRegion(l.getBlockX(), l.getBlockZ());
|
||||
IrisBiome b = sampleTrueBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ()).getBiome();
|
||||
IrisBiome b = sampleTrueBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
|
||||
for(IrisEffect j : r.getEffects())
|
||||
{
|
||||
@ -271,7 +270,7 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
int iz = (int) z;
|
||||
double height = getTerrainHeight(ix, iz);
|
||||
IrisRegion region = sampleRegion(ix, iz);
|
||||
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
|
||||
IrisBiome biome = sampleTrueBiome(ix, iz, height);
|
||||
|
||||
if(biome.getCachedColor() != null)
|
||||
{
|
||||
@ -298,7 +297,7 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
int iz = (int) z;
|
||||
double height = getTerrainHeight(ix, iz);
|
||||
IrisRegion region = sampleRegion(ix, iz);
|
||||
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
|
||||
IrisBiome biome = sampleTrueBiome(ix, iz, height);
|
||||
hb = biome;
|
||||
hr = region;
|
||||
return biome.getName() + " (" + Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in " + region.getName() + "\nY: " + (int) height);
|
||||
@ -324,8 +323,8 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
int z = e.getBlock().getZ();
|
||||
IrisDimension dim = getDimension();
|
||||
IrisRegion reg = sampleRegion(x, z);
|
||||
IrisBiome bio = sampleTrueBiome(x, z).getBiome();
|
||||
IrisBiome cbio = y < getFluidHeight() ? sampleTrueBiome(x, y, z).getBiome() : null;
|
||||
IrisBiome bio = sampleTrueBiome(x, z);
|
||||
IrisBiome cbio = y < getFluidHeight() ? sampleTrueBiome(x, y, z) : null;
|
||||
|
||||
if(cbio != null && bio.equals(cbio))
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
|
||||
getAccelerant().queue(key, () ->
|
||||
{
|
||||
IrisBiome b = sampleTrueBiome((i * 16) + 7, (j * 16) + 7).getBiome();
|
||||
IrisBiome b = sampleTrueBiome((i * 16) + 7, (j * 16) + 7);
|
||||
RNG ro = getMasterRandom().nextParallelRNG(496888 + i + j);
|
||||
int g = 1;
|
||||
|
||||
@ -262,8 +262,8 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
{
|
||||
for(int l = 0; l < k.getChecks(); l++)
|
||||
{
|
||||
IrisBiome sa = sampleTrueBiome(((i * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()), ((j * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius())).getBiome();
|
||||
IrisBiome sb = sampleTrueBiome(((i * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()), ((j * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius())).getBiome();
|
||||
IrisBiome sa = sampleTrueBiome(((i * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()), ((j * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()));
|
||||
IrisBiome sb = sampleTrueBiome(((i * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()), ((j * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()));
|
||||
|
||||
if(sa.getLoadKey().equals(sb.getLoadKey()))
|
||||
{
|
||||
@ -356,7 +356,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
int bx = (i * 16) + ro.nextInt(16);
|
||||
int bz = (j * 16) + ro.nextInt(16);
|
||||
|
||||
IrisBiome biome = sampleCaveBiome(bx, bz).getBiome();
|
||||
IrisBiome biome = sampleCaveBiome(bx, bz);
|
||||
|
||||
if(biome == null)
|
||||
{
|
||||
|
@ -25,7 +25,6 @@ import com.volmit.iris.object.IrisGenerator;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.BiomeMap;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.CaveResult;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.HeightMap;
|
||||
@ -107,8 +106,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
int height = (int) Math.round(noise);
|
||||
boolean carvable = getDimension().isCarving() && height > getDimension().getCarvingMin();
|
||||
IrisRegion region = sampleRegion(rx, rz);
|
||||
BiomeResult biomeResult = sampleTrueBiome(rx, rz, noise);
|
||||
IrisBiome biome = biomeResult.getBiome();
|
||||
IrisBiome biome = sampleTrueBiome(rx, rz, noise);
|
||||
|
||||
if(biome == null)
|
||||
{
|
||||
@ -221,7 +219,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
// Carve out biomes
|
||||
KList<CaveResult> caveResults = glCave.genCaves(rx, rz, x, z, sliver);
|
||||
IrisBiome caveBiome = glBiome.generateData(InferredType.CAVE, wx, wz, rx, rz, region).getBiome();
|
||||
IrisBiome caveBiome = glBiome.generateData(InferredType.CAVE, wx, wz, rx, rz, region);
|
||||
|
||||
// Decorate Cave Biome Height Sections
|
||||
if(caveBiome != null)
|
||||
@ -274,7 +272,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
super.onGenerate(random, x, z, data, grid);
|
||||
RNG ro = random.nextParallelRNG((x * x * x) - z);
|
||||
IrisRegion region = sampleRegion((x * 16) + 7, (z * 16) + 7);
|
||||
IrisBiome biome = sampleTrueBiome((x * 16) + 7, (z * 16) + 7).getBiome();
|
||||
IrisBiome biome = sampleTrueBiome((x * 16) + 7, (z * 16) + 7);
|
||||
|
||||
for(IrisDepositGenerator k : getDimension().getDeposits())
|
||||
{
|
||||
@ -501,7 +499,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
return h;
|
||||
}
|
||||
|
||||
public BiomeResult sampleTrueBiomeBase(int x, int z, int height)
|
||||
public IrisBiome sampleTrueBiomeBase(int x, int z, int height)
|
||||
{
|
||||
if(!getDimension().getFocus().equals(""))
|
||||
{
|
||||
@ -512,7 +510,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
double wz = getModifiedZ(x, z);
|
||||
IrisRegion region = sampleRegion(x, z);
|
||||
double sh = region.getShoreHeight(wx, wz);
|
||||
IrisBiome current = sampleBiome(x, z).getBiome();
|
||||
IrisBiome current = sampleBiome(x, z);
|
||||
|
||||
if(current.isShore() && height > sh)
|
||||
{
|
||||
@ -542,22 +540,22 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
return glBiome.generateRegionData(wx, wz, x, z, region);
|
||||
}
|
||||
|
||||
public BiomeResult sampleCaveBiome(int x, int z)
|
||||
public IrisBiome sampleCaveBiome(int x, int z)
|
||||
{
|
||||
double wx = getModifiedX(x, z);
|
||||
double wz = getModifiedZ(x, z);
|
||||
return glBiome.generateData(InferredType.CAVE, wx, wz, x, z, sampleRegion(x, z));
|
||||
}
|
||||
|
||||
public BiomeResult sampleTrueBiome(int x, int y, int z)
|
||||
public IrisBiome sampleTrueBiome(int x, int y, int z)
|
||||
{
|
||||
if(y < getTerrainHeight(x, z))
|
||||
{
|
||||
double wx = getModifiedX(x, z);
|
||||
double wz = getModifiedZ(x, z);
|
||||
BiomeResult r = glBiome.generateData(InferredType.CAVE, wx, wz, x, z, sampleRegion(x, z));
|
||||
IrisBiome r = glBiome.generateData(InferredType.CAVE, wx, wz, x, z, sampleRegion(x, z));
|
||||
|
||||
if(r.getBiome() != null)
|
||||
if(r != null)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
@ -566,7 +564,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
return sampleTrueBiome(x, z);
|
||||
}
|
||||
|
||||
public BiomeResult sampleTrueBiome(int x, int z)
|
||||
public IrisBiome sampleTrueBiome(int x, int z)
|
||||
{
|
||||
return sampleTrueBiome(x, z, getTerrainHeight(x, z));
|
||||
}
|
||||
@ -581,7 +579,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
});
|
||||
}
|
||||
|
||||
public BiomeResult sampleTrueBiome(int x, int z, double noise)
|
||||
public IrisBiome sampleTrueBiome(int x, int z, double noise)
|
||||
{
|
||||
if(!getDimension().getFocus().equals(""))
|
||||
{
|
||||
@ -595,15 +593,14 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
IrisRegion region = sampleRegion(x, z);
|
||||
int height = (int) Math.round(noise);
|
||||
double sh = region.getShoreHeight(wx, wz);
|
||||
BiomeResult res = sampleTrueBiomeBase(x, z, height);
|
||||
IrisBiome current = res.getBiome();
|
||||
IrisBiome current = sampleTrueBiomeBase(x, z, height);
|
||||
|
||||
if(current.isSea() && height > getDimension().getFluidHeight() - sh)
|
||||
{
|
||||
return glBiome.generateData(InferredType.SHORE, wx, wz, x, z, region);
|
||||
}
|
||||
|
||||
return res;
|
||||
return current;
|
||||
});
|
||||
}
|
||||
|
||||
@ -699,7 +696,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
try
|
||||
{
|
||||
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
|
||||
IrisBiome b = sampleBiome((int) xx, (int) zz);
|
||||
|
||||
for(IrisBiomeGeneratorLink i : b.getGenerators())
|
||||
{
|
||||
@ -722,7 +719,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
try
|
||||
{
|
||||
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
|
||||
IrisBiome b = sampleBiome((int) xx, (int) zz);
|
||||
|
||||
for(IrisBiomeGeneratorLink i : b.getGenerators())
|
||||
{
|
||||
@ -789,7 +786,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
public BiomeResult sampleBiome(int x, int z)
|
||||
public IrisBiome sampleBiome(int x, int z)
|
||||
{
|
||||
return getCache().getRawBiome(x, z, () ->
|
||||
{
|
||||
@ -820,13 +817,13 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
return new BiomeResult(biome, 0);
|
||||
return biome;
|
||||
}
|
||||
|
||||
double wx = getModifiedX(x, z);
|
||||
double wz = getModifiedZ(x, z);
|
||||
IrisRegion region = glBiome.getRegion(wx, wz);
|
||||
BiomeResult res = glBiome.generateRegionData(wx, wz, x, z, region);
|
||||
IrisBiome res = glBiome.generateRegionData(wx, wz, x, z, region);
|
||||
|
||||
return res;
|
||||
});
|
||||
|
@ -4,8 +4,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.KMap;
|
||||
|
||||
public class AtomicMulticache
|
||||
@ -13,9 +13,11 @@ public class AtomicMulticache
|
||||
public static boolean broken = false;
|
||||
private final AtomicInteger x;
|
||||
private final AtomicInteger z;
|
||||
private int hit = 0;
|
||||
private int miss = 0;
|
||||
private final KMap<Long, Double> height;
|
||||
private final KMap<Long, BiomeResult> biome;
|
||||
private final KMap<Long, BiomeResult> rawBiome;
|
||||
private final KMap<Long, IrisBiome> biome;
|
||||
private final KMap<Long, IrisBiome> rawBiome;
|
||||
private final KMap<Long, IrisRegion> region;
|
||||
|
||||
public AtomicMulticache()
|
||||
@ -23,8 +25,8 @@ public class AtomicMulticache
|
||||
x = new AtomicInteger(0);
|
||||
z = new AtomicInteger(0);
|
||||
height = new KMap<Long, Double>();
|
||||
biome = new KMap<Long, BiomeResult>();
|
||||
rawBiome = new KMap<Long, BiomeResult>();
|
||||
biome = new KMap<Long, IrisBiome>();
|
||||
rawBiome = new KMap<Long, IrisBiome>();
|
||||
region = new KMap<Long, IrisRegion>();
|
||||
}
|
||||
|
||||
@ -38,10 +40,38 @@ public class AtomicMulticache
|
||||
this.x.set(x);
|
||||
this.z.set(z);
|
||||
|
||||
if(!IrisSettings.get().sharedCaching || getSize() > 42000)
|
||||
if(!IrisSettings.get().sharedCaching)
|
||||
{
|
||||
drop();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(height.size() > getLimit())
|
||||
{
|
||||
height.clear();
|
||||
}
|
||||
|
||||
if(biome.size() > getLimit())
|
||||
{
|
||||
biome.clear();
|
||||
}
|
||||
|
||||
if(rawBiome.size() > getLimit())
|
||||
{
|
||||
rawBiome.clear();
|
||||
}
|
||||
|
||||
if(region.size() > getLimit())
|
||||
{
|
||||
region.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getLimit()
|
||||
{
|
||||
return 20000;
|
||||
}
|
||||
|
||||
public double getHeight(int x, int z, Supplier<Double> g)
|
||||
@ -56,10 +86,16 @@ public class AtomicMulticache
|
||||
|
||||
if(r == null)
|
||||
{
|
||||
miss++;
|
||||
r = g.get();
|
||||
height.put(pos, r);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
hit++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -70,45 +106,68 @@ public class AtomicMulticache
|
||||
|
||||
if(r == null)
|
||||
{
|
||||
miss++;
|
||||
r = g.get();
|
||||
region.put(pos, r);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g)
|
||||
{
|
||||
long pos = pos(x, z);
|
||||
BiomeResult r = biome.get(pos);
|
||||
|
||||
if(r == null)
|
||||
else
|
||||
{
|
||||
r = g.get();
|
||||
biome.put(pos, r);
|
||||
hit++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public BiomeResult getRawBiome(int x, int z, Supplier<BiomeResult> g)
|
||||
public IrisBiome getBiome(int x, int z, Supplier<IrisBiome> g)
|
||||
{
|
||||
long pos = pos(x, z);
|
||||
IrisBiome r = biome.get(pos);
|
||||
|
||||
if(r == null)
|
||||
{
|
||||
miss++;
|
||||
r = g.get();
|
||||
biome.put(pos, r);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
hit++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public IrisBiome getRawBiome(int x, int z, Supplier<IrisBiome> g)
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
long pos = pos(x, z);
|
||||
BiomeResult r = rawBiome.get(pos);
|
||||
IrisBiome r = rawBiome.get(pos);
|
||||
|
||||
if(r == null)
|
||||
{
|
||||
miss++;
|
||||
r = g.get();
|
||||
rawBiome.put(pos, r);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
hit++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public double getCacheHitRate()
|
||||
{
|
||||
return (double) hit / (double) (hit + miss);
|
||||
}
|
||||
|
||||
private long pos(int x, int z)
|
||||
{
|
||||
if(broken)
|
||||
@ -139,6 +198,8 @@ public class AtomicMulticache
|
||||
return;
|
||||
}
|
||||
|
||||
hit = 0;
|
||||
miss = 0;
|
||||
height.clear();
|
||||
region.clear();
|
||||
biome.clear();
|
||||
|
@ -3,8 +3,8 @@ package com.volmit.iris.gen.layer;
|
||||
import com.volmit.iris.gen.ContextualChunkGenerator;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.InferredType;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
@ -23,12 +23,12 @@ public class BiomeDataProvider
|
||||
generator = layer.getIris().getDimension().getBiomeStyle(type).create(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
|
||||
}
|
||||
|
||||
public BiomeResult generatePureData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
public IrisBiome generatePureData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return layer.generateBiomeData(bx, bz, regionData, getGenerator(), regionData.getBiomes(g, getType()), getType(), rawX, rawZ);
|
||||
}
|
||||
|
||||
public BiomeResult generateData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
public IrisBiome generateData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return layer.generateImpureData(rawX, rawZ, getType(), regionData, generatePureData(g, bx, bz, rawX, rawZ, regionData));
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.object.IrisRegionRidge;
|
||||
import com.volmit.iris.object.IrisRegionSpot;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
@ -55,12 +54,12 @@ public class GenLayerBiome extends GenLayer
|
||||
return regionGenerator.fitRarity(iris.getDimension().getAllRegions(iris), x, z);
|
||||
}
|
||||
|
||||
public BiomeResult generateData(double bx, double bz, int rawX, int rawZ)
|
||||
public IrisBiome generateData(double bx, double bz, int rawX, int rawZ)
|
||||
{
|
||||
return generateRegionData(bx, bz, rawX, rawZ, getRegion(bx, bz));
|
||||
}
|
||||
|
||||
public BiomeResult generateData(InferredType type, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
public IrisBiome generateData(InferredType type, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return getProvider(type).generateData(iris, bx, bz, rawX, rawZ, regionData);
|
||||
}
|
||||
@ -95,7 +94,7 @@ public class GenLayerBiome extends GenLayer
|
||||
return null;
|
||||
}
|
||||
|
||||
public BiomeResult generateRegionData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
public IrisBiome generateRegionData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return generateData(getType(bx, bz, regionData), bx, bz, rawX, rawZ, regionData);
|
||||
}
|
||||
@ -121,13 +120,13 @@ public class GenLayerBiome extends GenLayer
|
||||
return bridge;
|
||||
}
|
||||
|
||||
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CNG cell, KList<IrisBiome> biomes, InferredType inferredType, int rx, int rz)
|
||||
public IrisBiome generateBiomeData(double bx, double bz, IrisRegion regionData, CNG cell, KList<IrisBiome> biomes, InferredType inferredType, int rx, int rz)
|
||||
{
|
||||
for(IrisRegionRidge i : regionData.getRidgeBiomes())
|
||||
{
|
||||
if(i.getType().equals(inferredType) && i.isRidge(rng, rx, rz))
|
||||
{
|
||||
return new BiomeResult(iris.loadBiome(i.getBiome()).infer(i.getAs(), inferredType), 0.5);
|
||||
return iris.loadBiome(i.getBiome()).infer(i.getAs(), inferredType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,13 +134,13 @@ public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
if(i.getType().equals(inferredType) && i.isSpot(rng, rx, rz))
|
||||
{
|
||||
return new BiomeResult(iris.loadBiome(i.getBiome()).infer(i.getAs(), inferredType), 0.5);
|
||||
return iris.loadBiome(i.getBiome()).infer(i.getAs(), inferredType);
|
||||
}
|
||||
}
|
||||
|
||||
if(biomes.isEmpty())
|
||||
{
|
||||
return new BiomeResult(null, 0);
|
||||
return null;
|
||||
}
|
||||
|
||||
double x = bx / (iris.getDimension().getBiomeZoom() * regionData.getBiomeZoom(inferredType));
|
||||
@ -149,20 +148,20 @@ public class GenLayerBiome extends GenLayer
|
||||
IrisBiome biome = cell.fitRarity(biomes, x, z);
|
||||
biome.setInferredType(inferredType);
|
||||
|
||||
return implode(bx, bz, regionData, cell, new BiomeResult(biome, 1));
|
||||
return implode(bx, bz, regionData, cell, biome);
|
||||
}
|
||||
|
||||
public BiomeResult generateImpureData(int rawX, int rawZ, InferredType type, IrisRegion regionData, BiomeResult pureResult)
|
||||
public IrisBiome generateImpureData(int rawX, int rawZ, InferredType type, IrisRegion regionData, IrisBiome pureResult)
|
||||
{
|
||||
return pureResult;
|
||||
}
|
||||
|
||||
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CNG parentCell, BiomeResult parent)
|
||||
public IrisBiome implode(double bx, double bz, IrisRegion regionData, CNG parentCell, IrisBiome parent)
|
||||
{
|
||||
return implode(bx, bz, regionData, parentCell, parent, 1);
|
||||
}
|
||||
|
||||
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CNG parentCell, BiomeResult parent, int hits)
|
||||
public IrisBiome implode(double bx, double bz, IrisRegion regionData, CNG parentCell, IrisBiome parent, int hits)
|
||||
{
|
||||
if(hits > IrisSettings.get().maxBiomeChildDepth)
|
||||
{
|
||||
@ -172,15 +171,15 @@ public class GenLayerBiome extends GenLayer
|
||||
double x = bx / iris.getDimension().getBiomeZoom();
|
||||
double z = bz / iris.getDimension().getBiomeZoom();
|
||||
|
||||
if(!parent.getBiome().getRealChildren(iris).isEmpty())
|
||||
if(!parent.getRealChildren(iris).isEmpty())
|
||||
{
|
||||
CNG childCell = parent.getBiome().getChildrenGenerator(rng, 123, parent.getBiome().getChildShrinkFactor());
|
||||
KList<IrisBiome> chx = parent.getBiome().getRealChildren(iris).copy(); // TODO Cache
|
||||
chx.add(parent.getBiome());
|
||||
CNG childCell = parent.getChildrenGenerator(rng, 123, parent.getChildShrinkFactor());
|
||||
KList<IrisBiome> chx = parent.getRealChildren(iris).copy(); // TODO Cache
|
||||
chx.add(parent);
|
||||
IrisBiome biome = childCell.fitRarity(chx, x, z);
|
||||
biome.setInferredType(parent.getBiome().getInferredType());
|
||||
biome.setInferredType(parent.getInferredType());
|
||||
|
||||
return implode(bx, bz, regionData, childCell, new BiomeResult(biome, 0), hits + 1);
|
||||
return implode(bx, bz, regionData, childCell, biome, hits + 1);
|
||||
}
|
||||
|
||||
return parent;
|
||||
|
@ -95,8 +95,8 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
int rx = b.getX();
|
||||
int rz = b.getZ();
|
||||
IrisRegion region = gen.sampleRegion(rx, rz);
|
||||
IrisBiome biomeSurface = gen.sampleTrueBiome(rx, rz).getBiome();
|
||||
IrisBiome biomeUnder = gen.sampleTrueBiome(rx, b.getY(), rz).getBiome();
|
||||
IrisBiome biomeSurface = gen.sampleTrueBiome(rx, rz);
|
||||
IrisBiome biomeUnder = gen.sampleTrueBiome(rx, b.getY(), rz);
|
||||
KList<IrisLootTable> tables = new KList<IrisLootTable>();
|
||||
IrisStructureResult structure = gen.getStructure(rx, b.getY(), rz);
|
||||
double multiplier = 1D * gen.getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier();
|
||||
|
@ -40,7 +40,7 @@ public class PostSlabber extends IrisPostBlockFilter
|
||||
|
||||
if((ha == h + 1 && isSolid(x + 1, ha, z, currentPostX, currentPostZ, currentData)) || (hb == h + 1 && isSolid(x, hb, z + 1, currentPostX, currentPostZ, currentData)) || (hc == h + 1 && isSolid(x - 1, hc, z, currentPostX, currentPostZ, currentData)) || (hd == h + 1 && isSolid(x, hd, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
BlockData d = gen.sampleTrueBiome(x, z).getBiome().getSlab().get(rng, x, h, z);
|
||||
BlockData d = gen.sampleTrueBiome(x, z).getSlab().get(rng, x, h, z);
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public class PostWallPatcher extends IrisPostBlockFilter
|
||||
@Override
|
||||
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
|
||||
{
|
||||
IrisBiome biome = gen.sampleTrueBiome(x, z).getBiome();
|
||||
IrisBiome biome = gen.sampleTrueBiome(x, z);
|
||||
int h, ha, hb, hc, hd;
|
||||
|
||||
if(!biome.getWall().getPalette().isEmpty())
|
||||
@ -46,7 +46,7 @@ public class PostWallPatcher extends IrisPostBlockFilter
|
||||
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
|
||||
{
|
||||
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
|
||||
BlockData s = gen.sampleTrueBiome(x, z).getBiome().getSlab().get(rng, x, h, z);
|
||||
BlockData s = gen.sampleTrueBiome(x, z).getSlab().get(rng, x, h, z);
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user