mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Share carve ownership rule
- Add CarveOwnership, ranking hydrology over subterrain over transformed over natural - Resolve IrisCarveModifier cell ownership through IrisCarveModifier.carveOwner and CarveOwnership - Let hydrology win over subterrain rooms and transformed columns in MantleWriter isCarved and isPrerequisiteCarved - Check subterrain rooms in EngineMantle.isCarved and let hydrology win over transformed columns - Add CarveOwnershipTest running every reader over every flag combination
This commit is contained in:
1 parent
6f38d98e9e
commit
ccd5551854
6 files changed
+247
-52
No files matched your search
@@ -0,0 +1,23 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
public final class CarveOwnership {
|
||||
private CarveOwnership() {
|
||||
}
|
||||
|
||||
public static Owner resolve(boolean hydrology, boolean subterrain, boolean transformed) {
|
||||
if (hydrology) {
|
||||
return Owner.HYDROLOGY;
|
||||
}
|
||||
if (subterrain) {
|
||||
return Owner.SUBTERRAIN;
|
||||
}
|
||||
return transformed ? Owner.TRANSFORMED : Owner.NATURAL;
|
||||
}
|
||||
|
||||
public enum Owner {
|
||||
HYDROLOGY,
|
||||
SUBTERRAIN,
|
||||
TRANSFORMED,
|
||||
NATURAL
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.Terrain3DColumn;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveStorage;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||
import art.arcane.iris.pack.value.IrisPosition;
|
||||
import art.arcane.iris.generation.block.BoundBlockState;
|
||||
import art.arcane.iris.world.storage.matter.PreObjectMatterCell;
|
||||
@@ -123,16 +124,16 @@ public interface EngineMantle extends MatterGenerator {
|
||||
}
|
||||
|
||||
default boolean isCarved(int x, int h, int z) {
|
||||
Terrain3DColumn transformed = getComplex().transformedColumn(x, z);
|
||||
if (transformed != null) {
|
||||
return h >= 0 && h < transformed.topY() && !transformed.isSolid(h);
|
||||
}
|
||||
HydrologyCaveCell hydrology = HydrologyCaveStorage.getIfPresent(getMantle(), x, h, z);
|
||||
if (hydrology != null) {
|
||||
return hydrology.carves();
|
||||
}
|
||||
return getMantle().get(x, h, z, MatterCavern.class) != null
|
||||
|| getComplex().isTerrain3DOpening(x, h, z);
|
||||
SubterrainCell feature = getEngine().getSubterrainCell(x, h, z);
|
||||
Terrain3DColumn transformed = getComplex().transformedColumn(x, z);
|
||||
return switch (CarveOwnership.resolve(hydrology != null, feature != null && feature.owned(), transformed != null)) {
|
||||
case HYDROLOGY -> hydrology.carves();
|
||||
case SUBTERRAIN -> feature.carve();
|
||||
case TRANSFORMED -> h >= 0 && h < transformed.topY() && !transformed.isSolid(h);
|
||||
case NATURAL -> getMantle().get(x, h, z, MatterCavern.class) != null
|
||||
|| getComplex().isTerrain3DOpening(x, h, z);
|
||||
};
|
||||
}
|
||||
|
||||
default NativeBlockState get(int x, int y, int z) {
|
||||
|
||||
@@ -460,20 +460,16 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
}
|
||||
|
||||
public boolean isPrerequisiteCarved(int x, int y, int z) {
|
||||
SubterrainCell feature = getEngine().getSubterrainCell(x, y, z);
|
||||
if (feature != null && feature.owned()) {
|
||||
return feature.carve();
|
||||
}
|
||||
Terrain3DColumn transformed = engineMantle.getComplex().transformedColumn(x, z);
|
||||
if (transformed != null) {
|
||||
return y >= 0 && y < transformed.topY() && !transformed.isSolid(y);
|
||||
}
|
||||
HydrologyCaveCell hydrology = getPrerequisiteDataIfPresent(x, y, z, HydrologyCaveCell.class);
|
||||
if (hydrology != null) {
|
||||
return hydrology.carves();
|
||||
}
|
||||
return getPrerequisiteDataIfPresent(x, y, z, MatterCavern.class) != null
|
||||
|| engineMantle.getComplex().isTerrain3DOpening(x, y, z);
|
||||
SubterrainCell feature = getEngine().getSubterrainCell(x, y, z);
|
||||
Terrain3DColumn transformed = engineMantle.getComplex().transformedColumn(x, z);
|
||||
return switch (CarveOwnership.resolve(hydrology != null, feature != null && feature.owned(), transformed != null)) {
|
||||
case HYDROLOGY -> hydrology.carves();
|
||||
case SUBTERRAIN -> feature.carve();
|
||||
case TRANSFORMED -> y >= 0 && y < transformed.topY() && !transformed.isSolid(y);
|
||||
case NATURAL -> getPrerequisiteDataIfPresent(x, y, z, MatterCavern.class) != null
|
||||
|| engineMantle.getComplex().isTerrain3DOpening(x, y, z);
|
||||
};
|
||||
}
|
||||
|
||||
public byte[] getPrerequisiteCarvedColumn(int x, int z, int height) {
|
||||
@@ -820,20 +816,16 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
SubterrainCell feature = getEngine().getSubterrainCell(x, y, z);
|
||||
if (feature != null && feature.owned()) {
|
||||
return feature.carve();
|
||||
}
|
||||
Terrain3DColumn transformed = engineMantle.getComplex().transformedColumn(x, z);
|
||||
if (transformed != null) {
|
||||
return y >= 0 && y < transformed.topY() && !transformed.isSolid(y);
|
||||
}
|
||||
HydrologyCaveCell hydrology = getDataIfPresent(x, y, z, HydrologyCaveCell.class);
|
||||
if (hydrology != null) {
|
||||
return hydrology.carves();
|
||||
}
|
||||
return getDataIfPresent(x, y, z, MatterCavern.class) != null
|
||||
|| engineMantle.getComplex().isTerrain3DOpening(x, y, z);
|
||||
SubterrainCell feature = getEngine().getSubterrainCell(x, y, z);
|
||||
Terrain3DColumn transformed = engineMantle.getComplex().transformedColumn(x, z);
|
||||
return switch (CarveOwnership.resolve(hydrology != null, feature != null && feature.owned(), transformed != null)) {
|
||||
case HYDROLOGY -> hydrology.carves();
|
||||
case SUBTERRAIN -> feature.carve();
|
||||
case TRANSFORMED -> y >= 0 && y < transformed.topY() && !transformed.isSolid(y);
|
||||
case NATURAL -> getDataIfPresent(x, y, z, MatterCavern.class) != null
|
||||
|| engineMantle.getComplex().isTerrain3DOpening(x, y, z);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.iris.generation.runtime.EngineAssignedModifier;
|
||||
import art.arcane.iris.generation.mantle.CarveOwnership;
|
||||
import art.arcane.iris.generation.mantle.CaveCeilingMask;
|
||||
import art.arcane.iris.generation.mantle.CaveTerrainSnapshot;
|
||||
import art.arcane.iris.generation.mantle.TerrainMatterView;
|
||||
@@ -379,8 +380,12 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
return cavern.getLiquid() == 3 ? air : null;
|
||||
}
|
||||
|
||||
static boolean subterrainOwns(SubterrainCell feature, HydrologyCaveCell hydrology) {
|
||||
return hydrology == null && feature.owned() && (!feature.solid() || feature.room().reservedSolid());
|
||||
public static CarveOwnership.Owner carveOwner(HydrologyCaveCell hydrology, SubterrainCell feature, Terrain3DColumn terrain, int y) {
|
||||
return CarveOwnership.resolve(
|
||||
hydrology != null,
|
||||
feature.owned() && (!feature.solid() || feature.room().reservedSolid()),
|
||||
terrain != null && y >= terrain.minY() && y < terrain.topY() && !terrain.isSolid(y)
|
||||
);
|
||||
}
|
||||
|
||||
static NativeBlockState sealGuardState(NativeBlockState current, NativeBlockState rock) {
|
||||
@@ -473,7 +478,9 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
SubterrainCell feature = context.subterrainSampler() == null ? SubterrainCell.OUTSIDE
|
||||
: context.subterrainSampler().sampleCandidates(context.chunkBlockX() + localX, y + context.minimumY(),
|
||||
context.chunkBlockZ() + localZ);
|
||||
if (subterrainOwns(feature, hydrology)) {
|
||||
CarveOwnership.Owner owner = carveOwner(hydrology, feature,
|
||||
context.terrainColumns() == null ? null : context.terrainColumns()[columnIndex], y);
|
||||
if (owner == CarveOwnership.Owner.SUBTERRAIN) {
|
||||
if (!feature.solid() && context.caveCeilings() != null && y > context.caveCeilings()[columnIndex]) {
|
||||
return;
|
||||
}
|
||||
@@ -495,13 +502,10 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState current = context.output().getRaw(localX, y, localZ);
|
||||
if (hydrology == null && context.terrainColumns() != null) {
|
||||
Terrain3DColumn column = context.terrainColumns()[columnIndex];
|
||||
if (column != null && y >= column.minY() && y < column.topY() && !column.isSolid(y)) {
|
||||
return;
|
||||
}
|
||||
if (owner == CarveOwnership.Owner.TRANSFORMED) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState current = context.output().getRaw(localX, y, localZ);
|
||||
if (hydrology != null && hydrology.action() == HydrologyCaveAction.SEAL_GUARD) {
|
||||
NativeBlockState sealed = sealGuardState(current, context.chunkContext().getRock().get(localX, localZ));
|
||||
if (sealed != current) {
|
||||
|
||||
Reference in new issue
Block a user