mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Speed up plax mgr
This commit is contained in:
parent
c420a8a686
commit
a03539ad8b
@ -197,10 +197,15 @@ public class IrisComplex implements DataProvider {
|
|||||||
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
||||||
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
||||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||||
AtomicDouble str = new AtomicDouble(1D);
|
if(engine.getDimension().hasFeatures(engine))
|
||||||
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
|
{
|
||||||
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z))));
|
AtomicDouble str = new AtomicDouble(1D);
|
||||||
return str.get();
|
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
|
||||||
|
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z))));
|
||||||
|
return str.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1D;
|
||||||
});
|
});
|
||||||
|
|
||||||
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
||||||
|
@ -162,22 +162,21 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) {
|
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) {
|
||||||
try {
|
try {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
Hunk<BlockData> blocks = vblocks;
|
|
||||||
|
|
||||||
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().getBiomeActuator().actuate(x, z, vbiomes);
|
getFramework().getBiomeActuator().actuate(x, z, vbiomes);
|
||||||
getFramework().getTerrainActuator().actuate(x, z, blocks);
|
getFramework().getTerrainActuator().actuate(x, z, vblocks);
|
||||||
getFramework().getCaveModifier().modify(x, z, blocks);
|
getFramework().getCaveModifier().modify(x, z, vblocks);
|
||||||
getFramework().getRavineModifier().modify(x, z, blocks);
|
getFramework().getRavineModifier().modify(x, z, vblocks);
|
||||||
getFramework().getPostModifier().modify(x, z, blocks);
|
getFramework().getPostModifier().modify(x, z, vblocks);
|
||||||
getFramework().getDecorantActuator().actuate(x, z, blocks);
|
getFramework().getDecorantActuator().actuate(x, z, vblocks);
|
||||||
getFramework().getEngineParallax().insertParallax(x, z, blocks);
|
getFramework().getEngineParallax().insertParallax(x, z, vblocks);
|
||||||
getFramework().getDepositModifier().modify(x, z, blocks);
|
getFramework().getDepositModifier().modify(x, z, vblocks);
|
||||||
}
|
}
|
||||||
case ISLANDS -> {
|
case ISLANDS -> {
|
||||||
getFramework().getTerrainActuator().actuate(x, z, blocks);
|
getFramework().getTerrainActuator().actuate(x, z, vblocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
|
@ -199,6 +199,11 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
IrisLock getFeatureLock();
|
IrisLock getFeatureLock();
|
||||||
|
|
||||||
default void forEachFeature(double x, double z, Consumer<IrisFeaturePositional> f) {
|
default void forEachFeature(double x, double z, Consumer<IrisFeaturePositional> f) {
|
||||||
|
if(!getEngine().getDimension().hasFeatures(getEngine()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long key = Cache.key(((int) x) >> 4, ((int) z) >> 4);
|
long key = Cache.key(((int) x) >> 4, ((int) z) >> 4);
|
||||||
|
|
||||||
for (IrisFeaturePositional ipf : getFeatureCache().compute(key, (ke, v) -> {
|
for (IrisFeaturePositional ipf : getFeatureCache().compute(key, (ke, v) -> {
|
||||||
@ -225,17 +230,13 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
|
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
synchronized (m.getFeatures()) {
|
for (IrisFeaturePositional k : m.getFeatures()) {
|
||||||
for (IrisFeaturePositional k : m.getFeatures()) {
|
if (k.shouldFilter(x, z)) {
|
||||||
if (k.shouldFilter(x, z)) {
|
pos.add(k);
|
||||||
pos.add(k);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
e.printStackTrace();
|
|
||||||
Iris.warn("Failed to read positional features in chunk " + (i + cx) + " " + (j + cz) + "(" + e.getClass().getSimpleName() + ")");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisDataManager;
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
import com.volmit.iris.engine.IrisComplex;
|
import com.volmit.iris.engine.IrisComplex;
|
||||||
import com.volmit.iris.engine.data.DataProvider;
|
import com.volmit.iris.engine.data.DataProvider;
|
||||||
import com.volmit.iris.engine.data.DirectWorldWriter;
|
import com.volmit.iris.engine.data.mca.NBTWorld;
|
||||||
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.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
@ -44,9 +44,9 @@ import java.util.function.Consumer;
|
|||||||
@SuppressWarnings("EmptyMethod")
|
@SuppressWarnings("EmptyMethod")
|
||||||
public interface IrisAccess extends Hotloadable, DataProvider {
|
public interface IrisAccess extends Hotloadable, DataProvider {
|
||||||
|
|
||||||
void directWriteMCA(World w, int x, int z, DirectWorldWriter writer, MultiBurst burst);
|
void directWriteMCA(World w, int x, int z, NBTWorld writer, MultiBurst burst);
|
||||||
|
|
||||||
void directWriteChunk(World w, int x, int z, DirectWorldWriter writer);
|
void directWriteChunk(World w, int x, int z, NBTWorld writer);
|
||||||
|
|
||||||
int getGenerated();
|
int getGenerated();
|
||||||
|
|
||||||
|
@ -343,6 +343,7 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
private final transient AtomicCache<Double> sinr = new AtomicCache<>();
|
private final transient AtomicCache<Double> sinr = new AtomicCache<>();
|
||||||
private final transient AtomicCache<Double> cosr = new AtomicCache<>();
|
private final transient AtomicCache<Double> cosr = new AtomicCache<>();
|
||||||
private final transient AtomicCache<Double> rad = new AtomicCache<>();
|
private final transient AtomicCache<Double> rad = new AtomicCache<>();
|
||||||
|
private final transient AtomicCache<Boolean> featuresUsed = new AtomicCache<>();
|
||||||
|
|
||||||
public boolean hasSky() {
|
public boolean hasSky() {
|
||||||
return getSky() != null;
|
return getSky() != null;
|
||||||
@ -511,4 +512,48 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasFeatures(DataProvider data) {
|
||||||
|
return featuresUsed.aquire(() -> {
|
||||||
|
if(getFeatures().isNotEmpty() || getSpecificFeatures().isNotEmpty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(IrisRegion i : getAllRegions(data))
|
||||||
|
{
|
||||||
|
if(i.getFeatures().isNotEmpty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(IrisObjectPlacement j : i.getObjects())
|
||||||
|
{
|
||||||
|
if(j.isVacuum())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(IrisBiome j : i.getAllBiomes(data))
|
||||||
|
{
|
||||||
|
if(j.getFeatures().isNotEmpty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(IrisObjectPlacement k : i.getObjects())
|
||||||
|
{
|
||||||
|
if(k.isVacuum())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.verbose("Not using parallax noise features (they arent used in this dimension)");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import lombok.Data;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -56,9 +57,9 @@ public class ParallaxChunkMeta {
|
|||||||
private int maxObject = -1;
|
private int maxObject = -1;
|
||||||
private int minObject = -1;
|
private int minObject = -1;
|
||||||
private int count;
|
private int count;
|
||||||
private KList<IrisFeaturePositional> features;
|
private CopyOnWriteArrayList<IrisFeaturePositional> features;
|
||||||
|
|
||||||
public ParallaxChunkMeta() {
|
public ParallaxChunkMeta() {
|
||||||
this(false, false, false, false, false, false, -1, -1, 0, new KList<>());
|
this(false, false, false, false, false, false, -1, -1, 0, new CopyOnWriteArrayList<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,6 @@ public class ParallaxRegion extends HunkRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void save() throws IOException {
|
public synchronized void save() throws IOException {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
|
||||||
blockSlice.save();
|
blockSlice.save();
|
||||||
objectSlice.save();
|
objectSlice.save();
|
||||||
entitySlice.save();
|
entitySlice.save();
|
||||||
@ -164,7 +163,6 @@ public class ParallaxRegion extends HunkRegion {
|
|||||||
updateSlice.save();
|
updateSlice.save();
|
||||||
saveMetaHunk();
|
saveMetaHunk();
|
||||||
super.save();
|
super.save();
|
||||||
Iris.debug("Saved Parallax Region " + C.AQUA + getX() + "," + getZ() + C.LIGHT_PURPLE + " in " + C.RED + Form.duration(p.getMilliseconds(), 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int unload() {
|
public int unload() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user