mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Remove inlet passage
- Delete SeaInlet, its rasterizer, space and footprint, and the old inlet probe - Keep the mantle cells, old chunk seal and cave headroom behind SealedPassage - Keep their tests on a test passage so grottos can build on them - Report tidal arm counts from the plan in the hydrology probe
This commit is contained in:
21 files changed
+315
-1681
No files matched your search
+2
-2
@@ -19,7 +19,7 @@ import art.arcane.iris.generation.hydrology.raster.ChannelFluids;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkRasterizer;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.raster.NaturalHeights;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.hydrology.underground.SealedPassage;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.hydrology.water.Pond;
|
||||
import art.arcane.iris.generation.hydrology.water.Reach;
|
||||
@@ -438,7 +438,7 @@ public final class HydrologyRuntime {
|
||||
return HydrologyFeatureSearch.channelType(settings, tier);
|
||||
}
|
||||
|
||||
public List<SeaInlet> inlets(int chunkX, int chunkZ) {
|
||||
public List<SealedPassage> passages(int chunkX, int chunkZ) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
|
||||
+10
-73
@@ -7,26 +7,26 @@ import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class SeaInletRasterizer {
|
||||
public final class PassageRasterizer {
|
||||
public static final int SHELL = 2;
|
||||
private static final int CHUNK = 16;
|
||||
private static final int GRID = CHUNK + 2 * SHELL;
|
||||
static final int NONE = Integer.MIN_VALUE;
|
||||
|
||||
public void write(SeaInlet inlet, int chunkX, int chunkZ, MantleWriter writer, String fluid, SubterrainFluid subterrain,
|
||||
public void write(SealedPassage passage, int chunkX, int chunkZ, MantleWriter writer, String fluid, SubterrainFluid subterrain,
|
||||
HistoricalChunks historical) {
|
||||
if (!touches(inlet, chunkX, chunkZ)) {
|
||||
if (!touches(passage, chunkX, chunkZ)) {
|
||||
return;
|
||||
}
|
||||
int[] floors = new int[GRID * GRID];
|
||||
int[] ceilings = new int[GRID * GRID];
|
||||
if (!shape(inlet, (chunkX << 4) - SHELL, (chunkZ << 4) - SHELL, GRID, floors, ceilings)) {
|
||||
if (!shape(passage, (chunkX << 4) - SHELL, (chunkZ << 4) - SHELL, GRID, floors, ceilings)) {
|
||||
return;
|
||||
}
|
||||
HydrologyCaveCell wet = new HydrologyCaveCell(HydrologyCaveAction.WET_SOURCE, fluid);
|
||||
HydrologyCaveCell dry = new HydrologyCaveCell(HydrologyCaveAction.DRY_AIR, fluid);
|
||||
HydrologyCaveCell guard = new HydrologyCaveCell(HydrologyCaveAction.SEAL_GUARD, fluid);
|
||||
int water = inlet.waterLevel();
|
||||
int water = passage.waterLevel();
|
||||
boolean[] historicalAround = historicalAround(chunkX, chunkZ, historical);
|
||||
for (int lz = 0; lz < CHUNK; lz++) {
|
||||
for (int lx = 0; lx < CHUNK; lx++) {
|
||||
@@ -40,8 +40,6 @@ public final class SeaInletRasterizer {
|
||||
int floor = floors[cell];
|
||||
if (floor == NONE) {
|
||||
guard(writer, x, low - SHELL, water, z, guard);
|
||||
} else if (ceilings[cell] == SeaInlet.OPEN) {
|
||||
guard(writer, x, low - SHELL, floor - 1, z, guard);
|
||||
} else if (historicalAround != null && besideHistorical(historicalAround, lx, lz)) {
|
||||
guard(writer, x, low - SHELL, ceilings[cell], z, guard);
|
||||
} else {
|
||||
@@ -76,83 +74,22 @@ public final class SeaInletRasterizer {
|
||||
boolean at(int chunkX, int chunkZ);
|
||||
}
|
||||
|
||||
public static boolean touches(SeaInlet inlet, int chunkX, int chunkZ) {
|
||||
int[] bounds = bounds(inlet);
|
||||
public static boolean touches(SealedPassage passage, int chunkX, int chunkZ) {
|
||||
int[] bounds = passage.bounds();
|
||||
int minX = chunkX << 4;
|
||||
int minZ = chunkZ << 4;
|
||||
return bounds[0] <= minX + CHUNK - 1 + SHELL && bounds[2] >= minX - SHELL && bounds[1] <= minZ + CHUNK - 1 + SHELL
|
||||
&& bounds[3] >= minZ - SHELL;
|
||||
}
|
||||
|
||||
public static int[] bounds(SeaInlet inlet) {
|
||||
float minX = inlet.chamberX() - inlet.chamberRadius();
|
||||
float minZ = inlet.chamberZ() - inlet.chamberRadius();
|
||||
float maxX = inlet.chamberX() + inlet.chamberRadius() + 1;
|
||||
float maxZ = inlet.chamberZ() + inlet.chamberRadius() + 1;
|
||||
for (int station = 0; station < inlet.stations(); station++) {
|
||||
float reach = inlet.halfWidth()[station] + 1f;
|
||||
minX = Math.min(minX, inlet.xs()[station] - reach);
|
||||
minZ = Math.min(minZ, inlet.zs()[station] - reach);
|
||||
maxX = Math.max(maxX, inlet.xs()[station] + reach);
|
||||
maxZ = Math.max(maxZ, inlet.zs()[station] + reach);
|
||||
}
|
||||
return new int[]{(int) Math.floor(minX), (int) Math.floor(minZ), (int) Math.ceil(maxX), (int) Math.ceil(maxZ)};
|
||||
}
|
||||
|
||||
public static boolean column(SeaInlet inlet, int x, int z, int[] out) {
|
||||
double px = x + 0.5D;
|
||||
double pz = z + 0.5D;
|
||||
int floor = Integer.MAX_VALUE;
|
||||
int ceiling = NONE;
|
||||
float[] xs = inlet.xs();
|
||||
float[] zs = inlet.zs();
|
||||
for (int station = 0; station + 1 < xs.length; station++) {
|
||||
double ax = xs[station];
|
||||
double az = zs[station];
|
||||
double dx = xs[station + 1] - ax;
|
||||
double dz = zs[station + 1] - az;
|
||||
double span = dx * dx + dz * dz;
|
||||
double t = span <= 0D ? 0D : Math.clamp(((px - ax) * dx + (pz - az) * dz) / span, 0D, 1D);
|
||||
double distance = Math.hypot(px - (ax + t * dx), pz - (az + t * dz));
|
||||
double half = inlet.halfWidth()[station] + t * (inlet.halfWidth()[station + 1] - inlet.halfWidth()[station]);
|
||||
if (distance > half) {
|
||||
continue;
|
||||
}
|
||||
floor = Math.min(floor, (int) Math.round(inlet.floor()[station] + t * (inlet.floor()[station + 1] - inlet.floor()[station])));
|
||||
ceiling = Math.max(ceiling, ceiling(inlet, station, t));
|
||||
}
|
||||
double radius = inlet.chamberRadius();
|
||||
double fromCentre = Math.hypot(px - inlet.chamberX(), pz - inlet.chamberZ());
|
||||
if (fromCentre <= radius) {
|
||||
int last = xs.length - 1;
|
||||
double dome = Math.sqrt(1D - (fromCentre / radius) * (fromCentre / radius));
|
||||
int water = inlet.waterLevel();
|
||||
floor = Math.min(floor, water - (int) Math.max(1L, Math.round((water - inlet.floor()[last]) * dome)));
|
||||
ceiling = Math.max(ceiling, water + (int) Math.round((inlet.ceiling()[last] - water) * dome));
|
||||
}
|
||||
if (ceiling == NONE) {
|
||||
return false;
|
||||
}
|
||||
out[0] = floor;
|
||||
out[1] = ceiling;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int ceiling(SeaInlet inlet, int station, double t) {
|
||||
if (inlet.open(station) || inlet.open(station + 1)) {
|
||||
return t <= 0.5D ? inlet.ceiling()[station] : inlet.ceiling()[station + 1];
|
||||
}
|
||||
return (int) Math.round(inlet.ceiling()[station] + t * (inlet.ceiling()[station + 1] - inlet.ceiling()[station]));
|
||||
}
|
||||
|
||||
static boolean shape(SeaInlet inlet, int originX, int originZ, int size, int[] floors, int[] ceilings) {
|
||||
static boolean shape(SealedPassage passage, int originX, int originZ, int size, int[] floors, int[] ceilings) {
|
||||
Arrays.fill(floors, NONE);
|
||||
Arrays.fill(ceilings, NONE);
|
||||
boolean any = false;
|
||||
int[] column = new int[2];
|
||||
for (int gz = 0; gz < size; gz++) {
|
||||
for (int gx = 0; gx < size; gx++) {
|
||||
if (column(inlet, originX + gx, originZ + gz, column)) {
|
||||
if (passage.column(originX + gx, originZ + gz, column)) {
|
||||
floors[gz * size + gx] = column[0];
|
||||
ceilings[gz * size + gx] = column[1];
|
||||
any = true;
|
||||
@@ -184,7 +121,7 @@ public final class SeaInletRasterizer {
|
||||
for (int dz = -SHELL; dz <= SHELL; dz++) {
|
||||
for (int dx = -SHELL; dx <= SHELL; dx++) {
|
||||
int ceiling = ceilings[(gz + dz) * GRID + gx + dx];
|
||||
if (ceiling != SeaInlet.OPEN && ceiling > water && ceiling > roof) {
|
||||
if (ceiling > water && ceiling > roof) {
|
||||
roof = ceiling;
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -3,9 +3,9 @@ package art.arcane.iris.generation.hydrology.underground;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class SeaInletSpace {
|
||||
private static final int SHELL = SeaInletRasterizer.SHELL;
|
||||
private static final int NONE = SeaInletRasterizer.NONE;
|
||||
public final class PassageSpace {
|
||||
private static final int SHELL = PassageRasterizer.SHELL;
|
||||
private static final int NONE = PassageRasterizer.NONE;
|
||||
|
||||
private final int originX;
|
||||
private final int originZ;
|
||||
@@ -13,7 +13,7 @@ public final class SeaInletSpace {
|
||||
private final int[] lows;
|
||||
private final int[] highs;
|
||||
|
||||
private SeaInletSpace(int originX, int originZ, int size, int[] lows, int[] highs) {
|
||||
private PassageSpace(int originX, int originZ, int size, int[] lows, int[] highs) {
|
||||
this.originX = originX;
|
||||
this.originZ = originZ;
|
||||
this.size = size;
|
||||
@@ -21,7 +21,7 @@ public final class SeaInletSpace {
|
||||
this.highs = highs;
|
||||
}
|
||||
|
||||
public static SeaInletSpace of(Collection<SeaInlet> inlets, int originX, int originZ, int size) {
|
||||
public static PassageSpace of(Collection<SealedPassage> passages, int originX, int originZ, int size) {
|
||||
int[] lows = new int[size * size];
|
||||
int[] highs = new int[size * size];
|
||||
Arrays.fill(lows, NONE);
|
||||
@@ -29,26 +29,26 @@ public final class SeaInletSpace {
|
||||
int grid = size + 2 * SHELL;
|
||||
int[] floors = new int[grid * grid];
|
||||
int[] ceilings = new int[grid * grid];
|
||||
for (SeaInlet inlet : inlets) {
|
||||
if (!SeaInletRasterizer.shape(inlet, originX - SHELL, originZ - SHELL, grid, floors, ceilings)) {
|
||||
for (SealedPassage passage : passages) {
|
||||
if (!PassageRasterizer.shape(passage, originX - SHELL, originZ - SHELL, grid, floors, ceilings)) {
|
||||
continue;
|
||||
}
|
||||
for (int z = 0; z < size; z++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
int cell = (z + SHELL) * grid + x + SHELL;
|
||||
int low = SeaInletRasterizer.nearby(floors, grid, cell, true);
|
||||
int low = PassageRasterizer.nearby(floors, grid, cell, true);
|
||||
if (low == NONE) {
|
||||
continue;
|
||||
}
|
||||
int column = z * size + x;
|
||||
int bottom = low - SHELL;
|
||||
int top = Math.max(inlet.waterLevel(), SeaInletRasterizer.nearby(ceilings, grid, cell, false));
|
||||
int top = Math.max(passage.waterLevel(), PassageRasterizer.nearby(ceilings, grid, cell, false));
|
||||
lows[column] = lows[column] == NONE ? bottom : Math.min(lows[column], bottom);
|
||||
highs[column] = Math.max(highs[column], top);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new SeaInletSpace(originX, originZ, size, lows, highs);
|
||||
return new PassageSpace(originX, originZ, size, lows, highs);
|
||||
}
|
||||
|
||||
public boolean contains(int x, int y, int z) {
|
||||
@@ -1,61 +0,0 @@
|
||||
package art.arcane.iris.generation.hydrology.underground;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public record SeaInlet(long id, float[] xs, float[] zs, float[] halfWidth, int waterLevel, int[] floor, int[] ceiling, int chamberX,
|
||||
int chamberZ, int chamberRadius) {
|
||||
public static final int OPEN = Integer.MAX_VALUE;
|
||||
|
||||
public SeaInlet {
|
||||
int stations = xs.length;
|
||||
if (stations < 2 || zs.length != stations || halfWidth.length != stations || floor.length != stations || ceiling.length != stations) {
|
||||
throw new IllegalArgumentException("Sea inlet " + id + " needs at least two stations and matching arrays: xs=" + xs.length
|
||||
+ " zs=" + zs.length + " halfWidth=" + halfWidth.length + " floor=" + floor.length + " ceiling=" + ceiling.length);
|
||||
}
|
||||
if (chamberRadius <= 0) {
|
||||
throw new IllegalArgumentException("Sea inlet " + id + " needs a positive chamber radius, got " + chamberRadius);
|
||||
}
|
||||
for (int station = 0; station < stations; station++) {
|
||||
if (!(halfWidth[station] > 0f) || floor[station] >= waterLevel || ceiling[station] < waterLevel) {
|
||||
throw new IllegalArgumentException("Sea inlet " + id + " station " + station + " has half-width " + halfWidth[station]
|
||||
+ ", floor " + floor[station] + " and ceiling " + ceiling[station] + " around water level " + waterLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int stations() {
|
||||
return xs.length;
|
||||
}
|
||||
|
||||
public boolean open(int station) {
|
||||
return ceiling[station] == OPEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof SeaInlet inlet && id == inlet.id && waterLevel == inlet.waterLevel && chamberX == inlet.chamberX
|
||||
&& chamberZ == inlet.chamberZ && chamberRadius == inlet.chamberRadius && Arrays.equals(xs, inlet.xs)
|
||||
&& Arrays.equals(zs, inlet.zs) && Arrays.equals(halfWidth, inlet.halfWidth) && Arrays.equals(floor, inlet.floor)
|
||||
&& Arrays.equals(ceiling, inlet.ceiling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 31 * Long.hashCode(id) + waterLevel;
|
||||
hash = 31 * hash + chamberX;
|
||||
hash = 31 * hash + chamberZ;
|
||||
hash = 31 * hash + chamberRadius;
|
||||
hash = 31 * hash + Arrays.hashCode(xs);
|
||||
hash = 31 * hash + Arrays.hashCode(zs);
|
||||
hash = 31 * hash + Arrays.hashCode(halfWidth);
|
||||
hash = 31 * hash + Arrays.hashCode(floor);
|
||||
return 31 * hash + Arrays.hashCode(ceiling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
int last = xs.length - 1;
|
||||
return "SeaInlet[id=" + id + ", stations=" + xs.length + ", mouth=" + xs[0] + "," + zs[0] + ", end=" + xs[last] + "," + zs[last]
|
||||
+ ", waterLevel=" + waterLevel + ", chamber=" + chamberX + "," + chamberZ + " r" + chamberRadius + "]";
|
||||
}
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
package art.arcane.iris.generation.hydrology.underground;
|
||||
|
||||
final class SeaInletFootprint {
|
||||
private static final byte OPEN = 1;
|
||||
private static final byte COVERED = 2;
|
||||
private static final int SHELL = SeaInletRasterizer.SHELL;
|
||||
|
||||
private final int minX;
|
||||
private final int minZ;
|
||||
private final int maxX;
|
||||
private final int maxZ;
|
||||
private final byte[] kinds;
|
||||
|
||||
private SeaInletFootprint(SeaInlet inlet) {
|
||||
int[] bounds = SeaInletRasterizer.bounds(inlet);
|
||||
this.minX = bounds[0];
|
||||
this.minZ = bounds[1];
|
||||
this.maxX = bounds[2];
|
||||
this.maxZ = bounds[3];
|
||||
this.kinds = new byte[(maxX - minX + 1) * (maxZ - minZ + 1)];
|
||||
int[] column = new int[2];
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
if (SeaInletRasterizer.column(inlet, x, z, column)) {
|
||||
kinds[index(x, z)] = column[1] == SeaInlet.OPEN ? OPEN : COVERED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static SeaInletFootprint of(SeaInlet inlet) {
|
||||
return new SeaInletFootprint(inlet);
|
||||
}
|
||||
|
||||
boolean conflicts(SeaInletFootprint other) {
|
||||
return opensBeside(this, other) || opensBeside(other, this);
|
||||
}
|
||||
|
||||
private static boolean opensBeside(SeaInletFootprint open, SeaInletFootprint covered) {
|
||||
int fromX = Math.max(open.minX, covered.minX - SHELL);
|
||||
int toX = Math.min(open.maxX, covered.maxX + SHELL);
|
||||
int fromZ = Math.max(open.minZ, covered.minZ - SHELL);
|
||||
int toZ = Math.min(open.maxZ, covered.maxZ + SHELL);
|
||||
for (int z = fromZ; z <= toZ; z++) {
|
||||
for (int x = fromX; x <= toX; x++) {
|
||||
if (open.kind(x, z) == OPEN && covered.coveredNear(x, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean coveredNear(int x, int z) {
|
||||
for (int dz = -SHELL; dz <= SHELL; dz++) {
|
||||
for (int dx = -SHELL; dx <= SHELL; dx++) {
|
||||
if (kind(x + dx, z + dz) == COVERED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private byte kind(int x, int z) {
|
||||
return x < minX || x > maxX || z < minZ || z > maxZ ? 0 : kinds[index(x, z)];
|
||||
}
|
||||
|
||||
private int index(int x, int z) {
|
||||
return (z - minZ) * (maxX - minX + 1) + x - minX;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package art.arcane.iris.generation.hydrology.underground;
|
||||
|
||||
public interface SealedPassage {
|
||||
long id();
|
||||
|
||||
int waterLevel();
|
||||
|
||||
int roofClearance();
|
||||
|
||||
int[] bounds();
|
||||
|
||||
boolean column(int x, int z, int[] out);
|
||||
}
|
||||
@@ -2,8 +2,7 @@ package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||
import art.arcane.iris.generation.hydrology.underground.SealedPassage;
|
||||
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -60,16 +59,15 @@ public final class CaveCeilingMask {
|
||||
}
|
||||
|
||||
public static long[] headroom(int chunkX, int chunkZ, HydrologyRuntime runtime, long[] bands) {
|
||||
List<SeaInlet> inlets = runtime.inlets(chunkX, chunkZ);
|
||||
if (inlets.isEmpty()) {
|
||||
List<SealedPassage> passages = runtime.passages(chunkX, chunkZ);
|
||||
if (passages.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
int roofClearance = 6;
|
||||
return fillHeadroom(chunkX, chunkZ, inlets, roofClearance, bands) ? bands : null;
|
||||
return fillHeadroom(chunkX, chunkZ, passages, bands) ? bands : null;
|
||||
}
|
||||
|
||||
static boolean fillHeadroom(int chunkX, int chunkZ, List<SeaInlet> inlets, int roofClearance, long[] bands) {
|
||||
if (inlets.isEmpty()) {
|
||||
static boolean fillHeadroom(int chunkX, int chunkZ, List<SealedPassage> passages, long[] bands) {
|
||||
if (passages.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int originX = (chunkX << 4) - CONTAINMENT;
|
||||
@@ -80,19 +78,19 @@ public final class CaveCeilingMask {
|
||||
Arrays.fill(tops, Integer.MIN_VALUE);
|
||||
int[] column = new int[2];
|
||||
boolean roofed = false;
|
||||
for (SeaInlet inlet : inlets) {
|
||||
int[] bounds = SeaInletRasterizer.bounds(inlet);
|
||||
for (SealedPassage passage : passages) {
|
||||
int[] bounds = passage.bounds();
|
||||
int fromX = Math.max(originX, bounds[0]);
|
||||
int toX = Math.min(originX + FIELD - 1, bounds[2]);
|
||||
int toZ = Math.min(originZ + FIELD - 1, bounds[3]);
|
||||
for (int z = Math.max(originZ, bounds[1]); z <= toZ; z++) {
|
||||
for (int x = fromX; x <= toX; x++) {
|
||||
if (!SeaInletRasterizer.column(inlet, x, z, column) || column[1] == SeaInlet.OPEN) {
|
||||
if (!passage.column(x, z, column)) {
|
||||
continue;
|
||||
}
|
||||
int index = (z - originZ) * FIELD + x - originX;
|
||||
bottoms[index] = Math.min(bottoms[index], inlet.waterLevel() + 1);
|
||||
tops[index] = Math.max(tops[index], column[1] + roofClearance);
|
||||
bottoms[index] = Math.min(bottoms[index], passage.waterLevel() + 1);
|
||||
tops[index] = Math.max(tops[index], column[1] + passage.roofClearance());
|
||||
roofed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.underground.CarvedTerrain;
|
||||
import art.arcane.iris.generation.hydrology.underground.CaveVoxel;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletSpace;
|
||||
import art.arcane.iris.generation.hydrology.underground.PassageSpace;
|
||||
import art.arcane.iris.generation.hydrology.underground.SealedPassage;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
@@ -49,7 +49,7 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
private final SubterrainPlanner planner;
|
||||
private final List<SubterrainPlan> features;
|
||||
private final boolean terrain3D;
|
||||
private final SeaInletSpace inlets;
|
||||
private final PassageSpace passages;
|
||||
private final MantleChunk<Matter>[] chunks;
|
||||
private final boolean[] existing;
|
||||
private final int[] surfaces = new int[SPAN * SPAN];
|
||||
@@ -71,7 +71,7 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
this.minimumY = engine.getWorld().minHeight();
|
||||
HydrologyRuntime runtime = complex.getHydrologyRuntime();
|
||||
this.caveFluids = runtime.caveFluidPolicies();
|
||||
this.inlets = SeaInletSpace.of(inlets(runtime, chunkX, chunkZ), originX, originZ, SPAN);
|
||||
this.passages = PassageSpace.of(passages(runtime, chunkX, chunkZ), originX, originZ, SPAN);
|
||||
SubterrainPlanner subterrain = complex.getSubterrainPlanner();
|
||||
List<SubterrainPlan> plans = subterrain == null || subterrain.isEmpty() ? List.of()
|
||||
: subterrain.plansForBounds(originX, originZ, originX + SPAN - 1, originZ + SPAN - 1);
|
||||
@@ -88,7 +88,7 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
@Override
|
||||
public CaveVoxel voxel(int x, int y, int z) {
|
||||
int column = column(x, z);
|
||||
if (y <= 0 || y >= height || existing(x, z) || y > surface(x, z, column) || inlets.contains(x, y, z)) {
|
||||
if (y <= 0 || y >= height || existing(x, z) || y > surface(x, z, column) || passages.contains(x, y, z)) {
|
||||
return CaveVoxel.FOREIGN;
|
||||
}
|
||||
if (planner != null && planner.sample(features, x, y + minimumY, z).owned()) {
|
||||
@@ -149,16 +149,16 @@ final class MantleCarvedTerrain implements CarvedTerrain {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Collection<SeaInlet> inlets(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
||||
Map<Long, SeaInlet> inlets = new LinkedHashMap<>();
|
||||
private static Collection<SealedPassage> passages(HydrologyRuntime runtime, int chunkX, int chunkZ) {
|
||||
Map<Long, SealedPassage> passages = new LinkedHashMap<>();
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
for (int offsetX = -1; offsetX <= 1; offsetX++) {
|
||||
for (SeaInlet inlet : runtime.inlets(chunkX + offsetX, chunkZ + offsetZ)) {
|
||||
inlets.putIfAbsent(inlet.id(), inlet);
|
||||
for (SealedPassage passage : runtime.passages(chunkX + offsetX, chunkZ + offsetZ)) {
|
||||
passages.putIfAbsent(passage.id(), passage);
|
||||
}
|
||||
}
|
||||
}
|
||||
return inlets.values();
|
||||
return passages.values();
|
||||
}
|
||||
|
||||
private int surface(int x, int z, int column) {
|
||||
|
||||
@@ -169,9 +169,9 @@ public class MantleCarvingComponent extends IrisMantleComponent {
|
||||
);
|
||||
int[] caveCeilings = CaveCeilingMask.fill(x, z, complex.getHydrologyRuntime()::raster,
|
||||
blendScratch.caveCeilingField, blendScratch.caveCeilings) ? blendScratch.caveCeilings : null;
|
||||
long[] inletHeadroom = CaveCeilingMask.headroom(x, z, complex.getHydrologyRuntime(), blendScratch.inletHeadroom);
|
||||
if (inletHeadroom != null) {
|
||||
SurfaceFluidBoundaryPlan.join(surfaceFluidBoundaries, inletHeadroom);
|
||||
long[] passageHeadroom = CaveCeilingMask.headroom(x, z, complex.getHydrologyRuntime(), blendScratch.passageHeadroom);
|
||||
if (passageHeadroom != null) {
|
||||
SurfaceFluidBoundaryPlan.join(surfaceFluidBoundaries, passageHeadroom);
|
||||
}
|
||||
CaveFluidSupportPlan fluidSupportPlan = new CaveFluidSupportPlan();
|
||||
for (WeightedProfile weightedProfile : weightedProfiles) {
|
||||
@@ -194,10 +194,10 @@ public class MantleCarvingComponent extends IrisMantleComponent {
|
||||
caveCeilings
|
||||
);
|
||||
}
|
||||
rasterizeSubterrain(writer, x, z, complex, caveCeilings, inletHeadroom);
|
||||
rasterizeSubterrain(writer, x, z, complex, caveCeilings, passageHeadroom);
|
||||
}
|
||||
|
||||
private void rasterizeSubterrain(MantleWriter writer, int chunkX, int chunkZ, IrisComplex complex, int[] caveCeilings, long[] inletHeadroom) {
|
||||
private void rasterizeSubterrain(MantleWriter writer, int chunkX, int chunkZ, IrisComplex complex, int[] caveCeilings, long[] passageHeadroom) {
|
||||
SubterrainPlanner planner = complex.getSubterrainPlanner();
|
||||
if (planner == null || planner.isEmpty()) {
|
||||
return;
|
||||
@@ -211,7 +211,7 @@ public class MantleCarvingComponent extends IrisMantleComponent {
|
||||
if (cell.solid() && !cell.room().reservedSolid()) {
|
||||
return;
|
||||
}
|
||||
if (!cell.solid() && CaveCeilingMask.masked(caveCeilings, inletHeadroom, PowerOfTwoCoordinates.packLocal16(x & 15, z & 15), y)) {
|
||||
if (!cell.solid() && CaveCeilingMask.masked(caveCeilings, passageHeadroom, PowerOfTwoCoordinates.packLocal16(x & 15, z & 15), y)) {
|
||||
return;
|
||||
}
|
||||
if (cell.solid()) {
|
||||
@@ -767,7 +767,7 @@ public class MantleCarvingComponent extends IrisMantleComponent {
|
||||
private final double[] chunkSurfaceHeightSamples = new double[CHUNK_AREA];
|
||||
private final int[] caveCeilingField = new int[CaveCeilingMask.FIELD * CaveCeilingMask.FIELD];
|
||||
private final int[] caveCeilings = new int[CHUNK_AREA];
|
||||
private final long[] inletHeadroom = new long[CHUNK_AREA];
|
||||
private final long[] passageHeadroom = new long[CHUNK_AREA];
|
||||
private final double[][] neighbourHeights = new double[NEIGHBOURS][CHUNK_AREA];
|
||||
private final Object[][] neighbourObjects = new Object[NEIGHBOURS][CHUNK_AREA];
|
||||
private final long[][] neighbourSubmerged = new long[NEIGHBOURS][4];
|
||||
|
||||
+11
-11
@@ -12,8 +12,8 @@ import art.arcane.iris.generation.hydrology.raster.FluidSeams;
|
||||
import art.arcane.iris.generation.hydrology.underground.CarvedTerrain;
|
||||
import art.arcane.iris.generation.hydrology.underground.CavePoolFiller;
|
||||
import art.arcane.iris.generation.hydrology.underground.CaveSpringPlacer;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||
import art.arcane.iris.generation.hydrology.underground.PassageRasterizer;
|
||||
import art.arcane.iris.generation.hydrology.underground.SealedPassage;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
||||
@@ -35,7 +35,7 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
private static final int CHUNK = 16;
|
||||
private static final int GRID = CHUNK + 2;
|
||||
private static final int[] SIDES = {1, -1, GRID, -GRID};
|
||||
private static final SeaInletRasterizer INLETS = new SeaInletRasterizer();
|
||||
private static final PassageRasterizer PASSAGES = new PassageRasterizer();
|
||||
|
||||
public MantleHydrologyComponent(EngineMantle engineMantle) {
|
||||
super(engineMantle, ReservedFlag.RIVER_HYDROLOGY, PRIORITY);
|
||||
@@ -84,11 +84,11 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
}
|
||||
HydrologyRuntime runtime = complex.getHydrologyRuntime();
|
||||
ChunkWaterRaster own = CaveCeilingMask.ready(runtime.raster(chunkX, chunkZ), chunkX, chunkZ);
|
||||
List<SeaInlet> inlets = runtime.inlets(chunkX, chunkZ);
|
||||
if (!inlets.isEmpty()) {
|
||||
SeaInletRasterizer.SubterrainFluid subterrain = subterrainFluid(writer, complex, chunkX, chunkZ);
|
||||
for (SeaInlet inlet : inlets) {
|
||||
INLETS.write(inlet, chunkX, chunkZ, writer, HydrologyCaveCell.SEA_FLUID, subterrain, complex::isHistoricalChunk);
|
||||
List<SealedPassage> passages = runtime.passages(chunkX, chunkZ);
|
||||
if (!passages.isEmpty()) {
|
||||
PassageRasterizer.SubterrainFluid subterrain = subterrainFluid(writer, complex, chunkX, chunkZ);
|
||||
for (SealedPassage passage : passages) {
|
||||
PASSAGES.write(passage, chunkX, chunkZ, writer, HydrologyCaveCell.SEA_FLUID, subterrain, complex::isHistoricalChunk);
|
||||
}
|
||||
}
|
||||
generateFalls(writer, complex, runtime, own, chunkX, chunkZ);
|
||||
@@ -107,14 +107,14 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private static SeaInletRasterizer.SubterrainFluid subterrainFluid(MantleWriter writer, IrisComplex complex, int chunkX, int chunkZ) {
|
||||
private static PassageRasterizer.SubterrainFluid subterrainFluid(MantleWriter writer, IrisComplex complex, int chunkX, int chunkZ) {
|
||||
SubterrainPlanner planner = complex.getSubterrainPlanner();
|
||||
if (planner == null || planner.isEmpty()) {
|
||||
return SeaInletRasterizer.SubterrainFluid.NOWHERE;
|
||||
return PassageRasterizer.SubterrainFluid.NOWHERE;
|
||||
}
|
||||
List<SubterrainPlan> plans = planner.plansForBounds(chunkX << 4, chunkZ << 4, (chunkX << 4) + 15, (chunkZ << 4) + 15);
|
||||
if (plans.isEmpty()) {
|
||||
return SeaInletRasterizer.SubterrainFluid.NOWHERE;
|
||||
return PassageRasterizer.SubterrainFluid.NOWHERE;
|
||||
}
|
||||
int minimumY = writer.getEngine().getWorld().minHeight();
|
||||
return (x, y, z) -> planner.sample(plans, x, y + minimumY, z).fluid();
|
||||
|
||||
@@ -165,7 +165,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
resolverState.complex,
|
||||
subterrainPlanner == null ? null : subterrainPlanner.chunkSampler(x, z),
|
||||
subterrain ? caveCeilings(resolverState.complex, x, z) : null,
|
||||
subterrain ? inletHeadroom(resolverState.complex, x, z) : null
|
||||
subterrain ? passageHeadroom(resolverState.complex, x, z) : null
|
||||
);
|
||||
CarveResolver carveResolver = new CarveResolver(resolutionContext);
|
||||
terrain.forEachCell(carveResolver::apply);
|
||||
@@ -263,17 +263,17 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
int minimumY = getEngine().getWorld().minHeight();
|
||||
SubterrainSurfaceMaterials materials = subterrainMaterials(planner, blockX >> 4, blockZ >> 4);
|
||||
int[] caveCeilings = caveCeilings(getComplex(), blockX >> 4, blockZ >> 4);
|
||||
long[] inletHeadroom = inletHeadroom(getComplex(), blockX >> 4, blockZ >> 4);
|
||||
long[] passageHeadroom = passageHeadroom(getComplex(), blockX >> 4, blockZ >> 4);
|
||||
MantleChunk<Matter> chunk = getEngine().getMantle().getMantle().useChunk(blockX >> 4, blockZ >> 4);
|
||||
try {
|
||||
preserveSubterrain(planner, materials, caveCeilings, inletHeadroom, minimumY, blockX, blockZ, output,
|
||||
preserveSubterrain(planner, materials, caveCeilings, passageHeadroom, minimumY, blockX, blockZ, output,
|
||||
(worldX, y, worldZ) -> HydrologyCaveStorage.getIfPresent(chunk, worldX, y, worldZ));
|
||||
} finally {
|
||||
chunk.release();
|
||||
}
|
||||
}
|
||||
|
||||
private void preserveSubterrain(SubterrainPlanner planner, SubterrainSurfaceMaterials materials, int[] caveCeilings, long[] inletHeadroom,
|
||||
private void preserveSubterrain(SubterrainPlanner planner, SubterrainSurfaceMaterials materials, int[] caveCeilings, long[] passageHeadroom,
|
||||
int minimumY, int blockX, int blockZ, Hunk<NativeBlockState> output, HydrologyCells hydrology) {
|
||||
SubterrainRasterizer.rasterize(planner, blockX >> 4, blockZ >> 4, (worldX, worldY, worldZ, cell) -> {
|
||||
int y = worldY - minimumY;
|
||||
@@ -282,7 +282,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
}
|
||||
int x = worldX & 15;
|
||||
int z = worldZ & 15;
|
||||
if (!cell.solid() && CaveCeilingMask.masked(caveCeilings, inletHeadroom, PowerOfTwoCoordinates.packLocal16(x, z), y)) {
|
||||
if (!cell.solid() && CaveCeilingMask.masked(caveCeilings, passageHeadroom, PowerOfTwoCoordinates.packLocal16(x, z), y)) {
|
||||
return;
|
||||
}
|
||||
if (hydrology.at(worldX, y, worldZ) != null) {
|
||||
@@ -310,7 +310,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
new int[CaveCeilingMask.FIELD * CaveCeilingMask.FIELD], ceilings) ? ceilings : null;
|
||||
}
|
||||
|
||||
private static long[] inletHeadroom(IrisComplex complex, int chunkX, int chunkZ) {
|
||||
private static long[] passageHeadroom(IrisComplex complex, int chunkX, int chunkZ) {
|
||||
return CaveCeilingMask.headroom(chunkX, chunkZ, complex.getHydrologyRuntime(), new long[256]);
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
CarveOwnership.Owner owner = carveOwner(hydrology, feature,
|
||||
context.terrainColumns() == null ? null : context.terrainColumns()[columnIndex], y);
|
||||
if (owner == CarveOwnership.Owner.SUBTERRAIN) {
|
||||
if (!feature.solid() && CaveCeilingMask.masked(context.caveCeilings(), context.inletHeadroom(), columnIndex, y)) {
|
||||
if (!feature.solid() && CaveCeilingMask.masked(context.caveCeilings(), context.passageHeadroom(), columnIndex, y)) {
|
||||
return;
|
||||
}
|
||||
context.output().setRaw(localX, y, localZ, SubterrainRasterizer.state(feature));
|
||||
@@ -567,7 +567,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
IrisComplex complex,
|
||||
SubterrainPlanner.ChunkSampler subterrainSampler,
|
||||
int[] caveCeilings,
|
||||
long[] inletHeadroom
|
||||
long[] passageHeadroom
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user