mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 22:32:04 +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) -> {
|
heightStream = ProceduralStream.of((x, z) -> {
|
||||||
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
||||||
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
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));
|
.contextInjecting((c,x,z)->c.getHeight().get(x, z));
|
||||||
roundedHeighteightStream = heightStream.round().waste("Rounded Height Stream")
|
roundedHeighteightStream = heightStream.round().waste("Rounded Height Stream")
|
||||||
.contextInjecting((c,x,z)->(int)Math.round(c.getHeight().get(x, z)));
|
.contextInjecting((c,x,z)->(int)Math.round(c.getHeight().get(x, z)));
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ public class IrisEngine implements Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tickRandomPlayer() {
|
private void tickRandomPlayer() {
|
||||||
|
recycle();
|
||||||
if(perSecondBudLatch.flip()) {
|
if(perSecondBudLatch.flip()) {
|
||||||
buds.set(bud.get());
|
buds.set(bud.get());
|
||||||
bud.set(0);
|
bud.set(0);
|
||||||
@@ -459,8 +460,6 @@ public class IrisEngine implements Engine {
|
|||||||
if(generated.get() == 661) {
|
if(generated.get() == 661) {
|
||||||
J.a(() -> getData().savePrefetch(this));
|
J.a(() -> getData().savePrefetch(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
recycle();
|
|
||||||
} 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);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.volmit.iris.util.context;
|
|||||||
import com.volmit.iris.engine.IrisComplex;
|
import com.volmit.iris.engine.IrisComplex;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisRegion;
|
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.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
@@ -28,6 +29,7 @@ public class ChunkContext {
|
|||||||
public ChunkContext(int x, int z, IrisComplex c, boolean cache) {
|
public ChunkContext(int x, int z, IrisComplex c, boolean cache) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
if(cache) {
|
if(cache) {
|
||||||
BurstExecutor b = MultiBurst.burst.burst();
|
BurstExecutor b = MultiBurst.burst.burst();
|
||||||
height = new ChunkedDataCache<>(b, c.getHeightStream(), x, z);
|
height = new ChunkedDataCache<>(b, c.getHeightStream(), x, z);
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package com.volmit.iris.util.context;
|
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.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.stream.ProceduralStream;
|
import com.volmit.iris.util.stream.ProceduralStream;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class ChunkedDataCache<T> {
|
public class ChunkedDataCache<T> {
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int z;
|
private final int z;
|
||||||
|
private final KSet<T> uniques;
|
||||||
private final Object[] data;
|
private final Object[] data;
|
||||||
private final boolean cache;
|
private final boolean cache;
|
||||||
private final ProceduralStream<T> stream;
|
private final ProceduralStream<T> stream;
|
||||||
@@ -21,6 +27,7 @@ public class ChunkedDataCache<T> {
|
|||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
this.uniques = cache ? new KSet<>() : null;
|
||||||
if(cache) {
|
if(cache) {
|
||||||
data = new Object[256];
|
data = new Object[256];
|
||||||
int i,j;
|
int i,j;
|
||||||
@@ -29,7 +36,11 @@ public class ChunkedDataCache<T> {
|
|||||||
int finalI = i;
|
int finalI = i;
|
||||||
for(j = 0; j < 16; j++) {
|
for(j = 0; j < 16; j++) {
|
||||||
int finalJ = 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