This commit is contained in:
mcrcortex
2024-08-06 22:57:15 +10:00
parent cd3b40399c
commit 377c51f365
5 changed files with 42 additions and 11 deletions

View File

@@ -24,7 +24,7 @@ public class VoxyConfig {
public boolean enabled = true; public boolean enabled = true;
public boolean ingestEnabled = true; public boolean ingestEnabled = true;
public int renderDistance = 128;//Unused at the present public int renderDistance = 128;
public int serviceThreads = Math.max(Runtime.getRuntime().availableProcessors()/2, 1); public int serviceThreads = Math.max(Runtime.getRuntime().availableProcessors()/2, 1);
public String defaultSaveConfig; public String defaultSaveConfig;
public int renderQuality = 256;//Smaller is higher quality public int renderQuality = 256;//Smaller is higher quality

View File

@@ -40,11 +40,11 @@ public class HierarchicalNodeManager {
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
for(int x = -1; x<=1;x++) { for(int x = -100; x<=100;x++) {
for (int z = -1; z <= 1; z++) { for (int z = -100; z <= 100; z++) {
for (int y = -3; y <= 3; y++) { for (int y = -3; y <= 3; y++) {
updateFilterer.watch(4,x,y,z); updateFilterer.watch(0,x,y,z);
updateFilterer.unwatch(4,x,y,z); updateFilterer.unwatch(0,x,y,z);
} }
} }
} }
@@ -102,6 +102,15 @@ public class HierarchicalNodeManager {
} }
public void processBuildResult(BuiltSection section) { public void processBuildResult(BuiltSection section) {
section.free();
/*
if (!section.isEmpty()) {
this.geometryManager.uploadSection(section);
} else {
section.free();
}
*/
int nodeId = this.activeSectionMap.get(section.position); int nodeId = this.activeSectionMap.get(section.position);
if (nodeId == -1) { if (nodeId == -1) {
//Not tracked or mapped to a node!!! //Not tracked or mapped to a node!!!

View File

@@ -126,7 +126,7 @@ public class WorldImporter {
this.totalRegions.addAndGet(1); this.totalRegions.addAndGet(1);
workers.submit(() -> { workers.submit(() -> {
try { try {
if (!isRunning) { if (!this.isRunning) {
return; return;
} }
this.importRegionFile(file.toPath(), rx, rz); this.importRegionFile(file.toPath(), rx, rz);

View File

@@ -100,4 +100,8 @@ public class ServiceSlice extends TrackedObject {
public int getJobCount() { public int getJobCount() {
return this.jobCount.availablePermits(); return this.jobCount.availablePermits();
} }
public boolean hasJobs() {
return this.jobCount.availablePermits() != 0;
}
} }

View File

@@ -83,6 +83,7 @@ public class ServiceThreadPool {
private void worker(int threadId) { private void worker(int threadId) {
long seed = 1234342; long seed = 1234342;
int revolvingSelector = 0;
while (true) { while (true) {
this.jobCounter.acquireUninterruptibly(); this.jobCounter.acquireUninterruptibly();
if (!this.running) { if (!this.running) {
@@ -102,12 +103,29 @@ public class ServiceThreadPool {
System.err.println("Service worker tried to run but had 0 slices"); System.err.println("Service worker tried to run but had 0 slices");
break; break;
} }
long chosenNumber = clamped % this.totalJobWeight.get();
ServiceSlice service = ref[(int) (clamped % ref.length)]; ServiceSlice service = ref[(int) (clamped % ref.length)];
//1 in 64 chance just to pick a service that has a task, in a cycling manor, this is to keep at least one service from overloading all services constantly
if (((seed>>10)&63) == 0) {
for (int i = 0; i < ref.length; i++) {
int idx = (i+revolvingSelector)%ref.length;
var slice = ref[idx];
if (slice.hasJobs()) {
service = slice;
revolvingSelector = (idx+1)%ref.length;
break;
}
}
} else {
long chosenNumber = clamped % this.totalJobWeight.get();
for (var slice : ref) { for (var slice : ref) {
chosenNumber -= ((long) slice.weightPerJob) * slice.jobCount.availablePermits(); chosenNumber -= ((long) slice.weightPerJob) * slice.jobCount.availablePermits();
if (chosenNumber <= 0) { if (chosenNumber <= 0) {
service = slice; service = slice;
break;
}
} }
} }