Tweeks to iteration
This commit is contained in:
@@ -154,9 +154,7 @@ public class WorldConversionFactory {
|
||||
long sample = 0;
|
||||
int c = 0;
|
||||
int dec = 0;
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int i = 0; i < 0xFFF; i++) {
|
||||
if (dec-- == 0) {
|
||||
sample = bDat[c++];
|
||||
dec = iterPerLong;
|
||||
@@ -169,13 +167,11 @@ public class WorldConversionFactory {
|
||||
}
|
||||
sample >>>= eBits;
|
||||
|
||||
byte light = lightSupplier.supply(x, y, z);
|
||||
byte light = lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF);
|
||||
if (!(bId == 0 && (light == 0))) {
|
||||
data[G(x, y, z)] = Mapper.composeMappingId(light, bId, biomes[((y & 0b1100) << 2) | (z & 0b1100) | (x >> 2)]);
|
||||
data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]);
|
||||
} else {
|
||||
data[G(x, y, z)] = Mapper.AIR;
|
||||
}
|
||||
}
|
||||
data[i] = Mapper.AIR;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -183,15 +179,17 @@ public class WorldConversionFactory {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
int bId = pc[0];
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
byte light = lightSupplier.supply(x, y, z);
|
||||
if (!(bId == 0 && (light == 0))) {
|
||||
data[G(x, y, z)] = Mapper.composeMappingId(light, bId, biomes[((y & 0b1100) << 2) | (z & 0b1100) | (x >> 2)]);
|
||||
} else {
|
||||
data[G(x, y, z)] = Mapper.AIR;
|
||||
if (bId == 0) {//Its air
|
||||
for (int i = 0; i < 0xFFF; i++) {
|
||||
data[i] = Mapper.airWithLight(lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 0xFFF; i++) {
|
||||
byte light = lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF);
|
||||
if (light != 0) {
|
||||
data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]);
|
||||
} else {
|
||||
data[i] = Mapper.AIR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,6 +197,14 @@ public class WorldConversionFactory {
|
||||
return section;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static int G(int x, int y, int z) {
|
||||
return ((y<<8)|(z<<4)|x);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class WorldUpdater {
|
||||
if (!into.isLive) throw new IllegalStateException("World is not live");
|
||||
boolean shouldCheckEmptiness = false;
|
||||
WorldSection previousSection = null;
|
||||
final var vdat = section.section;
|
||||
|
||||
for (int lvl = 0; lvl < MAX_LOD_LAYER+1; lvl++) {
|
||||
var worldSection = into.acquire(lvl, section.x >> (lvl + 1), section.y >> (lvl + 1), section.z >> (lvl + 1));
|
||||
@@ -45,9 +46,9 @@ public class WorldUpdater {
|
||||
var secD = worldSection.data;
|
||||
for (int i = 0; i <= 0xFFF >> (lvl * 3); i++) {
|
||||
int secIdx = Integer.expand(i, secMsk)+baseSec;
|
||||
long newId = section.section[baseVIdx+i];
|
||||
long newId = vdat[baseVIdx+i];
|
||||
long oldId = secD[secIdx]; secD[secIdx] = newId;
|
||||
nonAirCountDelta += Mapper.isAir(oldId) == Mapper.isAir(newId) ? 0 : (Mapper.isAir(newId) ? -1 : 1);
|
||||
nonAirCountDelta += (Mapper.isAir(newId)?1:0)-(Mapper.isAir(oldId)?1:0);
|
||||
didStateChange |= newId != oldId;
|
||||
}
|
||||
}
|
||||
@@ -87,4 +88,16 @@ public class WorldUpdater {
|
||||
previousSection.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int MSK = 0b110110010100;
|
||||
int iMSK = ~MSK;
|
||||
int iMSK1 = iMSK+1;
|
||||
int i = 0;
|
||||
do {
|
||||
System.err.println(Integer.toBinaryString(i));
|
||||
if (i==MSK) break;
|
||||
i = (i+iMSK1)&MSK;
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,10 @@ public class Mapper {
|
||||
return (id&(~(0xFFL<<56)))|(Integer.toUnsignedLong(light&0xFF)<<56);
|
||||
}
|
||||
|
||||
public static long airWithLight(int light) {
|
||||
return Integer.toUnsignedLong(light&0xFF)<<56;
|
||||
}
|
||||
|
||||
public void setStateCallback(Consumer<StateEntry> stateCallback) {
|
||||
this.newStateCallback = stateCallback;
|
||||
}
|
||||
|
||||
@@ -291,10 +291,12 @@ public class DHImporter implements IDataImporter {
|
||||
// int a = 0;
|
||||
//}
|
||||
//Insert all entries into data cache
|
||||
for (int y = startY; y < endY; y++) {
|
||||
int idx = Integer.expand(y, 0b11111111_00_1111_0000_0000) | bPos;
|
||||
storage[idx] = mEntry;
|
||||
|
||||
startY = Integer.expand(startY, 0b11111111_00_1111_0000_0000);
|
||||
endY = Integer.expand(endY, 0b11111111_00_1111_0000_0000);
|
||||
final int Msk = 0b11111111_00_1111_0000_0000;
|
||||
final int iMsk1 = (~Msk)+1;
|
||||
for (int y = startY; y != endY; y = (y+iMsk1)&Msk) {
|
||||
storage[y+bPos] = mEntry;
|
||||
//touched[(idx >>> 12)>>6] |= 1L<<(idx&0x3f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user