TODOS and tweeks
This commit is contained in:
@@ -154,7 +154,7 @@ public class NodeManager {
|
|||||||
|
|
||||||
var request = new SingleNodeRequest(pos);
|
var request = new SingleNodeRequest(pos);
|
||||||
int id = this.singleRequests.put(request);
|
int id = this.singleRequests.put(request);
|
||||||
this.watcher.watch(pos, WorldEngine.UPDATE_FLAGS);
|
this.watcher.watch(pos, WorldEngine.DEFAULT_UPDATE_FLAGS);
|
||||||
this.activeSectionMap.put(pos, id|NODE_TYPE_REQUEST|REQUEST_TYPE_SINGLE);
|
this.activeSectionMap.put(pos, id|NODE_TYPE_REQUEST|REQUEST_TYPE_SINGLE);
|
||||||
this.topLevelNodes.add(pos);
|
this.topLevelNodes.add(pos);
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ public class NodeManager {
|
|||||||
throw new IllegalStateException("Child pos was in a request but not in active section map");
|
throw new IllegalStateException("Child pos was in a request but not in active section map");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.watcher.unwatch(cPos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.unwatch(cPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Child pos was not being watched");
|
throw new IllegalStateException("Child pos was not being watched");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ public class NodeManager {
|
|||||||
if (this.activeSectionMap.put(cPos, requestId|NODE_TYPE_REQUEST|REQUEST_TYPE_CHILD) != -1) {
|
if (this.activeSectionMap.put(cPos, requestId|NODE_TYPE_REQUEST|REQUEST_TYPE_CHILD) != -1) {
|
||||||
throw new IllegalStateException("Child pos was already in active section tracker but was part of a request");
|
throw new IllegalStateException("Child pos was already in active section tracker but was part of a request");
|
||||||
}
|
}
|
||||||
if (!this.watcher.watch(cPos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.watch(cPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Child pos update router issue");
|
throw new IllegalStateException("Child pos update router issue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,7 +428,7 @@ public class NodeManager {
|
|||||||
if (this.activeSectionMap.put(cPos, requestId|NODE_TYPE_REQUEST|REQUEST_TYPE_CHILD) != -1) {
|
if (this.activeSectionMap.put(cPos, requestId|NODE_TYPE_REQUEST|REQUEST_TYPE_CHILD) != -1) {
|
||||||
throw new IllegalStateException("Child pos was already in active section tracker but was part of a request");
|
throw new IllegalStateException("Child pos was already in active section tracker but was part of a request");
|
||||||
}
|
}
|
||||||
if (!this.watcher.watch(cPos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.watch(cPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Child pos update router issue");
|
throw new IllegalStateException("Child pos update router issue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ public class NodeManager {
|
|||||||
if (cnid == -1 || (cnid&NODE_TYPE_MSK) != NODE_TYPE_REQUEST) {//TODO: verify the removed section is a request type of child and the request id matches this
|
if (cnid == -1 || (cnid&NODE_TYPE_MSK) != NODE_TYPE_REQUEST) {//TODO: verify the removed section is a request type of child and the request id matches this
|
||||||
throw new IllegalStateException("Child pos was in a request but not in active section map");
|
throw new IllegalStateException("Child pos was in a request but not in active section map");
|
||||||
}
|
}
|
||||||
if (!this.watcher.unwatch(cPos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.unwatch(cPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Child pos was not being watched");
|
throw new IllegalStateException("Child pos was not being watched");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -663,7 +663,7 @@ public class NodeManager {
|
|||||||
if ((cId&NODE_TYPE_MSK) != NODE_TYPE_REQUEST || (cId&REQUEST_TYPE_MSK) != REQUEST_TYPE_CHILD || (cId&NODE_ID_MSK) != reqId) {
|
if ((cId&NODE_TYPE_MSK) != NODE_TYPE_REQUEST || (cId&REQUEST_TYPE_MSK) != REQUEST_TYPE_CHILD || (cId&NODE_ID_MSK) != reqId) {
|
||||||
throw new IllegalStateException("Invalid child active state map: " + cId);
|
throw new IllegalStateException("Invalid child active state map: " + cId);
|
||||||
}
|
}
|
||||||
if (!this.watcher.unwatch(childPos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.unwatch(childPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Pos was not being watched");
|
throw new IllegalStateException("Pos was not being watched");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -785,7 +785,7 @@ public class NodeManager {
|
|||||||
this.invalidateNode(nodeId);
|
this.invalidateNode(nodeId);
|
||||||
|
|
||||||
//Unwatch position
|
//Unwatch position
|
||||||
if (!this.watcher.unwatch(pos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.unwatch(pos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Pos was not being watched");
|
throw new IllegalStateException("Pos was not being watched");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -795,7 +795,7 @@ public class NodeManager {
|
|||||||
this.invalidateNode(nodeId);
|
this.invalidateNode(nodeId);
|
||||||
}
|
}
|
||||||
} else if (type == NODE_TYPE_REQUEST) {
|
} else if (type == NODE_TYPE_REQUEST) {
|
||||||
if (!this.watcher.unwatch(pos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.unwatch(pos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Pos was not being watched");
|
throw new IllegalStateException("Pos was not being watched");
|
||||||
}
|
}
|
||||||
if ((nodeId&REQUEST_TYPE_MSK) == REQUEST_TYPE_SINGLE) {
|
if ((nodeId&REQUEST_TYPE_MSK) == REQUEST_TYPE_SINGLE) {
|
||||||
@@ -1184,7 +1184,7 @@ public class NodeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Watch and request the child node at the given position
|
//Watch and request the child node at the given position
|
||||||
if (!this.watcher.watch(childPos, WorldEngine.UPDATE_FLAGS)) {
|
if (!this.watcher.watch(childPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||||
throw new IllegalStateException("Failed to watch childPos");
|
throw new IllegalStateException("Failed to watch childPos");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class TestNodeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String[] getPrettyTypes(int msk) {
|
private static String[] getPrettyTypes(int msk) {
|
||||||
if ((msk&~UPDATE_FLAGS)!=0) {
|
if ((msk&~(DEFAULT_UPDATE_FLAGS|UPDATE_TYPE_DONT_SAVE))!=0) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
String[] types = new String[Integer.bitCount(msk)];
|
String[] types = new String[Integer.bitCount(msk)];
|
||||||
@@ -150,6 +150,9 @@ public class TestNodeManager {
|
|||||||
if ((msk&UPDATE_TYPE_CHILD_EXISTENCE_BIT)!=0) {
|
if ((msk&UPDATE_TYPE_CHILD_EXISTENCE_BIT)!=0) {
|
||||||
types[i++] = "CHILD";
|
types[i++] = "CHILD";
|
||||||
}
|
}
|
||||||
|
if ((msk&UPDATE_TYPE_DONT_SAVE)!=0) {
|
||||||
|
types[i++] = "DONT_SAVE";
|
||||||
|
}
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package me.cortex.voxy.client.mixin.minecraft;
|
package me.cortex.voxy.client.mixin.minecraft;
|
||||||
|
|
||||||
|
import me.cortex.voxy.client.config.VoxyConfig;
|
||||||
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
||||||
import me.cortex.voxy.common.world.service.VoxelIngestService;
|
import me.cortex.voxy.common.world.service.VoxelIngestService;
|
||||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||||
|
import me.cortex.voxy.commonImpl.WorldIdentifier;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
@@ -57,8 +59,11 @@ public abstract class MixinClientWorld {
|
|||||||
// block removal
|
// block removal
|
||||||
if (!updated.isAir()) return;
|
if (!updated.isAir()) return;
|
||||||
|
|
||||||
var system = ((IGetVoxyRenderSystem)(this.worldRenderer)).getVoxyRenderSystem();
|
if (!VoxyConfig.CONFIG.ingestEnabled) return;//Only ingest if setting enabled
|
||||||
if (system == null) {
|
|
||||||
|
var self = (World)(Object)this;
|
||||||
|
var wi = WorldIdentifier.of(self);
|
||||||
|
if (wi == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,17 +71,15 @@ public abstract class MixinClientWorld {
|
|||||||
int y = pos.getY()&15;
|
int y = pos.getY()&15;
|
||||||
int z = pos.getZ()&15;
|
int z = pos.getZ()&15;
|
||||||
if (x == 0 || x==15 || y==0 || y==15 || z==0||z==15) {//Update if there is a statechange on the boarder
|
if (x == 0 || x==15 || y==0 || y==15 || z==0||z==15) {//Update if there is a statechange on the boarder
|
||||||
var world = (World)(Object)this;
|
|
||||||
|
|
||||||
var csp = ChunkSectionPos.from(pos);
|
var csp = ChunkSectionPos.from(pos);
|
||||||
|
|
||||||
var section = world.getChunk(pos).getSection(csp.getSectionY()-this.bottomSectionY);
|
var section = self.getChunk(pos).getSection(csp.getSectionY()-this.bottomSectionY);
|
||||||
var lp = world.getLightingProvider();
|
var lp = self.getLightingProvider();
|
||||||
|
|
||||||
var blp = lp.get(LightType.BLOCK).getLightSection(csp);
|
var blp = lp.get(LightType.BLOCK).getLightSection(csp);
|
||||||
var slp = lp.get(LightType.SKY).getLightSection(csp);
|
var slp = lp.get(LightType.SKY).getLightSection(csp);
|
||||||
|
|
||||||
VoxelIngestService.rawIngest(system.getEngine(), section, csp.getSectionX(), csp.getSectionY(), csp.getSectionZ(), blp==null?null:blp.copy(), slp==null?null:slp.copy());
|
VoxelIngestService.rawIngest(wi, section, csp.getSectionX(), csp.getSectionY(), csp.getSectionZ(), blp==null?null:blp.copy(), slp==null?null:slp.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class ActiveSectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WorldSection acquire(long key, boolean nullOnEmpty) {
|
public WorldSection acquire(long key, boolean nullOnEmpty) {
|
||||||
|
//TODO: add optional verification check to ensure this (or other critical systems) arnt being called on the render or server thread
|
||||||
if (this.engine != null) this.engine.lastActiveTime = System.currentTimeMillis();
|
if (this.engine != null) this.engine.lastActiveTime = System.currentTimeMillis();
|
||||||
int index = this.getCacheArrayIndex(key);
|
int index = this.getCacheArrayIndex(key);
|
||||||
var cache = this.loadedSectionCache[index];
|
var cache = this.loadedSectionCache[index];
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class WorldEngine {
|
|||||||
public static final int UPDATE_TYPE_BLOCK_BIT = 1;
|
public static final int UPDATE_TYPE_BLOCK_BIT = 1;
|
||||||
public static final int UPDATE_TYPE_CHILD_EXISTENCE_BIT = 2;
|
public static final int UPDATE_TYPE_CHILD_EXISTENCE_BIT = 2;
|
||||||
public static final int UPDATE_TYPE_DONT_SAVE = 4;
|
public static final int UPDATE_TYPE_DONT_SAVE = 4;
|
||||||
public static final int UPDATE_FLAGS = UPDATE_TYPE_BLOCK_BIT | UPDATE_TYPE_CHILD_EXISTENCE_BIT;
|
public static final int DEFAULT_UPDATE_FLAGS = UPDATE_TYPE_BLOCK_BIT | UPDATE_TYPE_CHILD_EXISTENCE_BIT;
|
||||||
|
|
||||||
public interface ISectionChangeCallback {void accept(WorldSection section, int updateFlags);}
|
public interface ISectionChangeCallback {void accept(WorldSection section, int updateFlags);}
|
||||||
public interface ISectionSaveCallback {void save(WorldEngine engine, WorldSection section);}
|
public interface ISectionSaveCallback {void save(WorldEngine engine, WorldSection section);}
|
||||||
@@ -113,7 +113,7 @@ public class WorldEngine {
|
|||||||
|
|
||||||
//Marks a section as dirty, enqueuing it for saving and or render data rebuilding
|
//Marks a section as dirty, enqueuing it for saving and or render data rebuilding
|
||||||
public void markDirty(WorldSection section) {
|
public void markDirty(WorldSection section) {
|
||||||
this.markDirty(section, UPDATE_FLAGS);
|
this.markDirty(section, DEFAULT_UPDATE_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markDirty(WorldSection section, int changeState) {
|
public void markDirty(WorldSection section, int changeState) {
|
||||||
|
|||||||
@@ -200,6 +200,13 @@ public class VoxelIngestService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean rawIngest(WorldIdentifier id, ChunkSection section, int x, int y, int z, ChunkNibbleArray bl, ChunkNibbleArray sl) {
|
||||||
|
if (id == null) return false;
|
||||||
|
var engine = id.getOrCreateEngine();
|
||||||
|
if (engine == null) return false;
|
||||||
|
return rawIngest(engine, section, x, y, z, bl, sl);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean rawIngest(WorldEngine engine, ChunkSection section, int x, int y, int z, ChunkNibbleArray bl, ChunkNibbleArray sl) {
|
public static boolean rawIngest(WorldEngine engine, ChunkSection section, int x, int y, int z, ChunkNibbleArray bl, ChunkNibbleArray sl) {
|
||||||
if (!shouldIngestSection(section, x, y, z)) return false;
|
if (!shouldIngestSection(section, x, y, z)) return false;
|
||||||
if (engine.instanceIn == null) return false;
|
if (engine.instanceIn == null) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user