TODOS and tweeks
This commit is contained in:
@@ -145,7 +145,7 @@ public class SectionUpdateRouter implements ISectionWatcher {
|
||||
if ((type&WorldEngine.UPDATE_TYPE_CHILD_EXISTENCE_BIT)!=0) {
|
||||
this.childUpdateCallback.accept(section);
|
||||
}
|
||||
if ((type& UPDATE_TYPE_BLOCK_BIT)!=0) {
|
||||
if ((type&UPDATE_TYPE_BLOCK_BIT)!=0) {
|
||||
this.renderMeshGen.accept(section.key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class NodeManager {
|
||||
|
||||
var request = new SingleNodeRequest(pos);
|
||||
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.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");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -371,7 +371,7 @@ public class NodeManager {
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public class NodeManager {
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -785,7 +785,7 @@ public class NodeManager {
|
||||
this.invalidateNode(nodeId);
|
||||
|
||||
//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");
|
||||
}
|
||||
} else {
|
||||
@@ -795,7 +795,7 @@ public class NodeManager {
|
||||
this.invalidateNode(nodeId);
|
||||
}
|
||||
} 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");
|
||||
}
|
||||
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
|
||||
if (!this.watcher.watch(childPos, WorldEngine.UPDATE_FLAGS)) {
|
||||
if (!this.watcher.watch(childPos, WorldEngine.DEFAULT_UPDATE_FLAGS)) {
|
||||
throw new IllegalStateException("Failed to watch childPos");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class TestNodeManager {
|
||||
}
|
||||
|
||||
private static String[] getPrettyTypes(int msk) {
|
||||
if ((msk&~UPDATE_FLAGS)!=0) {
|
||||
if ((msk&~(DEFAULT_UPDATE_FLAGS|UPDATE_TYPE_DONT_SAVE))!=0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
String[] types = new String[Integer.bitCount(msk)];
|
||||
@@ -150,6 +150,9 @@ public class TestNodeManager {
|
||||
if ((msk&UPDATE_TYPE_CHILD_EXISTENCE_BIT)!=0) {
|
||||
types[i++] = "CHILD";
|
||||
}
|
||||
if ((msk&UPDATE_TYPE_DONT_SAVE)!=0) {
|
||||
types[i++] = "DONT_SAVE";
|
||||
}
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
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.common.world.service.VoxelIngestService;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
import me.cortex.voxy.commonImpl.WorldIdentifier;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
@@ -57,8 +59,11 @@ public abstract class MixinClientWorld {
|
||||
// block removal
|
||||
if (!updated.isAir()) return;
|
||||
|
||||
var system = ((IGetVoxyRenderSystem)(this.worldRenderer)).getVoxyRenderSystem();
|
||||
if (system == null) {
|
||||
if (!VoxyConfig.CONFIG.ingestEnabled) return;//Only ingest if setting enabled
|
||||
|
||||
var self = (World)(Object)this;
|
||||
var wi = WorldIdentifier.of(self);
|
||||
if (wi == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,17 +71,15 @@ public abstract class MixinClientWorld {
|
||||
int y = pos.getY()&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
|
||||
var world = (World)(Object)this;
|
||||
|
||||
var csp = ChunkSectionPos.from(pos);
|
||||
|
||||
var section = world.getChunk(pos).getSection(csp.getSectionY()-this.bottomSectionY);
|
||||
var lp = world.getLightingProvider();
|
||||
var section = self.getChunk(pos).getSection(csp.getSectionY()-this.bottomSectionY);
|
||||
var lp = self.getLightingProvider();
|
||||
|
||||
var blp = lp.get(LightType.BLOCK).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) {
|
||||
//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();
|
||||
int index = this.getCacheArrayIndex(key);
|
||||
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_CHILD_EXISTENCE_BIT = 2;
|
||||
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 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
|
||||
public void markDirty(WorldSection section) {
|
||||
this.markDirty(section, UPDATE_FLAGS);
|
||||
this.markDirty(section, DEFAULT_UPDATE_FLAGS);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!shouldIngestSection(section, x, y, z)) return false;
|
||||
if (engine.instanceIn == null) return false;
|
||||
|
||||
Reference in New Issue
Block a user