mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
minor optimization for the mantle writer
This commit is contained in:
@@ -44,9 +44,7 @@ import lombok.Data;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static com.volmit.iris.engine.mantle.EngineMantle.AIR;
|
||||
|
||||
@@ -54,21 +52,21 @@ import static com.volmit.iris.engine.mantle.EngineMantle.AIR;
|
||||
public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
||||
private final EngineMantle engineMantle;
|
||||
private final Mantle mantle;
|
||||
private final KMap<Long, MantleChunk> cachedChunks;
|
||||
private final Map<Long, MantleChunk> cachedChunks;
|
||||
private final int radius;
|
||||
private final int x;
|
||||
private final int z;
|
||||
|
||||
public MantleWriter(EngineMantle engineMantle, Mantle mantle, int x, int z, int radius) {
|
||||
public MantleWriter(EngineMantle engineMantle, Mantle mantle, int x, int z, int radius, boolean multicore) {
|
||||
this.engineMantle = engineMantle;
|
||||
this.mantle = mantle;
|
||||
int d = radius * 2 + 1;
|
||||
this.cachedChunks = new KMap<>(d * d, 0.75f, Math.max(32, Runtime.getRuntime().availableProcessors() * 4));
|
||||
this.radius = radius;
|
||||
this.radius = radius * 2;
|
||||
int d = this.radius + 1;
|
||||
this.cachedChunks = multicore ? new KMap<>(d * d, 0.75f, Math.max(32, Runtime.getRuntime().availableProcessors() * 4)) : new HashMap<>(d * d);
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
|
||||
int r = radius / 4;
|
||||
int r = radius / 2;
|
||||
for (int i = -r; i <= r; i++) {
|
||||
for (int j = -r; j <= r; j++) {
|
||||
cachedChunks.put(Cache.key(i + x, j + z), mantle.getChunk(i + x, j + z).use());
|
||||
|
||||
@@ -176,8 +176,8 @@ public class Mantle {
|
||||
* @return the writer
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius) {
|
||||
return new MantleWriter(engineMantle, this, x, z, radius);
|
||||
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius, boolean multicore) {
|
||||
return new MantleWriter(engineMantle, this, x, z, radius, multicore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ interface MatterGenerator {
|
||||
return
|
||||
val multicore = multicore || IrisSettings.get().generator.isUseMulticoreMantle
|
||||
|
||||
mantle.write(engine.mantle, x, z, radius * 2).use { writer ->
|
||||
mantle.write(engine.mantle, x, z, radius, multicore).use { writer ->
|
||||
for (pair in components) {
|
||||
radius(x, z, pair.b, { x, z ->
|
||||
for (c in pair.a) {
|
||||
|
||||
Reference in New Issue
Block a user