Skip to content

Commit ddbc1c2

Browse files
committed
tweeks
1 parent 2f49d03 commit ddbc1c2

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private static void assertPosValid(long pos) {
136136
z <<= lvl;
137137
long p2 = WorldEngine.getWorldSectionId(0, x, y, z);
138138
if (WorldEngine.getLevel(p2) != 0 || WorldEngine.getX(p2) != x || WorldEngine.getY(p2) != y || WorldEngine.getZ(p2) != z) {
139-
throw new IllegalStateException("Position not valid at all levels");
139+
throw new IllegalStateException("Position not valid at all levels: " + pos + "-"+WorldEngine.pprintPos(pos) + ":"+WorldEngine.pprintPos(p2));
140140
}
141141
}
142142

src/main/java/me/cortex/voxy/client/core/rendering/hierachical/TestNodeManager.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ public int uploadReplaceSection(int oldId, BuiltSection section) {
3939
this.removeSection(oldId);
4040
}
4141
int newId = this.allocation.allocateNext();
42+
if (newId == -1) {
43+
Logger.error("Allocator full: "+this.allocation.getCount()+" " +section, new Throwable());
44+
section.free();
45+
return -1;
46+
}
4247
var entry = new Entry(section.position, section.geometryBuffer.size);
43-
if (this.sections.put(newId, entry) != null) {
44-
throw new IllegalStateException();
48+
var old = this.sections.put(newId, entry);
49+
if (old != null) {
50+
throw new IllegalStateException(oldId + ","+newId+" "+old+","+entry);
4551
}
4652
this.memoryInUse += entry.size;
4753
section.free();
@@ -282,22 +288,24 @@ public static void main(String[] args) {
282288
int ITER_COUNT = 5_000;
283289
int INNER_ITER_COUNT = 1_000_000;
284290
boolean GEO_REM = true;
291+
boolean LIMIT_REQUEST_SEC_ALLOCATION = true;
285292

286293
AtomicInteger finished = new AtomicInteger();
287294
HashSet<List<StackTraceElement>> seenTraces = new HashSet<>();
288295

296+
Logger.SHUTUP_INFO = true;
289297
Logger.SHUTUP = true;
290298

291-
if (true) {
299+
if (false) {
292300
for (int q = 0; q < ITER_COUNT; q++) {
293301
//Logger.info("Iteration "+ q);
294-
if (runTest(INNER_ITER_COUNT, q, seenTraces, GEO_REM)) {
302+
if (runTest(INNER_ITER_COUNT, q, seenTraces, GEO_REM, LIMIT_REQUEST_SEC_ALLOCATION)) {
295303
finished.incrementAndGet();
296304
}
297305
}
298306
} else {
299307
IntStream.range(0, ITER_COUNT).parallel().forEach(i->{
300-
if (runTest(INNER_ITER_COUNT, i, seenTraces, GEO_REM)) {
308+
if (runTest(INNER_ITER_COUNT, i, seenTraces, GEO_REM, LIMIT_REQUEST_SEC_ALLOCATION)) {
301309
finished.incrementAndGet();
302310
}
303311
});
@@ -314,7 +322,7 @@ private static long rPos(Random r, LongList tops) {
314322
return WorldEngine.getWorldSectionId(lvl, r.nextInt(bound)+(WorldEngine.getX(top)<<4), r.nextInt(bound)+(WorldEngine.getY(top)<<4), r.nextInt(bound)+(WorldEngine.getZ(top)<<4));
315323
}
316324

317-
private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElement>> traces, boolean geoRemoval) {
325+
private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElement>> traces, boolean geoRemoval, boolean requestLimiter) {
318326
Random r = new Random(testIdx * 1234L);
319327
try {
320328
var test = new TestBase();
@@ -334,7 +342,7 @@ private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElemen
334342
//Fuzzy bruteforce everything
335343
for (int x = -R; x<=R; x++) {
336344
for (int z = -R; z<=R; z++) {
337-
for (int y = -8; y<=7; y++) {
345+
for (int y = -1; y<=0; y++) {
338346
tops.add(WorldEngine.getWorldSectionId(4, x, y, z));
339347
}
340348
}
@@ -351,28 +359,29 @@ private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElemen
351359
long pos = rPos(r, tops);
352360
int op = r.nextInt(5);
353361
int extra = r.nextInt(256);
362+
boolean geoAddOk = ((!requestLimiter)||(test.geometryManager.allocation.getLimit()-test.geometryManager.allocation.getCount())>1000);
354363
boolean hasGeometry = r.nextBoolean();
355364
boolean addRemTLN = r.nextInt(64) == 0;
356365
boolean extraBool = r.nextBoolean();
357366
if (op == 0 && addRemTLN) {
358-
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(32)-16, r.nextInt(5)-2);
367+
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(2)-1, r.nextInt(5)-2);//r.nextInt(16)-8//for y
359368
boolean cont = tops.contains(pos);
360369
if (cont&&extraBool&&tops.size()>1) {
361370
extraBool = true;
362371
test.remTopPos(pos);
363372
tops.rem(pos);
364-
} else if (!cont) {
373+
} else if ((!cont)&&geoAddOk) {
365374
extraBool = false;
366375
test.putTopPos(pos);
367376
tops.add(pos);
368377
}
369-
} else if (op == 0) {
378+
} else if (op == 0&&geoAddOk) {
370379
test.request(pos);
371380
}
372381
if (op == 1) {
373382
test.childUpdate(pos, extra);
374383
}
375-
if (op == 2) {
384+
if (op == 2&&((!hasGeometry)||geoAddOk)) {
376385
test.meshUpdate(pos, extra, hasGeometry ? 100 : 0);
377386
}
378387
if (op == 3 && geoRemoval) {

src/main/java/me/cortex/voxy/common/Logger.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
public class Logger {
1313
public static boolean INSERT_CLASS = true;
1414
public static boolean SHUTUP = false;
15+
public static boolean SHUTUP_INFO = false;
1516
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger("Voxy");
1617

1718

@@ -76,7 +77,7 @@ public static void warn(Object... args) {
7677
}
7778

7879
public static void info(Object... args) {
79-
if (SHUTUP) {
80+
if (SHUTUP||SHUTUP_INFO) {
8081
return;
8182
}
8283
Throwable throwable = null;

0 commit comments

Comments
 (0)