Tweeks to iteration
This commit is contained in:
@@ -154,9 +154,7 @@ public class WorldConversionFactory {
|
|||||||
long sample = 0;
|
long sample = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int dec = 0;
|
int dec = 0;
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int i = 0; i < 0xFFF; i++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
for (int x = 0; x < 16; x++) {
|
|
||||||
if (dec-- == 0) {
|
if (dec-- == 0) {
|
||||||
sample = bDat[c++];
|
sample = bDat[c++];
|
||||||
dec = iterPerLong;
|
dec = iterPerLong;
|
||||||
@@ -169,13 +167,11 @@ public class WorldConversionFactory {
|
|||||||
}
|
}
|
||||||
sample >>>= eBits;
|
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))) {
|
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 {
|
} else {
|
||||||
data[G(x, y, z)] = Mapper.AIR;
|
data[i] = Mapper.AIR;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -183,15 +179,17 @@ public class WorldConversionFactory {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
int bId = pc[0];
|
int bId = pc[0];
|
||||||
for (int y = 0; y < 16; y++) {
|
if (bId == 0) {//Its air
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int i = 0; i < 0xFFF; i++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
data[i] = Mapper.airWithLight(lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
} 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;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static int G(int x, int y, int z) {
|
private static int G(int x, int y, int z) {
|
||||||
return ((y<<8)|(z<<4)|x);
|
return ((y<<8)|(z<<4)|x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class WorldUpdater {
|
|||||||
if (!into.isLive) throw new IllegalStateException("World is not live");
|
if (!into.isLive) throw new IllegalStateException("World is not live");
|
||||||
boolean shouldCheckEmptiness = false;
|
boolean shouldCheckEmptiness = false;
|
||||||
WorldSection previousSection = null;
|
WorldSection previousSection = null;
|
||||||
|
final var vdat = section.section;
|
||||||
|
|
||||||
for (int lvl = 0; lvl < MAX_LOD_LAYER+1; lvl++) {
|
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));
|
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;
|
var secD = worldSection.data;
|
||||||
for (int i = 0; i <= 0xFFF >> (lvl * 3); i++) {
|
for (int i = 0; i <= 0xFFF >> (lvl * 3); i++) {
|
||||||
int secIdx = Integer.expand(i, secMsk)+baseSec;
|
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;
|
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;
|
didStateChange |= newId != oldId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,4 +88,16 @@ public class WorldUpdater {
|
|||||||
previousSection.release();
|
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);
|
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) {
|
public void setStateCallback(Consumer<StateEntry> stateCallback) {
|
||||||
this.newStateCallback = stateCallback;
|
this.newStateCallback = stateCallback;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,10 +291,12 @@ public class DHImporter implements IDataImporter {
|
|||||||
// int a = 0;
|
// int a = 0;
|
||||||
//}
|
//}
|
||||||
//Insert all entries into data cache
|
//Insert all entries into data cache
|
||||||
for (int y = startY; y < endY; y++) {
|
startY = Integer.expand(startY, 0b11111111_00_1111_0000_0000);
|
||||||
int idx = Integer.expand(y, 0b11111111_00_1111_0000_0000) | bPos;
|
endY = Integer.expand(endY, 0b11111111_00_1111_0000_0000);
|
||||||
storage[idx] = mEntry;
|
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);
|
//touched[(idx >>> 12)>>6] |= 1L<<(idx&0x3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user