Merge pull request #14 from cyberpwnn/Blink

Blink
This commit is contained in:
Dan 2020-08-17 20:25:37 -04:00 committed by GitHub
commit 1d8691fed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 557 additions and 694 deletions

View File

@ -1,8 +1,8 @@
package com.volmit.iris.command; package com.volmit.iris.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.NoiseView;
import com.volmit.iris.gen.IrisChunkGenerator; import com.volmit.iris.gen.IrisChunkGenerator;
import com.volmit.iris.gui.NoiseView;
import com.volmit.iris.util.MortarCommand; import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender; import com.volmit.iris.util.MortarSender;

View File

@ -0,0 +1,55 @@
package com.volmit.iris.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.IrisChunkGenerator;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
public class CommandIrisTC extends MortarCommand
{
public CommandIrisTC()
{
super("ctc");
setDescription("Change generator thread count");
requiresPermission(Iris.perm.studio);
setCategory("World");
}
@Override
public boolean handle(MortarSender sender, String[] args)
{
if(sender.isPlayer())
{
Player p = sender.player();
World world = p.getWorld();
if(!(world.getGenerator() instanceof IrisChunkGenerator))
{
sender.sendMessage("You must be in an iris world.");
return true;
}
IrisChunkGenerator g = (IrisChunkGenerator) world.getGenerator();
int m = Math.min(Math.max(Integer.valueOf(args[0]), 2), 256);
g.changeThreadCount(m);
sender.sendMessage("Thread count changed to " + m);
return true;
}
else
{
sender.sendMessage("Players only.");
}
return true;
}
@Override
protected String getArgsUsage()
{
return "[thread-count]";
}
}

View File

@ -22,6 +22,9 @@ public class CommandIrisWorld extends MortarCommand
@Command @Command
private CommandIrisHotload hotload; private CommandIrisHotload hotload;
@Command
private CommandIrisTC tc;
public CommandIrisWorld() public CommandIrisWorld()
{ {
super("world", "wrld", "w"); super("world", "wrld", "w");

View File

@ -1,242 +0,0 @@
package com.volmit.iris.gen;
import org.bukkit.World;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.layer.GenLayerBiome;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomeGeneratorLink;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisGenerator;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.util.BiomeResult;
import com.volmit.iris.util.ChronoLatch;
import com.volmit.iris.util.IrisInterpolation;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
{
protected IrisLock regLock;
private KMap<String, IrisGenerator> generators;
private KMap<String, IrisGenerator> ceilingGenerators;
protected GenLayerBiome glBiome;
protected CNG masterFracture;
protected ChronoLatch cwarn = new ChronoLatch(1000);
public BiomeChunkGenerator(String dimensionName)
{
super(dimensionName);
generators = new KMap<>();
ceilingGenerators = new KMap<>();
regLock = new IrisLock("BiomeChunkGenerator");
}
public void onInit(World world, RNG rng)
{
super.onInit(world, rng);
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
masterFracture = CNG.signature(rng.nextParallelRNG(13)).scale(0.12);
}
@Override
public void onHotload()
{
super.onHotload();
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
}
public void registerGenerator(IrisGenerator g, IrisDimension dim)
{
KMap<String, IrisGenerator> generators = dim.isInverted() ? ceilingGenerators : this.generators;
regLock.lock();
if(g.getLoadKey() == null || generators.containsKey(g.getLoadKey()))
{
regLock.unlock();
return;
}
regLock.unlock();
generators.put(g.getLoadKey(), g);
}
protected KMap<String, IrisGenerator> getGenerators()
{
return getDimension().isInverted() ? ceilingGenerators : generators;
}
protected double getBiomeHeight(double rx, double rz, int x, int z)
{
double h = 0;
for(IrisGenerator i : getGenerators().values())
{
h += interpolateGenerator(rx, rz, i);
}
return h;
}
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen)
{
double hi = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for(IrisBiomeGeneratorLink i : b.getGenerators())
{
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMax();
}
}
}
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample hi biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
}
return 0;
});
double lo = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for(IrisBiomeGeneratorLink i : b.getGenerators())
{
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMin();
}
}
}
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample lo biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
}
return 0;
});
return M.lerp(lo, hi, gen.getHeight(rx, rz, world.getSeed() + 239945));
}
protected void loadGenerators()
{
generators.clear();
ceilingGenerators.clear();
loadGenerators(((CeilingChunkGenerator) this).getFloorDimension());
loadGenerators(((CeilingChunkGenerator) this).getCeilingDimension());
}
protected void loadGenerators(IrisDimension dim)
{
if(dim == null)
{
return;
}
KList<String> touch = new KList<>();
KList<String> loadQueue = new KList<>();
for(String i : dim.getRegions())
{
IrisRegion r = loadRegion(i);
if(r != null)
{
loadQueue.addAll(r.getLandBiomes());
loadQueue.addAll(r.getSeaBiomes());
loadQueue.addAll(r.getShoreBiomes());
loadQueue.addAll(r.getRidgeBiomeKeys());
loadQueue.addAll(r.getSpotBiomeKeys());
}
}
while(!loadQueue.isEmpty())
{
String next = loadQueue.pop();
if(!touch.contains(next))
{
touch.add(next);
IrisBiome biome = loadBiome(next);
biome.getGenerators().forEach((i) -> registerGenerator(i.getCachedGenerator(this), dim));
loadQueue.addAll(biome.getChildren());
}
}
}
public IrisRegion sampleRegion(int x, int z)
{
double wx = getModifiedX(x, z);
double wz = getModifiedZ(x, z);
return glBiome.getRegion(wx, wz);
}
public BiomeResult sampleBiome(int x, int z)
{
return getCache().getRawBiome(x, z, () ->
{
if(!getDimension().getFocus().equals(""))
{
IrisBiome biome = loadBiome(getDimension().getFocus());
for(String i : getDimension().getRegions())
{
IrisRegion reg = loadRegion(i);
if(reg.getLandBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.LAND);
break;
}
if(reg.getSeaBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.SEA);
break;
}
if(reg.getShoreBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.SHORE);
break;
}
}
return new BiomeResult(biome, 0);
}
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);
return res;
});
}
}

View File

@ -1,154 +0,0 @@
package com.volmit.iris.gen;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.util.InvertedBiomeGrid;
import com.volmit.iris.util.RNG;
public abstract class CeilingChunkGenerator extends PostBlockChunkGenerator
{
protected boolean generatingCeiling = false;
protected boolean ceilingCached = false;
protected IrisDimension cacheCeiling = null;
protected IrisDimension cacheFloor = null;
public CeilingChunkGenerator(String dimensionName, int threads)
{
super(dimensionName, threads);
}
@Override
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
{
targetFloor();
generate(random, x, z, data, grid);
if(getFloorDimension().isMirrorCeiling())
{
writeInverted(copy(data), data);
}
else if(getCeilingDimension() != null)
{
ChunkData ceiling = createChunkData(world);
InvertedBiomeGrid ceilingGrid = new InvertedBiomeGrid(grid);
targetCeiling();
generate(random, x, z, ceiling, ceilingGrid);
writeInverted(ceiling, data);
}
}
@Override
public void onHotload()
{
super.onHotload();
ceilingCached = false;
cacheCeiling = null;
cacheFloor = null;
getCache().targetChunk(0, 0);
}
private void targetFloor()
{
generatingCeiling = false;
}
private void targetCeiling()
{
generatingCeiling = true;
}
private void generate(RNG random, int x, int z, ChunkData ceiling, BiomeGrid grid)
{
super.onGenerate(random, x, z, ceiling, grid);
}
@Override
public IrisDimension getDimension()
{
return generatingCeiling ? getCeilingDimension() : getFloorDimension();
}
public IrisDimension getFloorDimension()
{
if(cacheFloor != null)
{
return cacheFloor;
}
return cacheFloor = super.getDimension();
}
public IrisDimension getCeilingDimension()
{
if(ceilingCached)
{
return cacheCeiling;
}
if(getFloorDimension().getCeiling().isEmpty())
{
return null;
}
IrisDimension c = loadDimension(getFloorDimension().getCeiling());
if(c != null)
{
c.setInverted(true);
}
ceilingCached = true;
cacheCeiling = c;
return c;
}
public void writeInverted(ChunkData data, ChunkData into)
{
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < data.getMaxHeight(); j++)
{
for(int k = 0; k < 16; k++)
{
BlockData b = data.getBlockData(i, j, k);
if(b == null || b.getMaterial().equals(Material.AIR))
{
continue;
}
into.setBlock(i, data.getMaxHeight() - j, k, b);
}
}
}
}
public ChunkData copy(ChunkData d)
{
ChunkData copy = createChunkData(world);
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < d.getMaxHeight(); j++)
{
for(int k = 0; k < 16; k++)
{
BlockData b = d.getBlockData(i, j, k);
if(b == null || b.getMaterial().equals(Material.AIR))
{
continue;
}
copy.setBlock(i, j, k, b);
}
}
}
return copy;
}
}

View File

@ -34,7 +34,6 @@ import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.object.IrisStructure; import com.volmit.iris.object.IrisStructure;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
import com.volmit.iris.util.ChronoLatch; import com.volmit.iris.util.ChronoLatch;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.J; import com.volmit.iris.util.J;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import com.volmit.iris.util.PrecisionStopwatch; import com.volmit.iris.util.PrecisionStopwatch;
@ -59,7 +58,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
protected ChronoLatch tickLatch; protected ChronoLatch tickLatch;
protected ChronoLatch pushLatch; protected ChronoLatch pushLatch;
protected IrisMetrics metrics; protected IrisMetrics metrics;
protected IrisLock hlock;
protected World world; protected World world;
protected int generated; protected int generated;
protected int ticks; protected int ticks;
@ -74,7 +72,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
tickLatch = new ChronoLatch(650); tickLatch = new ChronoLatch(650);
perSecond = new ChronoLatch(1000); perSecond = new ChronoLatch(1000);
hlast = M.ms(); hlast = M.ms();
hlock = new IrisLock("HotLock");
cache = new AtomicMulticache(); cache = new AtomicMulticache();
CNG.creates = 0; CNG.creates = 0;
generated = 0; generated = 0;
@ -318,7 +315,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
@Override @Override
public ChunkData generateChunkData(World world, Random no, int x, int z, BiomeGrid biomeGrid) public ChunkData generateChunkData(World world, Random no, int x, int z, BiomeGrid biomeGrid)
{ {
hlock.lock();
setHotloadable(false); setHotloadable(false);
if(!dev) if(!dev)
{ {
@ -330,7 +326,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
if(failing) if(failing)
{ {
hlock.unlock();
return generateChunkDataFailure(world, no, x, z, biomeGrid); return generateChunkDataFailure(world, no, x, z, biomeGrid);
} }
@ -359,7 +354,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
Iris.instance.hit(hits); Iris.instance.hit(hits);
metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds()); metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds());
setHotloadable(true); setHotloadable(true);
hlock.unlock();
return c; return c;
} }
@ -369,7 +363,6 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
} }
setHotloadable(true); setHotloadable(true);
hlock.unlock();
return generateChunkDataFailure(world, no, x, z, biomeGrid); return generateChunkDataFailure(world, no, x, z, biomeGrid);
} }
@ -380,12 +373,10 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
return; return;
} }
hlock.lock();
if(world != null) if(world != null)
{ {
checkHotload(world); checkHotload(world);
} }
hlock.unlock();
} }
private void checkHotload(World world) private void checkHotload(World world)

View File

@ -21,7 +21,6 @@ import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.util.BiomeResult; import com.volmit.iris.util.BiomeResult;
import com.volmit.iris.util.Form; import com.volmit.iris.util.Form;
import com.volmit.iris.util.Function2; import com.volmit.iris.util.Function2;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KMap; import com.volmit.iris.util.KMap;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@ -30,10 +29,9 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisContext
{ {
private Method initLighting; private Method initLighting;
private IrisLock lock;
private IrisBiome hb = null; private IrisBiome hb = null;
private IrisRegion hr = null; private IrisRegion hr = null;
private KMap<Player, IrisBiome> b = new KMap<>(); private KMap<Player, IrisBiome> b = new KMap<>();
@ -41,19 +39,16 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
public IrisChunkGenerator(String dimensionName, int threads) public IrisChunkGenerator(String dimensionName, int threads)
{ {
super(dimensionName, threads); super(dimensionName, threads);
lock = new IrisLock("IrisChunkGenerator");
} }
public IrisChunkGenerator(String dimensionName) public IrisChunkGenerator(String dimensionName)
{ {
super(dimensionName, 16); super(dimensionName, 16);
lock = new IrisLock("IrisChunkGenerator");
} }
public IrisChunkGenerator(int tc) public IrisChunkGenerator(int tc)
{ {
super("", tc); super("", tc);
lock = new IrisLock("IrisChunkGenerator");
} }
public void hotload() public void hotload()
@ -73,9 +68,7 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
@Override @Override
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
{ {
lock.lock();
super.onGenerate(random, x, z, data, grid); super.onGenerate(random, x, z, data, grid);
lock.unlock();
} }
public void onInit(World world, RNG rng) public void onInit(World world, RNG rng)
@ -139,11 +132,8 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
try try
{ {
parallaxMap.saveAll(); parallaxMap.saveAll();
ceilingParallaxMap.saveAll();
parallaxMap.getLoadedChunks().clear(); parallaxMap.getLoadedChunks().clear();
parallaxMap.getLoadedRegions().clear(); parallaxMap.getLoadedRegions().clear();
ceilingParallaxMap.getLoadedChunks().clear();
ceilingParallaxMap.getLoadedRegions().clear();
} }
catch(IOException e) catch(IOException e)
@ -152,7 +142,6 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
} }
setAvailableFilters(null); setAvailableFilters(null);
setCeilingSliverCache(null);
setSliverCache(null); setSliverCache(null);
Iris.info("Closing Iris Dimension " + getWorld().getName()); Iris.info("Closing Iris Dimension " + getWorld().getName());
} }
@ -217,14 +206,8 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
bytes += i.guessMemoryUsage(); bytes += i.guessMemoryUsage();
} }
for(AtomicRegionData i : ceilingParallaxMap.getLoadedRegions().values())
{
bytes += i.guessMemoryUsage();
}
bytes += getCache().getSize() * 65; bytes += getCache().getSize() * 65;
bytes += parallaxMap.getLoadedChunks().size() * 256 * 4 * 460; bytes += parallaxMap.getLoadedChunks().size() * 256 * 4 * 460;
bytes += ceilingParallaxMap.getLoadedChunks().size() * 256 * 4 * 460;
bytes += getSliverBuffer() * 220; bytes += getSliverBuffer() * 220;
bytes += 823 * getData().getObjectLoader().getTotalStorage(); bytes += 823 * getData().getObjectLoader().getTotalStorage();

View File

@ -37,8 +37,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
{ {
protected KMap<ChunkPosition, AtomicSliver> sliverCache; protected KMap<ChunkPosition, AtomicSliver> sliverCache;
protected AtomicWorldData parallaxMap; protected AtomicWorldData parallaxMap;
protected KMap<ChunkPosition, AtomicSliver> ceilingSliverCache;
protected AtomicWorldData ceilingParallaxMap;
private MasterLock masterLock; private MasterLock masterLock;
private IrisLock lock = new IrisLock("ParallaxLock"); private IrisLock lock = new IrisLock("ParallaxLock");
private IrisLock lockq = new IrisLock("ParallaxQueueLock"); private IrisLock lockq = new IrisLock("ParallaxQueueLock");
@ -48,7 +46,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
{ {
super(dimensionName, threads); super(dimensionName, threads);
sliverCache = new KMap<>(); sliverCache = new KMap<>();
ceilingSliverCache = new KMap<>();
sliverBuffer = 0; sliverBuffer = 0;
masterLock = new MasterLock(); masterLock = new MasterLock();
} }
@ -57,12 +54,11 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
{ {
super.onInit(world, rng); super.onInit(world, rng);
parallaxMap = new AtomicWorldData(world, "floor"); parallaxMap = new AtomicWorldData(world, "floor");
ceilingParallaxMap = new AtomicWorldData(world, "ceiling");
} }
protected KMap<ChunkPosition, AtomicSliver> getSliverCache() protected KMap<ChunkPosition, AtomicSliver> getSliverCache()
{ {
return getDimension().isInverted() ? ceilingSliverCache : sliverCache; return sliverCache;
} }
protected void onClose() protected void onClose()
@ -72,7 +68,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
try try
{ {
parallaxMap.unloadAll(true); parallaxMap.unloadAll(true);
ceilingParallaxMap.unloadAll(true);
} }
catch(IOException e) catch(IOException e)
@ -150,7 +145,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
public AtomicWorldData getParallaxMap() public AtomicWorldData getParallaxMap()
{ {
return getDimension().isInverted() ? ceilingParallaxMap : parallaxMap; return parallaxMap;
} }
public AtomicSliverMap getParallaxChunk(int x, int z) public AtomicSliverMap getParallaxChunk(int x, int z)

View File

@ -8,7 +8,6 @@ import com.volmit.iris.gen.atomics.AtomicSliverMap;
import com.volmit.iris.util.BiomeMap; import com.volmit.iris.util.BiomeMap;
import com.volmit.iris.util.GroupedExecutor; import com.volmit.iris.util.GroupedExecutor;
import com.volmit.iris.util.HeightMap; import com.volmit.iris.util.HeightMap;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.PrecisionStopwatch; import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@ -17,13 +16,12 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public abstract class ParallelChunkGenerator extends BiomeChunkGenerator public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
{ {
private GroupedExecutor accelerant; private GroupedExecutor accelerant;
private int threads; private int threads;
protected int cacheX; protected int cacheX;
protected int cacheZ; protected int cacheZ;
private IrisLock genlock;
protected boolean cachingAllowed; protected boolean cachingAllowed;
public ParallelChunkGenerator(String dimensionName, int threads) public ParallelChunkGenerator(String dimensionName, int threads)
@ -32,7 +30,6 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
cacheX = 0; cacheX = 0;
cacheZ = 0; cacheZ = 0;
this.threads = threads; this.threads = threads;
genlock = new IrisLock("ParallelGenLock");
cachingAllowed = false; cachingAllowed = false;
} }
@ -67,7 +64,6 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
{ {
genlock.lock();
cacheX = x; cacheX = x;
cacheZ = z; cacheZ = z;
getCache().targetChunk(cacheX, cacheZ); getCache().targetChunk(cacheX, cacheZ);
@ -101,7 +97,6 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
getMetrics().getTerrain().put(p.getMilliseconds()); getMetrics().getTerrain().put(p.getMilliseconds());
p = PrecisionStopwatch.start(); p = PrecisionStopwatch.start();
onPostGenerate(random, x, z, data, grid, height, biomeMap); onPostGenerate(random, x, z, data, grid, height, biomeMap);
genlock.unlock();
} }
protected void onClose() protected void onClose()

View File

@ -4,7 +4,6 @@ import org.bukkit.World;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.util.CaveResult; import com.volmit.iris.util.CaveResult;
import com.volmit.iris.util.IPostBlockAccess; import com.volmit.iris.util.IPostBlockAccess;
import com.volmit.iris.util.IrisLock; import com.volmit.iris.util.IrisLock;
@ -18,36 +17,35 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator implements IPostBlockAccess { public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator implements IPostBlockAccess
protected boolean generatingCeiling = false; {
protected boolean ceilingCached = false;
protected IrisDimension cacheCeiling = null;
protected IrisDimension cacheFloor = null;
private int currentPostX;
private int currentPostZ;
private ChunkData currentData;
private KList<IrisPostBlockFilter> availableFilters; private KList<IrisPostBlockFilter> availableFilters;
private String postKey; private String postKey;
private IrisLock lock; private IrisLock lock;
private int minPhase; private int minPhase;
private int maxPhase; private int maxPhase;
public PostBlockChunkGenerator(String dimensionName, int threads) { public PostBlockChunkGenerator(String dimensionName, int threads)
{
super(dimensionName, threads); super(dimensionName, threads);
availableFilters = new KList<>(); availableFilters = new KList<>();
postKey = "post-" + dimensionName; postKey = "post-" + dimensionName;
lock = new IrisLock("PostChunkGenerator"); lock = new IrisLock("PostChunkGenerator");
} }
public void onInit(World world, RNG rng) { public void onInit(World world, RNG rng)
{
super.onInit(world, rng); super.onInit(world, rng);
for (Class<? extends IrisPostBlockFilter> i : Iris.postProcessors) { for(Class<? extends IrisPostBlockFilter> i : Iris.postProcessors)
try { {
try
{
availableFilters.add(i.getConstructor(PostBlockChunkGenerator.class).newInstance(this)); availableFilters.add(i.getConstructor(PostBlockChunkGenerator.class).newInstance(this));
} }
catch (Throwable e) { catch(Throwable e)
{
Iris.error("Failed to initialize post processor: " + i.getCanonicalName()); Iris.error("Failed to initialize post processor: " + i.getCanonicalName());
fail(e); fail(e);
} }
@ -55,33 +53,39 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
} }
@Override @Override
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) { protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
{
super.onGenerate(random, x, z, data, grid); super.onGenerate(random, x, z, data, grid);
if (!getDimension().isPostProcessing()) { if(!getDimension().isPostProcessing())
{
return; return;
} }
KList<IrisPostBlockFilter> filters = getDimension().getPostBlockProcessors(this); KList<IrisPostBlockFilter> filters = getDimension().getPostBlockProcessors(this);
currentData = data;
currentPostX = x;
currentPostZ = z;
int rx, i, j; int rx, i, j;
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
for (int h = getMinPhase(); h <= getMaxPhase(); h++) { for(int h = getMinPhase(); h <= getMaxPhase(); h++)
for (i = 0; i < 16; i++) { {
for(i = 0; i < 16; i++)
{
rx = (x << 4) + i; rx = (x << 4) + i;
for (j = 0; j < 16; j++) { for(j = 0; j < 16; j++)
{
int rxx = rx; int rxx = rx;
int rzz = (z << 4) + j; int rzz = (z << 4) + j;
int hh = h; int hh = h;
getAccelerant().queue("post", () -> { getAccelerant().queue("post", () ->
for (IrisPostBlockFilter f : filters) { {
if (f.getPhase() == hh) { for(IrisPostBlockFilter f : filters)
f.onPost(rxx, rzz); {
if(f.getPhase() == hh)
{
f.onPost(rxx, rzz, x, z, data);
} }
} }
}); });
@ -90,14 +94,19 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
getAccelerant().waitFor("post"); getAccelerant().waitFor("post");
for (IrisPostBlockFilter f : filters) { for(IrisPostBlockFilter f : filters)
if (f.getPhase() == h) { {
while (f.getQueue().size() > 0) { if(f.getPhase() == h)
try { {
while(f.getQueue().size() > 0)
{
try
{
f.getQueue().pop().run(); f.getQueue().pop().run();
} }
catch (Throwable e) { catch(Throwable e)
{
} }
} }
@ -109,15 +118,19 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
getMetrics().getPost().put(p.getMilliseconds()); getMetrics().getPost().put(p.getMilliseconds());
} }
public IrisPostBlockFilter createProcessor(String processor, int phase) { public IrisPostBlockFilter createProcessor(String processor, int phase)
for (IrisPostBlockFilter i : availableFilters) { {
if (i.getKey().equals(processor)) { for(IrisPostBlockFilter i : availableFilters)
try { {
return i.getClass().getConstructor(PostBlockChunkGenerator.class, int.class).newInstance(this, if(i.getKey().equals(processor))
phase); {
try
{
return i.getClass().getConstructor(PostBlockChunkGenerator.class, int.class).newInstance(this, phase);
} }
catch (Throwable e) { catch(Throwable e)
{
Iris.error("Failed initialize find post processor: " + processor); Iris.error("Failed initialize find post processor: " + processor);
fail(e); fail(e);
} }
@ -130,13 +143,16 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
} }
@Override @Override
public void updateHeight(int x, int z, int h) { public void updateHeight(int x, int z, int h)
{
getCache().updateHeight(x, z, h); getCache().updateHeight(x, z, h);
} }
@Override @Override
public BlockData getPostBlock(int x, int y, int z) { public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
if (x >> 4 == currentPostX && z >> 4 == currentPostZ) { {
if(x >> 4 == currentPostX && z >> 4 == currentPostZ)
{
lock.lock(); lock.lock();
BlockData d = currentData.getBlockData(x & 15, y, z & 15); BlockData d = currentData.getBlockData(x & 15, y, z & 15);
lock.unlock(); lock.unlock();
@ -147,31 +163,36 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
} }
@Override @Override
public void setPostBlock(int x, int y, int z, BlockData d) { public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData)
if (x >> 4 == currentPostX && z >> 4 == currentPostZ) { {
if(x >> 4 == currentPostX && z >> 4 == currentPostZ)
{
lock.lock(); lock.lock();
currentData.setBlock(x & 15, y, z & 15, d); currentData.setBlock(x & 15, y, z & 15, d);
lock.unlock(); lock.unlock();
} }
else { else
Iris.warn("Post Block Overdraw: " + currentPostX + "," + currentPostZ + " into " + (x >> 4) + ", " {
+ (z >> 4)); Iris.warn("Post Block Overdraw: " + currentPostX + "," + currentPostZ + " into " + (x >> 4) + ", " + (z >> 4));
} }
} }
@Override @Override
public int highestTerrainOrFluidBlock(int x, int z) { public int highestTerrainOrFluidBlock(int x, int z)
{
return getHighest(x, z, false); return getHighest(x, z, false);
} }
@Override @Override
public int highestTerrainBlock(int x, int z) { public int highestTerrainBlock(int x, int z)
{
return getHighest(x, z, true); return getHighest(x, z, true);
} }
@Override @Override
public KList<CaveResult> caveFloors(int x, int z) { public KList<CaveResult> caveFloors(int x, int z)
{
return getCaves(x, z); return getCaves(x, z);
} }
} }

View File

@ -7,21 +7,31 @@ import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Bisected.Half; import org.bukkit.block.data.Bisected.Half;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.atomics.AtomicSliver; import com.volmit.iris.gen.atomics.AtomicSliver;
import com.volmit.iris.gen.layer.GenLayerBiome;
import com.volmit.iris.gen.layer.GenLayerCarve; import com.volmit.iris.gen.layer.GenLayerCarve;
import com.volmit.iris.gen.layer.GenLayerCave; import com.volmit.iris.gen.layer.GenLayerCave;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.object.DecorationPart; import com.volmit.iris.object.DecorationPart;
import com.volmit.iris.object.InferredType; import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomeDecorator; import com.volmit.iris.object.IrisBiomeDecorator;
import com.volmit.iris.object.IrisBiomeGeneratorLink;
import com.volmit.iris.object.IrisDepositGenerator; import com.volmit.iris.object.IrisDepositGenerator;
import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisGenerator;
import com.volmit.iris.object.IrisRegion; import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
import com.volmit.iris.util.BiomeMap; import com.volmit.iris.util.BiomeMap;
import com.volmit.iris.util.BiomeResult; import com.volmit.iris.util.BiomeResult;
import com.volmit.iris.util.CaveResult; import com.volmit.iris.util.CaveResult;
import com.volmit.iris.util.ChronoLatch;
import com.volmit.iris.util.HeightMap; import com.volmit.iris.util.HeightMap;
import com.volmit.iris.util.IrisInterpolation;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@ -37,15 +47,26 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
private GenLayerCave glCave; private GenLayerCave glCave;
private GenLayerCarve glCarve; private GenLayerCarve glCarve;
private RNG rockRandom; private RNG rockRandom;
protected IrisLock regLock;
private KMap<String, IrisGenerator> generators;
protected GenLayerBiome glBiome;
protected CNG masterFracture;
protected ChronoLatch cwarn = new ChronoLatch(1000);
public TerrainChunkGenerator(String dimensionName, int threads) public TerrainChunkGenerator(String dimensionName, int threads)
{ {
super(dimensionName, threads); super(dimensionName, threads);
generators = new KMap<>();
regLock = new IrisLock("BiomeChunkGenerator");
} }
@Override
public void onInit(World world, RNG rng) public void onInit(World world, RNG rng)
{ {
super.onInit(world, rng); super.onInit(world, rng);
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
masterFracture = CNG.signature(rng.nextParallelRNG(13)).scale(0.12);
rockRandom = getMasterRandom().nextParallelRNG(2858678); rockRandom = getMasterRandom().nextParallelRNG(2858678);
glCave = new GenLayerCave(this, rng.nextParallelRNG(238948)); glCave = new GenLayerCave(this, rng.nextParallelRNG(238948));
glCarve = new GenLayerCarve(this, rng.nextParallelRNG(968346576)); glCarve = new GenLayerCarve(this, rng.nextParallelRNG(968346576));
@ -549,10 +570,14 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
return sampleTrueBiome(x, z, getTerrainHeight(x, z)); return sampleTrueBiome(x, z, getTerrainHeight(x, z));
} }
@Override
public IrisRegion sampleRegion(int x, int z) public IrisRegion sampleRegion(int x, int z)
{ {
return getCache().getRegion(x, z, () -> super.sampleRegion(x, z)); return getCache().getRegion(x, z, () ->
{
double wx = getModifiedX(x, z);
double wz = getModifiedZ(x, z);
return glBiome.getRegion(wx, wz);
});
} }
public BiomeResult sampleTrueBiome(int x, int z, double noise) public BiomeResult sampleTrueBiome(int x, int z, double noise)
@ -616,4 +641,183 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
{ {
return Math.max(getTerrainHeight(x, z), getFluidHeight()); return Math.max(getTerrainHeight(x, z), getFluidHeight());
} }
@Override
public void onHotload()
{
super.onHotload();
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
}
public void registerGenerator(IrisGenerator g, IrisDimension dim)
{
KMap<String, IrisGenerator> generators = this.generators;
regLock.lock();
if(g.getLoadKey() == null || generators.containsKey(g.getLoadKey()))
{
regLock.unlock();
return;
}
regLock.unlock();
generators.put(g.getLoadKey(), g);
}
protected KMap<String, IrisGenerator> getGenerators()
{
return generators;
}
protected double getBiomeHeight(double rx, double rz, int x, int z)
{
double h = 0;
for(IrisGenerator i : getGenerators().values())
{
h += interpolateGenerator(rx, rz, i);
}
return h;
}
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen)
{
double hi = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for(IrisBiomeGeneratorLink i : b.getGenerators())
{
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMax();
}
}
}
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample hi biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
}
return 0;
});
double lo = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for(IrisBiomeGeneratorLink i : b.getGenerators())
{
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMin();
}
}
}
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample lo biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
}
return 0;
});
return M.lerp(lo, hi, gen.getHeight(rx, rz, world.getSeed() + 239945));
}
protected void loadGenerators()
{
generators.clear();
loadGenerators(getDimension());
}
protected void loadGenerators(IrisDimension dim)
{
if(dim == null)
{
return;
}
KList<String> touch = new KList<>();
KList<String> loadQueue = new KList<>();
for(String i : dim.getRegions())
{
IrisRegion r = loadRegion(i);
if(r != null)
{
loadQueue.addAll(r.getLandBiomes());
loadQueue.addAll(r.getSeaBiomes());
loadQueue.addAll(r.getShoreBiomes());
loadQueue.addAll(r.getRidgeBiomeKeys());
loadQueue.addAll(r.getSpotBiomeKeys());
}
}
while(!loadQueue.isEmpty())
{
String next = loadQueue.pop();
if(!touch.contains(next))
{
touch.add(next);
IrisBiome biome = loadBiome(next);
biome.getGenerators().forEach((i) -> registerGenerator(i.getCachedGenerator(this), dim));
loadQueue.addAll(biome.getChildren());
}
}
}
public BiomeResult sampleBiome(int x, int z)
{
return getCache().getRawBiome(x, z, () ->
{
if(!getDimension().getFocus().equals(""))
{
IrisBiome biome = loadBiome(getDimension().getFocus());
for(String i : getDimension().getRegions())
{
IrisRegion reg = loadRegion(i);
if(reg.getLandBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.LAND);
break;
}
if(reg.getSeaBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.SEA);
break;
}
if(reg.getShoreBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.SHORE);
break;
}
}
return new BiomeResult(biome, 0);
}
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);
return res;
});
}
} }

View File

@ -16,9 +16,6 @@ public class AtomicMulticache
private final KMap<Long, BiomeResult> biome; private final KMap<Long, BiomeResult> biome;
private final KMap<Long, BiomeResult> rawBiome; private final KMap<Long, BiomeResult> rawBiome;
private final KMap<Long, IrisRegion> region; private final KMap<Long, IrisRegion> region;
private int r = 0;
private int w = 0;
private int m = 0;
public AtomicMulticache() public AtomicMulticache()
{ {
@ -34,9 +31,6 @@ public class AtomicMulticache
{ {
this.x.set(x); this.x.set(x);
this.z.set(z); this.z.set(z);
r = 0;
w = 0;
m = 0;
if(!IrisSettings.get().sharedCaching || getSize() > 42000) if(!IrisSettings.get().sharedCaching || getSize() > 42000)
{ {
@ -46,70 +40,58 @@ public class AtomicMulticache
public double getHeight(int x, int z, Supplier<Double> g) public double getHeight(int x, int z, Supplier<Double> g)
{ {
return height.compute(pos(x, z), (k, v) -> Long pos = pos(x, z);
Double r = height.get(pos);
if(r == null)
{ {
if(v == null) r = g.get();
{ height.put(pos, r);
m++;
w++;
return g.get();
} }
r++; return r;
return v;
});
} }
public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g) public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g)
{ {
return region.compute(pos(x, z), (k, v) -> Long pos = pos(x, z);
IrisRegion r = region.get(pos);
if(r == null)
{ {
if(v == null) r = g.get();
{ region.put(pos, r);
m++;
w++;
return g.get();
} }
r++; return r;
return v;
});
} }
public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g) public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g)
{ {
return biome.compute(pos(x, z), (k, v) -> Long pos = pos(x, z);
BiomeResult r = biome.get(pos);
if(r == null)
{ {
if(v == null) r = g.get();
{ biome.put(pos, r);
m++;
w++;
return g.get();
} }
r++; return r;
return v;
});
} }
public BiomeResult getRawBiome(int x, int z, Supplier<BiomeResult> g) public BiomeResult getRawBiome(int x, int z, Supplier<BiomeResult> g)
{ {
return rawBiome.compute(pos(x, z), (k, v) -> Long pos = pos(x, z);
BiomeResult r = rawBiome.get(pos);
if(r == null)
{ {
if(v == null) r = g.get();
{ rawBiome.put(pos, r);
m++;
w++;
return g.get();
} }
r++; return r;
return v;
});
} }
private long pos(int x, int z) private long pos(int x, int z)

View File

@ -19,7 +19,8 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class GenLayerBiome extends GenLayer { public class GenLayerBiome extends GenLayer
{
private CNG regionGenerator; private CNG regionGenerator;
private CNG bridgeGenerator; private CNG bridgeGenerator;
private BiomeDataProvider seaProvider; private BiomeDataProvider seaProvider;
@ -30,7 +31,8 @@ public class GenLayerBiome extends GenLayer {
private BiomeDataProvider skylandProvider; private BiomeDataProvider skylandProvider;
private DimensionChunkGenerator iris; private DimensionChunkGenerator iris;
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng) { public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
{
super(iris, rng); super(iris, rng);
this.iris = iris; this.iris = iris;
seaProvider = new BiomeDataProvider(this, InferredType.SEA, rng); seaProvider = new BiomeDataProvider(this, InferredType.SEA, rng);
@ -39,14 +41,14 @@ public class GenLayerBiome extends GenLayer {
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng); caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng);
islandProvider = new BiomeDataProvider(this, InferredType.ISLAND, rng); islandProvider = new BiomeDataProvider(this, InferredType.ISLAND, rng);
skylandProvider = new BiomeDataProvider(this, InferredType.SKYLAND, rng); skylandProvider = new BiomeDataProvider(this, InferredType.SKYLAND, rng);
regionGenerator = iris.getDimension().getRegionStyle().create(rng.nextParallelRNG(1188519)).bake() regionGenerator = iris.getDimension().getRegionStyle().create(rng.nextParallelRNG(1188519)).bake().scale(1D / iris.getDimension().getRegionZoom());
.scale(1D / iris.getDimension().getRegionZoom()); bridgeGenerator = iris.getDimension().getContinentalStyle().create(rng.nextParallelRNG(1541462)).bake().scale(1D / iris.getDimension().getContinentZoom());
bridgeGenerator = iris.getDimension().getContinentalStyle().create(rng.nextParallelRNG(1541462)).bake()
.scale(1D / iris.getDimension().getContinentZoom());
} }
public IrisRegion getRegion(double bx, double bz) { public IrisRegion getRegion(double bx, double bz)
if (iris.getDimension().getRegions().isEmpty()) { {
if(iris.getDimension().getRegions().isEmpty())
{
Iris.error("NO REGIONS!"); Iris.error("NO REGIONS!");
return null; return null;
} }
@ -57,60 +59,84 @@ public class GenLayerBiome extends GenLayer {
return regionGenerator.fitRarity(iris.getDimension().getAllRegions(iris), x, z); return regionGenerator.fitRarity(iris.getDimension().getAllRegions(iris), x, z);
} }
public BiomeResult generateData(double bx, double bz, int rawX, int rawZ) { public BiomeResult generateData(double bx, double bz, int rawX, int rawZ)
{
return generateRegionData(bx, bz, rawX, rawZ, getRegion(bx, bz)); return generateRegionData(bx, bz, rawX, rawZ, getRegion(bx, bz));
} }
public BiomeResult generateData(InferredType type, double bx, double bz, int rawX, int rawZ, public BiomeResult generateData(InferredType type, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
IrisRegion regionData) { {
return getProvider(type).generateData(iris, bx, bz, rawX, rawZ, regionData); return getProvider(type).generateData(iris, bx, bz, rawX, rawZ, regionData);
} }
public BiomeDataProvider getProvider(InferredType type) { public BiomeDataProvider getProvider(InferredType type)
if (type.equals(InferredType.SEA)) { {
if(type.equals(InferredType.SEA))
{
return seaProvider; return seaProvider;
} }
else if (type.equals(InferredType.LAND)) { else if(type.equals(InferredType.LAND))
{
return landProvider; return landProvider;
} }
else if (type.equals(InferredType.SHORE)) { else if(type.equals(InferredType.SHORE))
{
return shoreProvider; return shoreProvider;
} }
else if (type.equals(InferredType.CAVE)) { else if(type.equals(InferredType.CAVE))
{
return caveProvider; return caveProvider;
} }
else if (type.equals(InferredType.ISLAND)) { else if(type.equals(InferredType.ISLAND))
{
return islandProvider; return islandProvider;
} }
else if (type.equals(InferredType.SKYLAND)) { else if(type.equals(InferredType.SKYLAND))
{
return skylandProvider; return skylandProvider;
} }
else { else
{
Iris.error("Cannot find a BiomeDataProvider for type " + type.name()); Iris.error("Cannot find a BiomeDataProvider for type " + type.name());
} }
return null; return null;
} }
public BiomeResult generateRegionData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData) { public BiomeResult generateRegionData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{
return generateData(getType(bx, bz, regionData), bx, bz, rawX, rawZ, regionData); return generateData(getType(bx, bz, regionData), bx, bz, rawX, rawZ, regionData);
} }
public InferredType getType(double bx, double bz, IrisRegion regionData) { public InferredType getType(double bx, double bz, IrisRegion regionData)
{
double x = bx; double x = bx;
double z = bz; double z = bz;
return bridgeGenerator.fit(0, 1, x, z) == 0 ? InferredType.LAND : InferredType.SEA; double c = iris.getDimension().getLandChance();
if(c >= 1)
{
return InferredType.LAND;
} }
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CNG cell, KList<IrisBiome> biomes, if(c <= 0)
InferredType inferredType) { {
if (biomes.isEmpty()) { return InferredType.SEA;
}
return bridgeGenerator.fitDouble(0, 1, x, z) < c ? InferredType.LAND : InferredType.SEA;
}
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CNG cell, KList<IrisBiome> biomes, InferredType inferredType)
{
if(biomes.isEmpty())
{
return new BiomeResult(null, 0); return new BiomeResult(null, 0);
} }
@ -122,16 +148,20 @@ public class GenLayerBiome extends GenLayer {
return implode(bx, bz, regionData, cell, new BiomeResult(biome, 1)); return implode(bx, bz, regionData, cell, new BiomeResult(biome, 1));
} }
public BiomeResult generateImpureData(int rawX, int rawZ, InferredType type, IrisRegion regionData, public BiomeResult generateImpureData(int rawX, int rawZ, InferredType type, IrisRegion regionData, BiomeResult pureResult)
BiomeResult pureResult) { {
for (IrisRegionRidge i : regionData.getRidgeBiomes()) { for(IrisRegionRidge i : regionData.getRidgeBiomes())
if (i.getType().equals(type) && i.isRidge(rng, rawX, rawZ)) { {
if(i.getType().equals(type) && i.isRidge(rng, rawX, rawZ))
{
return new BiomeResult(iris.loadBiome(i.getBiome()).infer(i.getAs(), type), 0.5); return new BiomeResult(iris.loadBiome(i.getBiome()).infer(i.getAs(), type), 0.5);
} }
} }
for (IrisRegionSpot i : regionData.getSpotBiomes()) { for(IrisRegionSpot i : regionData.getSpotBiomes())
if (i.getType().equals(type) && i.isSpot(rng, rawX, rawZ)) { {
if(i.getType().equals(type) && i.isSpot(rng, rawX, rawZ))
{
return new BiomeResult(iris.loadBiome(i.getBiome()).infer(i.getAs(), type), 0.5); return new BiomeResult(iris.loadBiome(i.getBiome()).infer(i.getAs(), type), 0.5);
} }
} }
@ -139,20 +169,23 @@ public class GenLayerBiome extends GenLayer {
return pureResult; return pureResult;
} }
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CNG parentCell, BiomeResult parent) { public BiomeResult implode(double bx, double bz, IrisRegion regionData, CNG parentCell, BiomeResult parent)
{
return implode(bx, bz, regionData, parentCell, parent, 1); return implode(bx, bz, regionData, parentCell, parent, 1);
} }
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CNG parentCell, BiomeResult parent, public BiomeResult implode(double bx, double bz, IrisRegion regionData, CNG parentCell, BiomeResult parent, int hits)
int hits) { {
if (hits > IrisSettings.get().maxBiomeChildDepth) { if(hits > IrisSettings.get().maxBiomeChildDepth)
{
return parent; return parent;
} }
double x = bx / iris.getDimension().getBiomeZoom(); double x = bx / iris.getDimension().getBiomeZoom();
double z = bz / iris.getDimension().getBiomeZoom(); double z = bz / iris.getDimension().getBiomeZoom();
if (!parent.getBiome().getRealChildren(iris).isEmpty()) { if(!parent.getBiome().getRealChildren(iris).isEmpty())
{
CNG childCell = parent.getBiome().getChildrenGenerator(rng, 123, parent.getBiome().getChildShrinkFactor()); CNG childCell = parent.getBiome().getChildrenGenerator(rng, 123, parent.getBiome().getChildShrinkFactor());
KList<IrisBiome> chx = parent.getBiome().getRealChildren(iris).copy(); // TODO Cache KList<IrisBiome> chx = parent.getBiome().getRealChildren(iris).copy(); // TODO Cache
chx.add(parent.getBiome()); chx.add(parent.getBiome());
@ -166,7 +199,8 @@ public class GenLayerBiome extends GenLayer {
} }
@Override @Override
public double generate(double x, double z) { public double generate(double x, double z)
{
return 0; return 0;
} }
} }

View File

@ -178,7 +178,7 @@ public class GenLayerCave extends GenLayer
public boolean canAir(Material m) public boolean canAir(Material m)
{ {
return (m.isSolid() || (B.isDecorant(m)) || m.equals(Material.AIR) || m.equals(B.mat("CAVE_AIR"))) && !m.equals(Material.BEDROCK); return (B.isSolid(m) || (B.isDecorant(m)) || m.equals(Material.AIR) || m.equals(B.mat("CAVE_AIR"))) && !m.equals(Material.BEDROCK);
} }
public boolean canWater(Material m) public boolean canWater(Material m)
@ -188,7 +188,7 @@ public class GenLayerCave extends GenLayer
public boolean can(Material m) public boolean can(Material m)
{ {
return m.isSolid() && !m.equals(Material.BEDROCK); return B.isSolid(m) && !m.equals(Material.BEDROCK);
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package com.volmit.iris.gen.post; package com.volmit.iris.gen.post;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
@ -22,7 +23,7 @@ public class PostFloatingNibDeleter extends IrisPostBlockFilter
} }
@Override @Override
public void onPost(int x, int z) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int g = 0; int g = 0;
int h = highestTerrainBlock(x, z); int h = highestTerrainBlock(x, z);
@ -41,13 +42,13 @@ public class PostFloatingNibDeleter extends IrisPostBlockFilter
g += hc < h - 1 ? 1 : 0; g += hc < h - 1 ? 1 : 0;
g += hd < h - 1 ? 1 : 0; g += hd < h - 1 ? 1 : 0;
if(g == 4 && isAir(x, h - 1, z)) if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData))
{ {
setPostBlock(x, h, z, AIR); setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData);
for(int i = h - 1; i > 0; i--) for(int i = h - 1; i > 0; i--)
{ {
if(!isAir(x, i, z)) if(!isAir(x, i, z, currentPostX, currentPostZ, currentData))
{ {
updateHeight(x, z, i); updateHeight(x, z, i);
break; break;

View File

@ -2,6 +2,7 @@ package com.volmit.iris.gen.post;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.util.IrisPostBlockFilter; import com.volmit.iris.util.IrisPostBlockFilter;
@ -20,7 +21,7 @@ public class PostNibSmoother extends IrisPostBlockFilter
} }
@Override @Override
public void onPost(int x, int z) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int g = 0; int g = 0;
int h = highestTerrainBlock(x, z); int h = highestTerrainBlock(x, z);
@ -35,13 +36,13 @@ public class PostNibSmoother extends IrisPostBlockFilter
if(g >= 3) if(g >= 3)
{ {
BlockData bc = getPostBlock(x, h, z); BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
BlockData b = getPostBlock(x, h + 1, z); BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
Material m = bc.getMaterial(); Material m = bc.getMaterial();
if(m.isSolid()) if(m.isSolid())
{ {
setPostBlock(x, h, z, b); setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h - 1); updateHeight(x, z, h - 1);
} }
} }

View File

@ -1,5 +1,7 @@
package com.volmit.iris.gen.post; package com.volmit.iris.gen.post;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.util.IrisPostBlockFilter; import com.volmit.iris.util.IrisPostBlockFilter;
@ -17,7 +19,7 @@ public class PostPotholeFiller extends IrisPostBlockFilter
} }
@Override @Override
public void onPost(int x, int z) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int g = 0; int g = 0;
int h = highestTerrainBlock(x, z); int h = highestTerrainBlock(x, z);
@ -32,7 +34,7 @@ public class PostPotholeFiller extends IrisPostBlockFilter
if(g >= 3) if(g >= 3)
{ {
setPostBlock(x, h + 1, z, getPostBlock(x, h, z)); setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1); updateHeight(x, z, h + 1);
} }
} }

View File

@ -2,6 +2,7 @@ package com.volmit.iris.gen.post;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.util.IrisPostBlockFilter; import com.volmit.iris.util.IrisPostBlockFilter;
@ -26,7 +27,7 @@ public class PostSlabber extends IrisPostBlockFilter
} }
@Override @Override
public void onPost(int x, int z) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int h = highestTerrainBlock(x, z); int h = highestTerrainBlock(x, z);
int ha = highestTerrainBlock(x + 1, z); int ha = highestTerrainBlock(x + 1, z);
@ -34,7 +35,7 @@ public class PostSlabber extends IrisPostBlockFilter
int hc = highestTerrainBlock(x - 1, z); int hc = highestTerrainBlock(x - 1, z);
int hd = highestTerrainBlock(x, z - 1); int hd = highestTerrainBlock(x, z - 1);
if((ha == h + 1 && isSolid(x + 1, ha, z)) || (hb == h + 1 && isSolid(x, hb, z + 1)) || (hc == h + 1 && isSolid(x - 1, hc, z)) || (hd == h + 1 && isSolid(x, hd, z - 1))) 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).getBiome().getSlab().get(rng, x, h, z);
@ -50,16 +51,16 @@ public class PostSlabber extends IrisPostBlockFilter
return; return;
} }
if(isSnowLayer(x, h, z)) if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData))
{ {
return; return;
} }
if(isAirOrWater(x, h + 2, z)) if(isAirOrWater(x, h + 2, z, currentPostX, currentPostZ, currentData))
{ {
queue(() -> queue(() ->
{ {
setPostBlock(x, h + 1, z, d); setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1); updateHeight(x, z, h + 1);
}); });
} }

View File

@ -2,6 +2,7 @@ package com.volmit.iris.gen.post;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
@ -26,7 +27,7 @@ public class PostWallPatcher extends IrisPostBlockFilter
} }
@Override @Override
public void onPost(int x, int z) 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).getBiome();
int h, ha, hb, hc, hd; int h, ha, hb, hc, hd;
@ -48,7 +49,7 @@ public class PostWallPatcher extends IrisPostBlockFilter
{ {
if(!s.getMaterial().equals(AIR)) if(!s.getMaterial().equals(AIR))
{ {
setPostBlock(x, h + 1, z, s); setPostBlock(x, h + 1, z, s, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1); updateHeight(x, z, h + 1);
} }
} }
@ -64,12 +65,12 @@ public class PostWallPatcher extends IrisPostBlockFilter
continue; continue;
} }
if(isAirOrWater(x, i, z)) if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData))
{ {
continue; continue;
} }
setPostBlock(x, i, z, d); setPostBlock(x, i, z, d, currentPostX, currentPostZ, currentData);
} }
} }
} }

View File

@ -3,6 +3,7 @@ package com.volmit.iris.gen.post;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.Waterlogged;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
@ -24,10 +25,10 @@ public class PostWaterlogger extends IrisPostBlockFilter
} }
@Override @Override
public void onPost(int x, int z) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int h = highestTerrainBlock(x, z); int h = highestTerrainBlock(x, z);
BlockData b = getPostBlock(x, h, z); BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
if(b instanceof Waterlogged) if(b instanceof Waterlogged)
{ {
@ -38,24 +39,24 @@ public class PostWaterlogger extends IrisPostBlockFilter
return; return;
} }
if(isWaterOrWaterlogged(x, h + 1, z) && !ww.isWaterlogged()) if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData) && !ww.isWaterlogged())
{ {
ww.setWaterlogged(true); ww.setWaterlogged(true);
setPostBlock(x, h, z, ww); setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
} }
else if(!ww.isWaterlogged() && (isWaterOrWaterlogged(x + 1, h, z) || isWaterOrWaterlogged(x - 1, h, z) || isWaterOrWaterlogged(x, h, z + 1) || isWaterOrWaterlogged(x, h, z - 1))) else if(!ww.isWaterlogged() && (isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData)))
{ {
ww.setWaterlogged(true); ww.setWaterlogged(true);
setPostBlock(x, h, z, ww); setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
} }
} }
else if(b.getMaterial().equals(Material.AIR) && h <= gen.getFluidHeight()) else if(b.getMaterial().equals(Material.AIR) && h <= gen.getFluidHeight())
{ {
if((isWaterOrWaterlogged(x + 1, h, z) || isWaterOrWaterlogged(x - 1, h, z) || isWaterOrWaterlogged(x, h, z + 1) || isWaterOrWaterlogged(x, h, z - 1))) if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData)))
{ {
setPostBlock(x, h, z, WATER); setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData);
} }
} }
} }

View File

@ -1,4 +1,4 @@
package com.volmit.iris; package com.volmit.iris.gui;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -24,6 +24,7 @@ import javax.swing.JLayeredPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JViewport; import javax.swing.JViewport;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.IrisChunkGenerator; import com.volmit.iris.gen.IrisChunkGenerator;
import com.volmit.iris.noise.CNG; import com.volmit.iris.noise.CNG;
import com.volmit.iris.object.NoiseStyle; import com.volmit.iris.object.NoiseStyle;

View File

@ -31,6 +31,7 @@ public class CNG
private final double opacity; private final double opacity;
private NoiseInjector injector; private NoiseInjector injector;
private RNG rng; private RNG rng;
private boolean noscale;
private int oct; private int oct;
private double patch; private double patch;
private double up; private double up;
@ -124,6 +125,7 @@ public class CNG
public CNG(RNG random, NoiseType t, double opacity, int octaves) public CNG(RNG random, NoiseType t, double opacity, int octaves)
{ {
creates++; creates++;
noscale = t.equals(NoiseType.WHITE);
this.oct = octaves; this.oct = octaves;
this.rng = random; this.rng = random;
power = 1; power = 1;
@ -332,8 +334,8 @@ public class CNG
public double noise(double... dim) public double noise(double... dim)
{ {
double scale = this.bakedScale * this.scale; double scale = noscale ? 1 : this.bakedScale * this.scale;
double f = (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D); double f = noscale ? 0 : (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
double x = dim.length > 0 ? dim[0] + f : 0D; double x = dim.length > 0 ? dim[0] + f : 0D;
double y = dim.length > 1 ? dim[1] - f : 0D; double y = dim.length > 1 ? dim[1] - f : 0D;
double z = dim.length > 2 ? dim[2] - f : 0D; double z = dim.length > 2 ? dim[2] - f : 0D;

View File

@ -353,21 +353,21 @@ public class FastNoise
private static double DValCoord2D(int seed, long x, long y) private static double DValCoord2D(int seed, long x, long y)
{ {
int n = seed; long n = seed;
n ^= X_PRIME_L * x; n ^= X_PRIME_L * x;
n ^= Y_PRIME_L * y; n ^= Y_PRIME_L * y;
return ((n * n * n * 604930000L) / 21474836480000D) % 2D; return ((n * n * n * 60493L) / (double) Long.MAX_VALUE);
} }
private static double DValCoord3D(int seed, long x, long y, long z) private static double DValCoord3D(int seed, long x, long y, long z)
{ {
int n = seed; long n = seed;
n ^= X_PRIME_L * x; n ^= X_PRIME_L * x;
n ^= Y_PRIME_L * y; n ^= Y_PRIME_L * y;
n ^= Z_PRIME_L * z; n ^= Z_PRIME_L * z;
return ((n * n * n * 604930000L) / 21474836480000D) % 2D; return ((n * n * n * 60493L) / (double) Long.MAX_VALUE);
} }
private static float ValCoord3D(int seed, int x, int y, int z) private static float ValCoord3D(int seed, int x, int y, int z)
@ -628,7 +628,7 @@ public class FastNoise
{ {
long i = Double.doubleToRawLongBits(f); long i = Double.doubleToRawLongBits(f);
return i ^ (i >> 16); return i ^ (i >> 32);
} }
public float GetWhiteNoise(float x, float y, float z, float w) public float GetWhiteNoise(float x, float y, float z, float w)

View File

@ -9,21 +9,26 @@ public class WhiteNoise implements NoiseGenerator
n = new FastNoise((int) seed); n = new FastNoise((int) seed);
} }
private double f(double m)
{
return m;
}
@Override @Override
public double noise(double x) public double noise(double x)
{ {
return (n.GetWhiteNoise(Float.intBitsToFloat((int) Double.doubleToLongBits(x / 1000d)) % 1000000F, 0) / 2D) + 0.5D; return (n.DGetWhiteNoise(f(x), 0d) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double z) public double noise(double x, double z)
{ {
return (n.GetWhiteNoise(Float.intBitsToFloat((int) Double.doubleToLongBits(x / 1000d)) % 1000000F, Float.intBitsToFloat((int) Double.doubleToLongBits(z / 1000d)) % 1000000F) / 2D) + 0.5D; return (n.DGetWhiteNoise(f(x), f(z)) / 2D) + 0.5D;
} }
@Override @Override
public double noise(double x, double y, double z) public double noise(double x, double y, double z)
{ {
return (n.GetWhiteNoise(Float.intBitsToFloat((int) Double.doubleToLongBits(x / 1000d)) % 1000000F, Float.intBitsToFloat((int) Double.doubleToLongBits(y / 1000d)) % 1000000F, Float.intBitsToFloat((int) Double.doubleToLongBits(z / 1000d)) % 1000000F) / 2D) + 0.5D; return (n.DGetWhiteNoise(f(x), f(y), f(z)) / 2D) + 0.5D;
} }
} }

View File

@ -22,7 +22,6 @@ import com.volmit.iris.util.MaxNumber;
import com.volmit.iris.util.MinNumber; import com.volmit.iris.util.MinNumber;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
import com.volmit.iris.util.RegistryListBiome; import com.volmit.iris.util.RegistryListBiome;
import com.volmit.iris.util.RegistryListDimension;
import com.volmit.iris.util.RegistryListRegion; import com.volmit.iris.util.RegistryListRegion;
import com.volmit.iris.util.Required; import com.volmit.iris.util.Required;
@ -49,6 +48,12 @@ public class IrisDimension extends IrisRegistrant
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).") @Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
private int version = 1; private int version = 1;
@MinNumber(0)
@MaxNumber(1)
@DontObfuscate
@Desc("The land chance. Up to 1.0 for total land or 0.0 for total sea")
private double landChance = 0.625;
@DontObfuscate @DontObfuscate
@Desc("The placement style of regions") @Desc("The placement style of regions")
private IrisGeneratorStyle regionStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); private IrisGeneratorStyle regionStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
@ -145,15 +150,6 @@ public class IrisDimension extends IrisRegistrant
@Desc("Compatability filters") @Desc("Compatability filters")
private KList<IrisCompatabilityFilter> compatability = getDefaultCompatability(); private KList<IrisCompatabilityFilter> compatability = getDefaultCompatability();
@RegistryListDimension
@DontObfuscate
@Desc("The ceiling dimension. Leave blank for normal sky.")
private String ceiling = "";
@DontObfuscate
@Desc("Mirrors the generator floor into the ceiling. Think nether but worse...")
private boolean mirrorCeiling = false;
@Required @Required
@DontObfuscate @DontObfuscate
@Desc("The world environment") @Desc("The world environment")
@ -289,7 +285,6 @@ public class IrisDimension extends IrisRegistrant
private transient AtomicCache<Double> sinr = new AtomicCache<>(); private transient AtomicCache<Double> sinr = new AtomicCache<>();
private transient AtomicCache<Double> cosr = new AtomicCache<>(); private transient AtomicCache<Double> cosr = new AtomicCache<>();
private transient AtomicCache<Double> rad = new AtomicCache<>(); private transient AtomicCache<Double> rad = new AtomicCache<>();
private transient boolean inverted = false;
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g) public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g)
{ {

View File

@ -188,8 +188,6 @@ public class IrisObject extends IrisRegistrant
} }
for(IrisObjectReplace j : config.getEdit()) for(IrisObjectReplace j : config.getEdit())
{
if(j.isExact())
{ {
for(BlockData k : j.getFind()) for(BlockData k : j.getFind())
{ {
@ -199,7 +197,6 @@ public class IrisObject extends IrisRegistrant
} }
} }
} }
}
data = config.getRotation().rotate(data, spinx, spiny, spinz); data = config.getRotation().rotate(data, spinx, spiny, spinz);
int xx = x + (int) Math.round(i.getX()); int xx = x + (int) Math.round(i.getX());

View File

@ -9,19 +9,12 @@ import com.volmit.iris.util.RNG;
@Desc("Styles of noise") @Desc("Styles of noise")
@DontObfuscate @DontObfuscate
public enum NoiseStyle { public enum NoiseStyle
{
@Desc("White Noise is like static. Useful for block scattering but not terrain.") @Desc("White Noise is like static. Useful for block scattering but not terrain.")
@DontObfuscate @DontObfuscate
STATIC(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1)), STATIC(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1)),
@Desc("White Noise is like static. Useful for block scattering but not terrain. 4 Times finer.")
@DontObfuscate
STATIC_FINE(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1).scale(4)),
@Desc("White Noise is like static. Useful for block scattering but not terrain. 16 Times finer.")
@DontObfuscate
STATIC_ULTRA_FINE(rng -> new CNG(rng, NoiseType.WHITE, 1D, 1).scale(16)),
@Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.") @Desc("Wispy Perlin-looking simplex noise. The 'iris' style noise.")
@DontObfuscate @DontObfuscate
IRIS(rng -> CNG.signature(rng).scale(1)), IRIS(rng -> CNG.signature(rng).scale(1)),
@ -44,9 +37,7 @@ public enum NoiseStyle {
@Desc("Very Detailed smoke using simplex fractured with fractal billow simplex at high octaves.") @Desc("Very Detailed smoke using simplex fractured with fractal billow simplex at high octaves.")
@DontObfuscate @DontObfuscate
FRACTAL_SMOKE(rng -> new CNG(rng, 1D, 1) FRACTAL_SMOKE(rng -> new CNG(rng, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 8).scale(0.2), 1000).scale(0.34)),
.fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_BILLOW_SIMPLEX, 1D, 8).scale(0.2), 1000)
.scale(0.34)),
@Desc("Thinner Veins.") @Desc("Thinner Veins.")
@DontObfuscate @DontObfuscate
@ -54,19 +45,15 @@ public enum NoiseStyle {
@Desc("Cells of simplex noise") @Desc("Cells of simplex noise")
@DontObfuscate @DontObfuscate
SIMPLEX_CELLS(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1) SIMPLEX_CELLS(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1).fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.CELLULAR, 1D, 1).scale(1), 200)),
.fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.CELLULAR, 1D, 1).scale(1), 200)),
@Desc("Veins of simplex noise") @Desc("Veins of simplex noise")
@DontObfuscate @DontObfuscate
SIMPLEX_VASCULAR(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1) SIMPLEX_VASCULAR(rng -> new CNG(rng.nextParallelRNG(1), NoiseType.SIMPLEX, 1D, 1).scale(1).fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.VASCULAR, 1D, 1).scale(1), 200)),
.fractureWith(new CNG(rng.nextParallelRNG(8), NoiseType.VASCULAR, 1D, 1).scale(1), 200)),
@Desc("Very Detailed fluid using simplex fractured with fractal billow simplex at high octaves.") @Desc("Very Detailed fluid using simplex fractured with fractal billow simplex at high octaves.")
@DontObfuscate @DontObfuscate
FRACTAL_WATER(rng -> new CNG(rng, 1D, 1) FRACTAL_WATER(rng -> new CNG(rng, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 9).scale(0.03), 9900).scale(1.14)),
.fractureWith(new CNG(rng.nextParallelRNG(1), NoiseType.FRACTAL_FBM_SIMPLEX, 1D, 9).scale(0.03), 9900)
.scale(1.14)),
@Desc("Perlin. Like simplex but more natural") @Desc("Perlin. Like simplex but more natural")
@DontObfuscate @DontObfuscate
@ -413,17 +400,21 @@ public enum NoiseStyle {
VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)), VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)),
; ;
private CNGFactory f; private CNGFactory f;
private NoiseStyle(CNGFactory f) { private NoiseStyle(CNGFactory f)
{
this.f = f; this.f = f;
} }
public CNG create(RNG seed) { public CNG create(RNG seed)
{
return f.create(seed).bake(); return f.create(seed).bake();
} }
public IrisGeneratorStyle style() { public IrisGeneratorStyle style()
{
return new IrisGeneratorStyle(this); return new IrisGeneratorStyle(this);
} }
} }

View File

@ -12,13 +12,11 @@ public class GroupedExecutor
{ {
private int xc; private int xc;
private ExecutorService service; private ExecutorService service;
private IrisLock lock;
private KMap<String, Integer> mirror; private KMap<String, Integer> mirror;
public GroupedExecutor(int threadLimit, int priority, String name) public GroupedExecutor(int threadLimit, int priority, String name)
{ {
xc = 1; xc = 1;
lock = new IrisLock("GX");
mirror = new KMap<String, Integer>(); mirror = new KMap<String, Integer>();
if(threadLimit == 1) if(threadLimit == 1)
@ -79,8 +77,6 @@ public class GroupedExecutor
while(true) while(true)
{ {
J.sleep(0);
if(mirror.get(g) == 0) if(mirror.get(g) == 0)
{ {
break; break;
@ -97,13 +93,8 @@ public class GroupedExecutor
public void queue(String q, NastyRunnable r) public void queue(String q, NastyRunnable r)
{ {
lock.lock(); mirror.compute(q, (k, v) -> k == null || v == null ? 1 : v + 1);
if(!mirror.containsKey(q))
{
mirror.put(q, 0);
}
mirror.put(q, mirror.get(q) + 1);
lock.unlock();
service.execute(() -> service.execute(() ->
{ {
try try
@ -116,9 +107,7 @@ public class GroupedExecutor
} }
lock.lock(); mirror.compute(q, (k, v) -> v - 1);
mirror.put(q, mirror.get(q) - 1);
lock.unlock();
}); });
} }
@ -126,7 +115,7 @@ public class GroupedExecutor
{ {
J.a(() -> J.a(() ->
{ {
J.sleep(10000); J.sleep(100);
service.shutdown(); service.shutdown();
}); });
} }

View File

@ -1,12 +1,13 @@
package com.volmit.iris.util; package com.volmit.iris.util;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
public interface IPostBlockAccess public interface IPostBlockAccess
{ {
public BlockData getPostBlock(int x, int y, int z); public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData);
public void setPostBlock(int x, int y, int z, BlockData d); public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData);
public int highestTerrainOrFluidBlock(int x, int z); public int highestTerrainOrFluidBlock(int x, int z);

View File

@ -132,6 +132,13 @@ public class IrisInterpolation
return cubic(cubic(p00, p01, p02, p03, muy), cubic(p10, p11, p12, p13, muy), cubic(p20, p21, p22, p23, muy), cubic(p30, p31, p32, p33, muy), mux); return cubic(cubic(p00, p01, p02, p03, muy), cubic(p10, p11, p12, p13, muy), cubic(p20, p21, p22, p23, muy), cubic(p30, p31, p32, p33, muy), mux);
} }
public static double trilerp(double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double x, double y, double z)
{
double s = blerp(v1, v2, v3, v4, x, y);
double t = blerp(v5, v6, v7, v8, x, y);
return lerp(s, t, z);
}
public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n) public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n)
{ {
int fx = (int) Math.floor(x / rad); int fx = (int) Math.floor(x / rad);

View File

@ -5,6 +5,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Levelled; import org.bukkit.block.data.Levelled;
import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Slab; import org.bukkit.block.data.type.Slab;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.gen.post.Post; import com.volmit.iris.gen.post.Post;
@ -32,18 +33,18 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
this(gen, 0); this(gen, 0);
} }
public abstract void onPost(int x, int z); public abstract void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData);
@Override @Override
public BlockData getPostBlock(int x, int y, int z) public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
return gen.getPostBlock(x, y, z); return gen.getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
} }
@Override @Override
public void setPostBlock(int x, int y, int z, BlockData d) public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
gen.setPostBlock(x, y, z, d); gen.setPostBlock(x, y, z, d, currentPostX, currentPostZ, currentData);
} }
@Override @Override
@ -58,57 +59,57 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
return gen.highestTerrainBlock(x, z); return gen.highestTerrainBlock(x, z);
} }
public boolean isAir(int x, int y, int z) public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR); return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
} }
public boolean hasGravity(int x, int y, int z) public boolean hasGravity(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER); return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER);
} }
public boolean isSolid(int x, int y, int z) public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid(); return d.getMaterial().isSolid();
} }
public boolean isAirOrWater(int x, int y, int z) public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR); return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
} }
public boolean isSlab(int x, int y, int z) public boolean isSlab(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Slab; return d instanceof Slab;
} }
public boolean isSnowLayer(int x, int y, int z) public boolean isSnowLayer(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.SNOW); return d.getMaterial().equals(Material.SNOW);
} }
public boolean isWater(int x, int y, int z) public boolean isWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER); return d.getMaterial().equals(Material.WATER);
} }
public boolean isWaterOrWaterlogged(int x, int y, int z) public boolean isWaterOrWaterlogged(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged()); return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged());
} }
public boolean isLiquid(int x, int y, int z) public boolean isLiquid(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Levelled; return d instanceof Levelled;
} }