diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLake.java b/src/main/java/com/volmit/iris/engine/object/IrisLake.java index a29374fd5..4dc25ed50 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLake.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLake.java @@ -22,7 +22,11 @@ import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.mantle.MantleWriter; import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.math.RNG; +import com.volmit.iris.util.matter.MatterFluidBody; +import com.volmit.iris.util.matter.slices.FluidBodyMatter; +import com.volmit.iris.util.noise.CNG; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -41,7 +45,10 @@ public class IrisLake implements IRare { private int rarity = 15; @Desc("The width style of this lake") - private IrisStyledRange width = new IrisStyledRange(6, 9, NoiseStyle.PERLIN.style()); + private IrisShapedGeneratorStyle widthStyle = new IrisShapedGeneratorStyle(NoiseStyle.PERLIN.style(), 5, 9); + + @Desc("The depth style of this lake") + private IrisShapedGeneratorStyle depthStyle = new IrisShapedGeneratorStyle(NoiseStyle.PERLIN.style(), 4, 7); @Desc("Define the shape of this lake") private IrisWorm worm = new IrisWorm(); @@ -55,6 +62,49 @@ public class IrisLake implements IRare { } public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) { + KList pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> { + }); + CNG dg = depthStyle.getGenerator().createNoCache(rng, engine.getData()); + CNG bw = widthStyle.getGenerator().createNoCache(rng, engine.getData()); + IrisPosition avg; + double ax = 0; + double ay = 0; + double az = 0; + double[] surfaces = new double[pos.size()]; + int i = 0; + for(IrisPosition p : pos) + { + surfaces[i] = engine.getComplex().getHeightStream().get(x, z); + ax += p.getX(); + ay += surfaces[i]; + az += p.getZ(); + i++; + } + + avg = new IrisPosition(ax / pos.size(), ay / pos.size(), az / pos.size()); + MatterFluidBody body = FluidBodyMatter.get(customBiome, false); + i = 0; + + for (IrisPosition p : pos) { + + double surface = surfaces[i]; + double depth = dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), p.getX(), p.getZ()) + (surface - avg.getY()); + double width = bw.fitDouble(widthStyle.getMin(), widthStyle.getMax(), p.getX(), p.getZ()); + + if(depth > 1) + { + writer.setElipsoidFunction(p.getX(), avg.getY(), p.getZ(), width, depth, width, true, (xx,yy,zz) -> { + if(yy > avg.getY()) + { + return null; + } + + return body; + }); + } + + i++; + } } }