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.block.data.BlockData;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.volmit.iris.engine.mantle.EngineMantle.AIR;
|
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 {
|
public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
||||||
private final EngineMantle engineMantle;
|
private final EngineMantle engineMantle;
|
||||||
private final Mantle mantle;
|
private final Mantle mantle;
|
||||||
private final KMap<Long, MantleChunk> cachedChunks;
|
private final Map<Long, MantleChunk> cachedChunks;
|
||||||
private final int radius;
|
private final int radius;
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int z;
|
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.engineMantle = engineMantle;
|
||||||
this.mantle = mantle;
|
this.mantle = mantle;
|
||||||
int d = radius * 2 + 1;
|
this.radius = radius * 2;
|
||||||
this.cachedChunks = new KMap<>(d * d, 0.75f, Math.max(32, Runtime.getRuntime().availableProcessors() * 4));
|
int d = this.radius + 1;
|
||||||
this.radius = radius;
|
this.cachedChunks = multicore ? new KMap<>(d * d, 0.75f, Math.max(32, Runtime.getRuntime().availableProcessors() * 4)) : new HashMap<>(d * d);
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
int r = radius / 4;
|
int r = radius / 2;
|
||||||
for (int i = -r; i <= r; i++) {
|
for (int i = -r; i <= r; i++) {
|
||||||
for (int j = -r; j <= r; j++) {
|
for (int j = -r; j <= r; j++) {
|
||||||
cachedChunks.put(Cache.key(i + x, j + z), mantle.getChunk(i + x, j + z).use());
|
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
|
* @return the writer
|
||||||
*/
|
*/
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius) {
|
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius, boolean multicore) {
|
||||||
return new MantleWriter(engineMantle, this, x, z, radius);
|
return new MantleWriter(engineMantle, this, x, z, radius, multicore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ interface MatterGenerator {
|
|||||||
return
|
return
|
||||||
val multicore = multicore || IrisSettings.get().generator.isUseMulticoreMantle
|
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) {
|
for (pair in components) {
|
||||||
radius(x, z, pair.b, { x, z ->
|
radius(x, z, pair.b, { x, z ->
|
||||||
for (c in pair.a) {
|
for (c in pair.a) {
|
||||||
|
|||||||
Reference in New Issue
Block a user