mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-24 10:02:08 -05:00
bugfixes
This commit is contained in:
parent
c179f0262b
commit
eac6ff191b
4 changed files with 18 additions and 5 deletions
|
@ -70,7 +70,7 @@ namespace ClassicalSharp {
|
|||
public static FastColour[] FogColour;
|
||||
public static Vector3[] MinBB, MaxBB, RenderMinBB, RenderMaxBB;
|
||||
static uint[] DefinedCustomBlocks;
|
||||
public static int MaxDefined, Count;
|
||||
public static int MaxDefined, Count, IDMask;
|
||||
|
||||
public static void Allocate(int count) {
|
||||
IsLiquid = new bool[count];
|
||||
|
@ -102,6 +102,7 @@ namespace ClassicalSharp {
|
|||
DefinedCustomBlocks = new uint[count >> 5];
|
||||
MaxDefined = count - 1;
|
||||
Count = count;
|
||||
IDMask = Utils.NextPowerOf2(Count) - 1;
|
||||
}
|
||||
|
||||
public static void Reset() {
|
||||
|
|
|
@ -51,8 +51,13 @@ namespace ClassicalSharp.Entities {
|
|||
for (int i = 0; i < count; i++) {
|
||||
// Unpack the block and coordinate data
|
||||
State state = Searcher.stateCache[i];
|
||||
#if !ONLY_8BIT
|
||||
bPos.X = state.X >> 3; bPos.Y = state.Y >> 4; bPos.Z = state.Z >> 3;
|
||||
int block = (state.X & 0x7) | (state.Y & 0xF) << 3 | (state.Z & 0x7) << 7;
|
||||
#else
|
||||
bPos.X = state.X >> 3; bPos.Y = state.Y >> 3; bPos.Z = state.Z >> 3;
|
||||
int block = (state.X & 0x7) | (state.Y & 0x7) << 3 | (state.Z & 0x7) << 6;
|
||||
#endif
|
||||
|
||||
blockBB.Min = BlockInfo.MinBB[block];
|
||||
blockBB.Min.X += bPos.X; blockBB.Min.Y += bPos.Y; blockBB.Min.Z += bPos.Z;
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace ClassicalSharp.Map {
|
|||
public BlockID GetBlock(int x, int y, int z) {
|
||||
int i = (y * Length + z) * Width + x;
|
||||
#if !ONLY_8BIT
|
||||
return (BlockID)((blocks[i] | (blocks2[i] << 8)) & BlockInfo.MaxDefined);
|
||||
return (BlockID)((blocks[i] | (blocks2[i] << 8)) & BlockInfo.IDMask);
|
||||
#else
|
||||
return blocks[i];
|
||||
#endif
|
||||
|
@ -83,7 +83,7 @@ namespace ClassicalSharp.Map {
|
|||
public BlockID GetBlock(Vector3I p) {
|
||||
int i = (p.Y * Length + p.Z) * Width + p.X;
|
||||
#if !ONLY_8BIT
|
||||
return (BlockID)((blocks[i] | (blocks2[i] << 8)) & BlockInfo.MaxDefined);
|
||||
return (BlockID)((blocks[i] | (blocks2[i] << 8)) & BlockInfo.IDMask);
|
||||
#else
|
||||
return blocks[i];
|
||||
#endif
|
||||
|
@ -115,7 +115,7 @@ namespace ClassicalSharp.Map {
|
|||
|
||||
int i = (y * Length + z) * Width + x;
|
||||
#if !ONLY_8BIT
|
||||
return (BlockID)((blocks[i] | (blocks2[i] << 8)) & BlockInfo.MaxDefined);
|
||||
return (BlockID)((blocks[i] | (blocks2[i] << 8)) & BlockInfo.IDMask);
|
||||
#else
|
||||
return blocks[i];
|
||||
#endif
|
||||
|
|
|
@ -12,10 +12,17 @@ namespace ClassicalSharp.Physics {
|
|||
public float tSquared;
|
||||
|
||||
public State(int x, int y, int z, BlockID block, float tSquared) {
|
||||
#if !ONLY_8BIT
|
||||
X = x << 3; Y = y << 4; Z = z << 3;
|
||||
X |= (block & 0x007);
|
||||
Y |= (block & 0x078) >> 3;
|
||||
Z |= (block & 0x380) >> 7;
|
||||
#else
|
||||
X = x << 3; Y = y << 3; Z = z << 3;
|
||||
X |= (block & 0x007);
|
||||
Y |= (block & 0x038) >> 3;
|
||||
Z |= (block & 0x1C0) >> 6;
|
||||
#endif
|
||||
this.tSquared = tSquared;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue