mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 02:29:14 +00:00
Unload mantle when not generating
This commit is contained in:
@@ -175,7 +175,8 @@ public class IrisComplex implements DataProvider {
|
||||
heightStream = ProceduralStream.of((x, z) -> {
|
||||
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
||||
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize).waste("Height Stream")
|
||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize)
|
||||
.waste("Height Stream")
|
||||
.contextInjecting((c,x,z)->c.getHeight().get(x, z));
|
||||
roundedHeighteightStream = heightStream.round().waste("Rounded Height Stream")
|
||||
.contextInjecting((c,x,z)->(int)Math.round(c.getHeight().get(x, z)));
|
||||
|
||||
@@ -147,6 +147,7 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void tickRandomPlayer() {
|
||||
recycle();
|
||||
if(perSecondBudLatch.flip()) {
|
||||
buds.set(bud.get());
|
||||
bud.set(0);
|
||||
@@ -459,8 +460,6 @@ public class IrisEngine implements Engine {
|
||||
if(generated.get() == 661) {
|
||||
J.a(() -> getData().savePrefetch(this));
|
||||
}
|
||||
|
||||
recycle();
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
fail("Failed to generate " + x + ", " + z, e);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.volmit.iris.util.context;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
@@ -28,6 +29,7 @@ public class ChunkContext {
|
||||
public ChunkContext(int x, int z, IrisComplex c, boolean cache) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
|
||||
if(cache) {
|
||||
BurstExecutor b = MultiBurst.burst.burst();
|
||||
height = new ChunkedDataCache<>(b, c.getHeightStream(), x, z);
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.volmit.iris.util.context;
|
||||
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@Data
|
||||
public class ChunkedDataCache<T> {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final KSet<T> uniques;
|
||||
private final Object[] data;
|
||||
private final boolean cache;
|
||||
private final ProceduralStream<T> stream;
|
||||
@@ -21,6 +27,7 @@ public class ChunkedDataCache<T> {
|
||||
this.cache = cache;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.uniques = cache ? new KSet<>() : null;
|
||||
if(cache) {
|
||||
data = new Object[256];
|
||||
int i,j;
|
||||
@@ -29,7 +36,11 @@ public class ChunkedDataCache<T> {
|
||||
int finalI = i;
|
||||
for(j = 0; j < 16; j++) {
|
||||
int finalJ = j;
|
||||
burst.queue(() -> data[(finalJ * 16) + finalI] = stream.get(x+ finalI, z+ finalJ));
|
||||
burst.queue(() -> {
|
||||
T t = stream.get(x+ finalI, z+ finalJ);
|
||||
data[(finalJ * 16) + finalI] = t;
|
||||
uniques.add(t);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user