This commit is contained in:
Daniel Mills 2020-01-17 10:40:45 -05:00
parent 451eca0aa9
commit 3a699d34eb
11 changed files with 135 additions and 99 deletions

View File

@ -14,19 +14,20 @@ public class Settings
public int threadPriority = Thread.MAX_PRIORITY;
public int threadCount = 4;
public boolean debugMode = true;
public int decorationAccuracy = 1;
public int cascadeLimit = 14;
public int decorationAccuracy = 2;
public boolean interpolation = true;
public boolean surfaceNoise = true;
public boolean verbose = false;
}
public static class GeneratorSettings
{
public double objectDensity = 1D;
public int hermiteSampleRadius = 4;
public double horizontalZoom = 2;
public double heightFracture = 155;
public double landScale = 0.5;
public double landChance = 0.6;
public double landScale = 0.45;
public double landChance = 0.53;
public double biomeEdgeScramble = 0; // 1550D
public double roughness = 1.55;
public double heightMultiplier = 0.806;
@ -37,12 +38,12 @@ public class Settings
public int seaLevel = 63;
public double caveDensity = 4;
public double caveScale = 1.45;
public double biomeScale = 1.65;
public double biomeScale = 1.25;
public boolean flatBedrock = true;
public boolean genObjects = false;
public boolean genCarving = false;
public boolean genCaverns = false;
public boolean genCaves = false;
public boolean genObjects = true;
public boolean genCarving = true;
public boolean genCaverns = true;
public boolean genCaves = true;
public double carvingChance = 0.352;
public double cavernChance = 0.321;
public int minCarvingHeight = 75;

View File

@ -18,6 +18,8 @@ import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.execution.TaskExecutor;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
import ninja.bytecode.shuriken.format.F;
import ninja.bytecode.shuriken.io.IO;
import ninja.bytecode.shuriken.json.JSONException;
@ -103,12 +105,16 @@ public class PackController implements IrisController
}
L.v(ChatColor.LIGHT_PURPLE + "Processing Content");
TaskExecutor executor = new TaskExecutor(Runtime.getRuntime().availableProcessors() * 2, Thread.MIN_PRIORITY, "Schematic Processor");
TaskGroup gx = executor.startWork();
for(GenObjectGroup i : genObjectGroups.v())
{
i.processVariants();
gx.queue(i::processVariants);
}
gx.execute();
executor.close();
for(String i : dimensions.k())
{
IrisDimension id = dimensions.get(i);

View File

@ -11,7 +11,6 @@ import org.bukkit.generator.BlockPopulator;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
import ninja.bytecode.iris.generator.layer.BiomeNoiseGenerator;
import ninja.bytecode.iris.generator.layer.GenLayerBiome;
import ninja.bytecode.iris.generator.layer.GenLayerCarving;
import ninja.bytecode.iris.generator.layer.GenLayerCaverns;
@ -67,7 +66,6 @@ public class IrisGenerator extends ParallelChunkGenerator
private GenLayerCarving glCarving;
private GenLayerCaverns glCaverns;
private GenLayerSnow glSnow;
private BiomeNoiseGenerator glBase;
private GenLayerCliffs glCliffs;
private RNG rTerrain;
private CompiledDimension dim;
@ -145,7 +143,17 @@ public class IrisGenerator extends ParallelChunkGenerator
public IrisBiome getBiome(int wxx, int wzx)
{
return glBiome.getBiome(wxx, wzx);
IrisBiome biome = glBiome.getBiome(wxx, wzx);
IrisBiome real = glBiome.getBiome(wxx, wzx, true);
boolean frozen = getRegion(biome) != null ? getRegion(biome).isFrozen() : false;
int height = computeHeight(wxx, wzx, new ChunkPlan(), biome);
int max = Math.max(height, Iris.settings.gen.seaLevel);
IrisBiome nbiome = height < 63 ? getOcean(real, height) : biome;
biome = nbiome;
biome = height > 61 && height < 65 ? frozen ? biome : getBeach(real) : biome;
biome = height > 63 && biome.getType().equals(BiomeType.FLUID) ? getBeach(real) : biome;
return biome;
}
public IrisBiome biome(String name)
@ -236,13 +244,10 @@ public class IrisGenerator extends ParallelChunkGenerator
int highest = 0;
int seaLevel = Iris.settings.gen.seaLevel;
IrisBiome biome = getBiome(wxx, wzx);
boolean frozen = getRegion(biome) != null ? getRegion(biome).isFrozen() : false;
IrisRegion r = getRegion(biome);
boolean frozen = r != null && r.isFrozen();
int height = computeHeight(wxx, wzx, plan, biome);
int max = Math.max(height, seaLevel);
IrisBiome nbiome = height < 63 ? getOcean(biome, height) : biome;
biome = nbiome;
biome = height > 61 && height < 65 ? frozen ? biome : getBeach(biome) : biome;
biome = height > 63 && biome.getType().equals(BiomeType.FLUID) ? getBeach(biome) : biome;
for(int i = 0; i < max; i++)
{

View File

@ -15,6 +15,9 @@ import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import mortar.compute.math.M;
import mortar.logic.format.F;
import mortar.util.text.C;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.placer.NMSPlacer;
import ninja.bytecode.iris.util.Direction;
import ninja.bytecode.iris.util.IPlacer;
@ -225,17 +228,17 @@ public class GenObject
return g % 2 == 0 ? m : m + 1;
}
public void place(Location l)
public Location place(Location l)
{
place(l, new NMSPlacer(l.getWorld()));
return place(l, new NMSPlacer(l.getWorld()));
}
public void place(Location l, IPlacer placer)
public Location place(Location l, IPlacer placer)
{
place(l.getBlockX(), l.getBlockY(), l.getBlockZ(), placer);
return place(l.getBlockX(), l.getBlockY(), l.getBlockZ(), placer);
}
public void place(int wx, int wy, int wz, IPlacer placer)
public Location place(int wx, int wy, int wz, IPlacer placer)
{
Location start = new Location(placer.getWorld(), wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d));
@ -275,7 +278,12 @@ public class GenObject
placer.set(j, undo.get(j));
}
return;
if(Iris.settings.performance.verbose)
{
L.w(C.WHITE + "Object " + C.YELLOW + getName() + C.WHITE + " failed to place in " + C.YELLOW + m.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(f.getBlockX()) + " " + F.f(f.getBlockY()) + " " + F.f(f.getBlockZ()));
}
return null;
}
if(b.material.equals(Material.SKULL))
@ -294,6 +302,8 @@ public class GenObject
e.printStackTrace();
}
}
return start;
}
public static GenObject load(InputStream in) throws IOException

View File

@ -3,12 +3,15 @@ package ninja.bytecode.iris.generator.genobject;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.generator.BlockPopulator;
import mortar.logic.format.F;
import mortar.util.text.C;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.TimingsController;
@ -38,7 +41,7 @@ public class GenObjectDecorator extends BlockPopulator
for(IrisBiome i : generator.getDimension().getBiomes())
{
GMap<GenObjectGroup, Double> gc = new GMap<>();
int ff = 0;
for(String j : i.getSchematicGroups().k())
{
double c = i.getSchematicGroups().get(j);
@ -46,7 +49,7 @@ public class GenObjectDecorator extends BlockPopulator
try
{
GenObjectGroup g = generator.getDimension().getObjectGroup(j);
ff += g.size();
gc.put(g, c);
}
@ -60,6 +63,11 @@ public class GenObjectDecorator extends BlockPopulator
if(!gc.isEmpty())
{
populationCache.put(i, gc);
if(Iris.settings.performance.verbose)
{
L.v(C.DARK_GREEN + i.getName() + ": " + C.DARK_AQUA + F.f(ff) + " Objects");
}
}
}
}
@ -77,7 +85,7 @@ public class GenObjectDecorator extends BlockPopulator
{
int x = (source.getX() << 4) + random.nextInt(16);
int z = (source.getZ() << 4) + random.nextInt(16);
IrisBiome biome = g.getBiome(x, z);
IrisBiome biome = g.getBiome((int) g.getOffsetX(x), (int) g.getOffsetX(z));
if(hits.contains(biome))
{
@ -102,6 +110,11 @@ public class GenObjectDecorator extends BlockPopulator
{
}
if(Iris.settings.performance.verbose)
{
L.flush();
}
}
private void populate(World world, Random random, Chunk source, IrisBiome biome, GMap<GenObjectGroup, Double> objects)
@ -110,30 +123,39 @@ public class GenObjectDecorator extends BlockPopulator
{
for(int j = 0; j < getTries(objects.get(i)); j++)
{
int x = (source.getX() << 4) + random.nextInt(16);
int z = (source.getZ() << 4) + random.nextInt(16);
Block b = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
Material t = b.getType();
if(!t.isSolid() || !biome.isSurface(t))
if(M.r(Iris.settings.gen.objectDensity))
{
continue;
}
int x = (source.getX() << 4) + random.nextInt(16);
int z = (source.getZ() << 4) + random.nextInt(16);
Block b = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
Material t = b.getType();
if(placer == null)
{
if(Iris.settings.performance.fastDecoration)
if(!t.isSolid() || !biome.isSurface(t))
{
placer = new NMSPlacer(world);
continue;
}
else
if(placer == null)
{
placer = new BukkitPlacer(world, false);
if(Iris.settings.performance.fastDecoration)
{
placer = new NMSPlacer(world);
}
else
{
placer = new BukkitPlacer(world, false);
}
}
GenObject g = i.getSchematics().get(random.nextInt(i.getSchematics().size()));
Location start = g.place(x, b.getY(), z, placer);
if(start != null && Iris.settings.performance.verbose)
{
L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + g.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ()));
}
}
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(x, b.getY(), z, placer);
}
}

View File

@ -4,7 +4,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import net.md_5.bungee.api.ChatColor;
@ -196,34 +195,42 @@ public class GenObjectGroup
public void processVariants()
{
TaskExecutor te = new TaskExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Variant Processor");
TaskGroup g = te.startWork();
GList<GenObject> inject = new GList<>();
String x = Thread.currentThread().getName();
ReentrantLock rr = new ReentrantLock();
for(GenObject i : getSchematics())
{
for(Direction j : new Direction[] {Direction.S, Direction.E, Direction.W})
{
GenObject cp = i.copy();
GenObject f = cp;
f.rotate(Direction.N, j);
rr.lock();
inject.add(f);
rr.unlock();
g.queue(() ->
{
GenObject cp = i.copy();
GenObject f = cp;
f.rotate(Direction.N, j);
inject.add(f);
});
}
}
g.execute();
getSchematics().add(inject);
g = te.startWork();
for(GenObject i : getSchematics())
{
i.recalculateMountShift();
for(String j : flags)
g.queue(() ->
{
i.computeFlag(j);
}
i.recalculateMountShift();
for(String j : flags)
{
i.computeFlag(j);
}
});
}
g.execute();
te.close();
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name);
}
}

View File

@ -1,7 +1,6 @@
package ninja.bytecode.iris.generator.layer;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.RNG;

View File

@ -123,11 +123,22 @@ public class GenLayerBiome extends GenLayer
}
public IrisBiome getBiome(double wxx, double wzx)
{
return getBiome(wxx, wzx, false);
}
public IrisBiome getBiome(double wxx, double wzx, boolean real)
{
double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;
double wz = Math.round((double) wzx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;
double x = wx + (Iris.settings.gen.biomeEdgeScramble == 0 ? 0 : (fracture.noise(wz, wx) * Iris.settings.gen.biomeEdgeScramble));
double z = wz - (Iris.settings.gen.biomeEdgeScramble == 0 ? 0 : (fracture.noise(wx, wz) * Iris.settings.gen.biomeEdgeScramble));
if(real)
{
return getRegionGenerator(x, z).getChoice(x, z);
}
IrisBiome cbi = iris.biome("Ocean");
double land = island.noise(x, z);
double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D);

View File

@ -934,7 +934,6 @@ public class IrisBiome
{
final int prime = 31;
int result = 1;
result = prime * result + ((bng == null) ? 0 : bng.hashCode());
long temp;
temp = Double.doubleToLongBits(cliffChance);
result = prime * result + (int) (temp ^ (temp >>> 32));
@ -956,9 +955,6 @@ public class IrisBiome
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
result = prime * result + ((poly == null) ? 0 : poly.hashCode());
result = prime * result + ((polyRock == null) ? 0 : polyRock.hashCode());
result = prime * result + ((polySub == null) ? 0 : polySub.hashCode());
result = prime * result + ((realBiome == null) ? 0 : realBiome.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + ((rock == null) ? 0 : rock.hashCode());
@ -994,13 +990,6 @@ public class IrisBiome
if(getClass() != obj.getClass())
return false;
IrisBiome other = (IrisBiome) obj;
if(bng == null)
{
if(other.bng != null)
return false;
}
else if(!bng.equals(other.bng))
return false;
if(Double.doubleToLongBits(cliffChance) != Double.doubleToLongBits(other.cliffChance))
return false;
if(Double.doubleToLongBits(cliffScale) != Double.doubleToLongBits(other.cliffScale))
@ -1042,27 +1031,6 @@ public class IrisBiome
}
else if(!parent.equals(other.parent))
return false;
if(poly == null)
{
if(other.poly != null)
return false;
}
else if(!poly.equals(other.poly))
return false;
if(polyRock == null)
{
if(other.polyRock != null)
return false;
}
else if(!polyRock.equals(other.polyRock))
return false;
if(polySub == null)
{
if(other.polySub != null)
return false;
}
else if(!polySub.equals(other.polySub))
return false;
if(realBiome != other.realBiome)
return false;
if(region == null)

View File

@ -8,6 +8,8 @@ import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.execution.TaskExecutor;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
import ninja.bytecode.shuriken.json.JSONArray;
import ninja.bytecode.shuriken.json.JSONException;
import ninja.bytecode.shuriken.json.JSONObject;
@ -65,14 +67,21 @@ public class IrisDimension
private GList<IrisBiome> biomesFromArray(JSONArray a) throws JSONException, IOException
{
GList<IrisBiome> b = new GList<>();
TaskExecutor t = new TaskExecutor(Runtime.getRuntime().availableProcessors() * 2, Thread.MIN_PRIORITY, "Biome Loader");
TaskGroup g = t.startWork();
for(int i = 0; i < a.length(); i++)
{
int ii = i;
IrisBiome bb = Iris.getController(PackController.class).loadBiome(a.getString(ii));
Iris.getController(PackController.class).registerBiome(a.getString(ii), bb);
b.add(bb);
g.queue(() ->
{
IrisBiome bb = Iris.getController(PackController.class).loadBiome(a.getString(ii));
Iris.getController(PackController.class).registerBiome(a.getString(ii), bb);
b.add(bb);
});
}
g.execute();
t.close();
return b;
}

View File

@ -11,7 +11,6 @@ import org.bukkit.generator.ChunkGenerator;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.ExecutionController;
import ninja.bytecode.iris.controller.TimingsController;
import ninja.bytecode.shuriken.execution.ChronoLatch;
import ninja.bytecode.shuriken.execution.TaskExecutor;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskResult;
@ -29,7 +28,6 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
private TaskGroup tg;
private boolean ready = false;
int cg = 0;
private ChronoLatch cl = new ChronoLatch(1000);
private RollingSequence rs = new RollingSequence(512);
private World world;
private TaskExecutor genPool;