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

@ -138,7 +138,7 @@ public class IrisBoardManager implements BoardProvider, Listener {
if (engine != null) {
v.add("&7&m------------------");
KList<IrisFeaturePositional> f = new KList<>();
engine.getFramework().getEngineParallax().forEachFeature(x, z, f::add);
f.add(engine.getFramework().getEngineParallax().forEachFeature(x, z));
v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight());
v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName());

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