9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00

Tweak feature iteration

This commit is contained in:
Daniel Mills
2021-07-31 08:18:00 -04:00
parent dff88403b5
commit 302f54971d
3 changed files with 46 additions and 53 deletions

View File

@@ -205,8 +205,11 @@ public class IrisComplex implements DataProvider {
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
if (engine.getDimension().hasFeatures(engine)) {
AtomicDouble str = new AtomicDouble(1D);
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng))));
for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z))
{
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng)));
}
return str.get();
}
@@ -409,8 +412,12 @@ public class IrisComplex implements DataProvider {
}
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z));
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
-> noise.set(i.filter(x, z, noise.get(), rng)));
for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z))
{
noise.set(i.filter(x, z, noise.get(), rng));
}
return Math.min(engine.getHeight(), Math.max(noise.get(), 0));
}

View File

@@ -198,59 +198,45 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
}
}
@BlockCoordinates
default void forEachFeature(double x, double z, Consumer<IrisFeaturePositional> f) {
if (!getEngine().getDimension().hasFeatures(getEngine())) {
return;
}
for (IrisFeaturePositional ipf : forEachFeature(x, z)) {
f.accept(ipf);
}
}
@BlockCoordinates
default KList<IrisFeaturePositional> forEachFeature(double x, double z) {
synchronized (getEngine())
{
KList<IrisFeaturePositional> pos = new KList<>();
if (!getEngine().getDimension().hasFeatures(getEngine())) {
return pos;
}
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
if (i.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng())) {
pos.add(i);
}
}
int s = (int) Math.ceil(getParallaxSize() / 2D);
int i, j;
int cx = (int)x >> 4;
int cz = (int)z >> 4;
for (i = -s; i <= s; i++) {
for (j = -s; j <= s; j++) {
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
try {
for (IrisFeaturePositional k : m.getFeatures()) {
if (k.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng())) {
pos.add(k);
}
}
} catch (Throwable e) {
Iris.error("FILTER ERROR" + " AT " + (cx + i) + " " + (j + cz));
e.printStackTrace();
Iris.reportError(e);
}
}
}
KList<IrisFeaturePositional> pos = new KList<>();
if (!getEngine().getDimension().hasFeatures(getEngine())) {
return pos;
}
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
if (i.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng())) {
pos.add(i);
}
}
int s = (int) Math.ceil(getParallaxSize() / 2D);
int i, j;
int cx = (int)x >> 4;
int cz = (int)z >> 4;
for (i = -s; i <= s; i++) {
for (j = -s; j <= s; j++) {
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
try {
for (IrisFeaturePositional k : m.getFeatures()) {
if (k.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng())) {
pos.add(k);
}
}
} catch (Throwable e) {
Iris.error("FILTER ERROR" + " AT " + (cx + i) + " " + (j + cz));
e.printStackTrace();
Iris.reportError(e);
}
}
}
return pos;
}
@ChunkCoordinates