mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Precache height
This commit is contained in:
parent
2283f1ddc9
commit
4a3ac17a2f
@ -19,6 +19,7 @@
|
|||||||
package com.volmit.iris.engine;
|
package com.volmit.iris.engine;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.engine.framework.*;
|
import com.volmit.iris.engine.framework.*;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
@ -26,7 +27,11 @@ import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
|||||||
import com.volmit.iris.engine.object.IrisDecorator;
|
import com.volmit.iris.engine.object.IrisDecorator;
|
||||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||||
import com.volmit.iris.engine.parallel.BurstExecutor;
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
@ -162,27 +167,25 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
try {
|
try {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
|
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
|
||||||
|
|
||||||
// This is a very weird optimization, but it works
|
|
||||||
// Basically we precache multicore the biome stream which effectivley
|
|
||||||
// makes the biome stream, interpolation & noise engine run in parallel without mca
|
|
||||||
BurstExecutor b = burst().burst(16);
|
BurstExecutor b = burst().burst(16);
|
||||||
|
PrecisionStopwatch px = PrecisionStopwatch.start();
|
||||||
for (int i = 0; i < vblocks.getWidth(); i++) {
|
for (int i = 0; i < vblocks.getWidth(); i++) {
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
b.queue(() -> {
|
b.queue(() -> {
|
||||||
for (int j = 0; j < vblocks.getDepth(); j++) {
|
for (int j = 0; j < vblocks.getDepth(); j++) {
|
||||||
getFramework().getComplex().getTrueBiomeStream().get(x + finalI, z + j);
|
getFramework().getComplex().getTrueBiomeStream().get(x + finalI, z + j);
|
||||||
|
getFramework().getComplex().getTrueHeightStream().get(x + finalI, z + j);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
b.complete();
|
b.complete();
|
||||||
|
getMetrics().getPrecache().put(px.getMilliseconds());
|
||||||
|
|
||||||
switch (getDimension().getTerrainMode()) {
|
switch (getDimension().getTerrainMode()) {
|
||||||
case NORMAL -> {
|
case NORMAL -> {
|
||||||
getFramework().getEngineParallax().generateParallaxArea(x >> 4, z >> 4);
|
getFramework().getEngineParallax().generateParallaxArea(x >> 4, z >> 4);
|
||||||
getFramework().getTerrainActuator().actuate(x, z, vblocks);
|
getFramework().getTerrainActuator().actuate(x, z, vblocks.synchronize());
|
||||||
getFramework().getBiomeActuator().actuate(x, z, vbiomes);
|
getFramework().getBiomeActuator().actuate(x, z, vbiomes);
|
||||||
getFramework().getCaveModifier().modify(x, z, vblocks);
|
getFramework().getCaveModifier().modify(x, z, vblocks);
|
||||||
getFramework().getRavineModifier().modify(x, z, vblocks);
|
getFramework().getRavineModifier().modify(x, z, vblocks);
|
||||||
@ -196,6 +199,22 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
|
|
||||||
|
if(IrisSettings.get().getGeneral().isDebug())
|
||||||
|
{
|
||||||
|
KList<String> v = new KList<>();
|
||||||
|
KMap<String, Double> g = getMetrics().pull();
|
||||||
|
|
||||||
|
for(String i : g.sortKNumber())
|
||||||
|
{
|
||||||
|
if(g.get(i) != null)
|
||||||
|
{
|
||||||
|
v.add(C.RESET + "" + C.LIGHT_PURPLE + i + ": " + C.UNDERLINE + C.BLUE + Form.duration(g.get(i), 0) + C.RESET + C.GRAY + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.debug(v.toString(", "));
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
fail("Failed to generate " + x + ", " + z, e);
|
fail("Failed to generate " + x + ", " + z, e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user