This commit is contained in:
cyberpwn
2021-08-28 21:50:50 -04:00
parent faf5bcb32b
commit dd0b4f27d4
49 changed files with 271 additions and 444 deletions

View File

@@ -82,7 +82,7 @@ public class IrisPosition {
}
public boolean isLongerThan(IrisPosition s, int maxLength) {
return Math.abs(Math.pow(s.x - x,2) + Math.pow(s.y - y,2) + Math.pow(s.z - z,2)) > maxLength * maxLength;
return Math.abs(Math.pow(s.x - x, 2) + Math.pow(s.y - y, 2) + Math.pow(s.z - z, 2)) > maxLength * maxLength;
}
public Vector toVector() {

View File

@@ -59,50 +59,37 @@ public class IrisCarving {
@BlockCoordinates
public void doCarving(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
if(caves.isNotEmpty())
{
for(IrisCavePlacer i : caves)
{
if (caves.isNotEmpty()) {
for (IrisCavePlacer i : caves) {
i.generateCave(writer, rng, engine, x, y, z);
}
}
if(ravines.isNotEmpty())
{
for(IrisRavinePlacer i : ravines)
{
if (ravines.isNotEmpty()) {
for (IrisRavinePlacer i : ravines) {
i.generateRavine(writer, rng, engine, x, y, z);
}
}
if(spheres.isNotEmpty())
{
for(IrisSphere i : spheres)
{
if(rng.nextInt(i.getRarity()) == 0)
{
if (spheres.isNotEmpty()) {
for (IrisSphere i : spheres) {
if (rng.nextInt(i.getRarity()) == 0) {
i.generate(rng, engine, writer, x, y, z);
}
}
}
if(elipsoids.isNotEmpty())
{
for(IrisElipsoid i : elipsoids)
{
if(rng.nextInt(i.getRarity()) == 0)
{
if (elipsoids.isNotEmpty()) {
for (IrisElipsoid i : elipsoids) {
if (rng.nextInt(i.getRarity()) == 0) {
i.generate(rng, engine, writer, x, y, z);
}
}
}
if(pyramids.isNotEmpty())
{
for(IrisPyramid i : pyramids)
{
if(rng.nextInt(i.getRarity()) == 0)
{
if (pyramids.isNotEmpty()) {
for (IrisPyramid i : pyramids) {
if (rng.nextInt(i.getRarity()) == 0) {
i.generate(rng, engine, writer, x, y, z);
}
}
@@ -112,23 +99,19 @@ public class IrisCarving {
public int getMaxRange(IrisData data) {
int max = 0;
for(IrisCavePlacer i : caves)
{
for (IrisCavePlacer i : caves) {
max = Math.max(max, i.getSize(data));
}
if(elipsoids.isNotEmpty())
{
if (elipsoids.isNotEmpty()) {
max = (int) Math.max(elipsoids.stream().mapToDouble(IrisElipsoid::maxSize).max().getAsDouble(), max);
}
if(spheres.isNotEmpty())
{
if (spheres.isNotEmpty()) {
max = (int) Math.max(spheres.stream().mapToDouble(IrisSphere::maxSize).max().getAsDouble(), max);
}
if(pyramids.isNotEmpty())
{
if (pyramids.isNotEmpty()) {
max = (int) Math.max(pyramids.stream().mapToDouble(IrisPyramid::maxSize).max().getAsDouble(), max);
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.engine.object.carving;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
@@ -26,14 +25,9 @@ import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.engine.object.basic.IrisRange;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.engine.object.noise.IrisWorm;
import com.volmit.iris.engine.object.objects.IrisObjectLimit;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterCavern;
@@ -44,9 +38,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@@ -83,9 +74,9 @@ public class IrisCave extends IrisRegistrant {
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
writer.setLine(getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z,
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
}
@Override

View File

@@ -74,8 +74,7 @@ public class IrisCavePlacer implements IRare {
return;
}
if(rng.nextInt(rarity) != 0)
{
if (rng.nextInt(rarity) != 0) {
return;
}
@@ -88,20 +87,15 @@ public class IrisCavePlacer implements IRare {
return;
}
if(y == -1)
{
int h = (int) caveStartHeight.get(rng,x, z,data);
int ma = breakSurface ? h : (int) (engine.getComplex().getHeightStream().get(x, z) - 9);
if (y == -1) {
int h = (int) caveStartHeight.get(rng, x, z, data);
int ma = breakSurface ? h : (int) (engine.getComplex().getHeightStream().get(x, z) - 9);
y = Math.min(h, ma);
}
try
{
try {
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15));
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
fail.set(true);
}

View File

@@ -26,7 +26,6 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.engine.object.noise.IrisStyledRange;
@@ -38,8 +37,7 @@ import lombok.Data;
@Desc("Represents an procedural eliptical shape")
@Data
public class IrisElipsoid implements IRare
{
public class IrisElipsoid implements IRare {
@Required
@Desc("Typically a 1 in RARITY on a per fork basis")
@MinNumber(1)
@@ -60,8 +58,7 @@ public class IrisElipsoid implements IRare
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
@SuppressWarnings("SuspiciousNameCombination")
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z)
{
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
writer.setElipsoid(x, y, z,
xRadius.get(rng, z, y, engine.getData()),
yRadius.get(rng, x, z, engine.getData()),

View File

@@ -26,7 +26,6 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.engine.object.noise.IrisStyledRange;
@@ -38,8 +37,7 @@ import lombok.Data;
@Desc("Represents an procedural eliptical shape")
@Data
public class IrisPyramid implements IRare
{
public class IrisPyramid implements IRare {
@Required
@Desc("Typically a 1 in RARITY on a per fork basis")
@MinNumber(1)
@@ -53,10 +51,10 @@ public class IrisPyramid implements IRare
private IrisStyledRange baseWidth = new IrisStyledRange(1, 5, new IrisGeneratorStyle(NoiseStyle.STATIC));
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z)
{
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
writer.setPyramid(x, y, z, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())),
(int)baseWidth.get(rng, z, y, engine.getData()), true);
(int) baseWidth.get(rng, z, y, engine.getData()), true);
}
public double maxSize() {

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.engine.object.carving;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
@@ -29,7 +28,6 @@ import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.engine.object.basic.IrisRange;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.noise.IrisShapedGeneratorStyle;
import com.volmit.iris.engine.object.noise.IrisWorm;
@@ -89,6 +87,7 @@ public class IrisRavine extends IrisRegistrant {
private double ribThickness = 3;
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
@Override
public String getFolderName() {
return "ravines";
@@ -101,36 +100,32 @@ public class IrisRavine extends IrisRegistrant {
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {});
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {
});
CNG dg = depthStyle.getGenerator().createNoCache(rng, engine.getData());
CNG bw = baseWidthStyle.getGenerator().createNoCache(rng, engine.getData());
if(pos.size() < nodeThreshold)
{
if (pos.size() < nodeThreshold) {
return;
}
for(IrisPosition p : pos)
{
for (IrisPosition p : pos) {
int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y;
int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), p.getX(), p.getZ()));
int width = (int) Math.round(bw.fitDouble(baseWidthStyle.getMin(), baseWidthStyle.getMax(), p.getX(), p.getZ()));
int surface = (int) Math.round(rsurface - depth * 0.45);
fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface-depth, surface), p.getZ());
fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface - depth, surface), p.getZ());
for(int i = surface + depth; i >= surface; i--)
{
if(i % ribThickness == 0) {
for (int i = surface + depth; i >= surface; i--) {
if (i % ribThickness == 0) {
double v = width + ((((surface + depth) - i) * (angle / 360D)));
if(v <= 0.25)
{
if (v <= 0.25) {
break;
}
if(i <= ribThickness+2)
{
if (i <= ribThickness + 2) {
break;
}
@@ -138,18 +133,15 @@ public class IrisRavine extends IrisRegistrant {
}
}
for(int i = surface - depth; i <= surface; i++)
{
if(i % ribThickness == 0) {
for (int i = surface - depth; i <= surface; i++) {
if (i % ribThickness == 0) {
double v = width - ((((surface - depth) - i) * (angle / 360D)));
if(v <= 0.25)
{
if (v <= 0.25) {
break;
}
if(i <= ribThickness+2)
{
if (i <= ribThickness + 2) {
break;
}

View File

@@ -28,9 +28,6 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.engine.object.noise.IrisStyledRange;
import com.volmit.iris.engine.object.noise.NoiseStyle;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -68,8 +65,7 @@ public class IrisRavinePlacer implements IRare {
return;
}
if(rng.nextInt(rarity) != 0)
{
if (rng.nextInt(rarity) != 0) {
return;
}
@@ -82,15 +78,11 @@ public class IrisRavinePlacer implements IRare {
return;
}
try
{
try {
int xx = x + rng.nextInt(15);
int zz = z + rng.nextInt(15);
ravine.generate(mantle, rng, engine, xx, y, zz);
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
fail.set(true);
}

View File

@@ -26,7 +26,6 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.engine.object.noise.IrisStyledRange;
@@ -38,8 +37,7 @@ import lombok.Data;
@Desc("Represents an procedural eliptical shape")
@Data
public class IrisSphere implements IRare
{
public class IrisSphere implements IRare {
@Required
@Desc("Typically a 1 in RARITY on a per fork basis")
@MinNumber(1)
@@ -53,9 +51,9 @@ public class IrisSphere implements IRare
private IrisStyledRange radius = new IrisStyledRange(1, 5, new IrisGeneratorStyle(NoiseStyle.STATIC));
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z)
{
writer.setSphere(x, y, z, radius.get(rng, z, y, engine.getData()),true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
writer.setSphere(x, y, z, radius.get(rng, z, y, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
}
public double maxSize() {

View File

@@ -27,7 +27,6 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.common.CaveResult;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.object.spawners.IrisSpawner;
import com.volmit.iris.util.collection.KList;
@@ -87,7 +86,7 @@ public class IrisEntitySpawn implements IRare {
IrisComplex comp = gen.getComplex();
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
KList<Location> r = new KList<>();
r.add( new Location(c.getWorld(), x, hf + 1, z)); // TODO CAVE HEIGHT
r.add(new Location(c.getWorld(), x, hf + 1, z)); // TODO CAVE HEIGHT
yield r.getRandom(rng);
}

View File

@@ -75,8 +75,7 @@ public class IrisGeneratorStyle {
return this;
}
public CNG createNoCache(RNG rng, IrisData data)
{
public CNG createNoCache(RNG rng, IrisData data) {
if (getExpression() != null) {
IrisExpression e = data.getExpressionLoader().load(getExpression());

View File

@@ -18,16 +18,13 @@
package com.volmit.iris.engine.object.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.engine.object.basic.IrisRange;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.function.NoiseProvider;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import lombok.AllArgsConstructor;
@@ -65,8 +62,7 @@ public class IrisWorm {
private IrisStyledRange girth = new IrisStyledRange().setMin(3).setMax(5)
.setStyle(new IrisGeneratorStyle(NoiseStyle.PERLIN));
public KList<IrisPosition> generate(RNG rng, IrisData data, MantleWriter writer, IrisRange verticalRange, int x, int y, int z, Consumer<IrisPosition> fork)
{
public KList<IrisPosition> generate(RNG rng, IrisData data, MantleWriter writer, IrisRange verticalRange, int x, int y, int z, Consumer<IrisPosition> fork) {
int itr = maxIterations;
double jx, jy, jz;
double cx = x;
@@ -79,14 +75,12 @@ public class IrisWorm {
CNG gy = xStyle.getGenerator().createNoCache(new RNG(rng.lmax()), data);
CNG gz = xStyle.getGenerator().createNoCache(new RNG(rng.lmax()), data);
while(itr-- > 0)
{
while (itr-- > 0) {
IrisPosition current = new IrisPosition(Math.round(cx), Math.round(cy), Math.round(cz));
fork.accept(current);
pos.add(current);
if(check != null)
{
if (check != null) {
check.add(current);
}
@@ -98,23 +92,19 @@ public class IrisWorm {
cz += jz;
IrisPosition next = new IrisPosition(Math.round(cx), Math.round(cy), Math.round(cz));
if(verticalRange != null && !verticalRange.contains(next.getY()))
{
if (verticalRange != null && !verticalRange.contains(next.getY())) {
break;
}
if(!writer.isWithin((int)Math.round(cx), verticalRange != null ? (int)Math.round(cy) : 5, (int)Math.round(cz)))
{
if (!writer.isWithin((int) Math.round(cx), verticalRange != null ? (int) Math.round(cy) : 5, (int) Math.round(cz))) {
break;
}
if(next.isLongerThan(start, maxDistance))
{
if (next.isLongerThan(start, maxDistance)) {
break;
}
if(check != null && check.contains(next))
{
if (check != null && check.contains(next)) {
break;
}
}

View File

@@ -464,8 +464,7 @@ public class IrisObject extends IrisRegistrant {
if (yv < 0) {
if (config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) {
y = (c != null ? c.getSurface() : placer.getHighest(x, z, getLoader(), config.isUnderwater())) + rty;
if(placer.isCarved(x, y, z) || placer.isCarved(x, y-1, z))
{
if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z)) {
bail = true;
}
} else if (config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
@@ -476,8 +475,7 @@ public class IrisObject extends IrisRegistrant {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j))
{
if (placer.isCarved(i, h, j)) {
bail = true;
break;
}
@@ -495,8 +493,7 @@ public class IrisObject extends IrisRegistrant {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j))
{
if (placer.isCarved(i, h, j)) {
bail = true;
break;
}
@@ -514,8 +511,7 @@ public class IrisObject extends IrisRegistrant {
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j))
{
if (placer.isCarved(i, h, j)) {
bail = true;
break;
}
@@ -532,8 +528,7 @@ public class IrisObject extends IrisRegistrant {
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j))
{
if (placer.isCarved(i, h, j)) {
bail = true;
break;
}
@@ -544,15 +539,13 @@ public class IrisObject extends IrisRegistrant {
}
} else if (config.getMode().equals(ObjectPlaceMode.PAINT)) {
y = placer.getHighest(x, z, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(x, y, z))
{
if (placer.isCarved(x, y, z)) {
bail = true;
}
}
} else {
y = yv;
if(placer.isCarved(x, y, z))
{
if (placer.isCarved(x, y, z)) {
bail = true;
}
}
@@ -562,8 +555,7 @@ public class IrisObject extends IrisRegistrant {
bail = placer.isCarved(x, y, z);
}
if(bail)
{
if (bail) {
return -1;
}