mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Reduce array sizes in block info, make some things more consistent.
This commit is contained in:
parent
168e685867
commit
1ceeeda4ba
@ -4,11 +4,11 @@ namespace ClassicalSharp {
|
||||
|
||||
public partial class BlockInfo {
|
||||
|
||||
bool[] hidden = new bool[70 * 70 * 6];
|
||||
bool[] hidden = new bool[blocksCount * blocksCount * 6];
|
||||
|
||||
void SetupCullingCache() {
|
||||
for( byte tile = 1; tile <= 65; tile++ ) {
|
||||
for( byte neighbour = 1; neighbour <= 65; neighbour++ ) {
|
||||
for( byte tile = 1; tile < blocksCount; tile++ ) {
|
||||
for( byte neighbour = 1; neighbour < blocksCount; neighbour++ ) {
|
||||
bool hidden = IsHidden( tile, neighbour );
|
||||
if( hidden ) {
|
||||
SetHidden( tile, neighbour, TileSide.Left, true );
|
||||
@ -29,11 +29,11 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
|
||||
hidden[( tile * 70 + block ) * 6 + tileSide] = value;
|
||||
hidden[( tile * blocksCount + block ) * 6 + tileSide] = value;
|
||||
}
|
||||
|
||||
public bool IsFaceHidden( byte tile, byte block, int tileSide ) {
|
||||
return hidden[( tile * 70 + block ) * 6 + tileSide];
|
||||
return hidden[( tile * blocksCount + block ) * 6 + tileSide];
|
||||
}
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ namespace ClassicalSharp {
|
||||
};
|
||||
|
||||
public static void MakeOptimisedTexture( FastBitmap atlas ) {
|
||||
int size = atlas.Width / 16;
|
||||
int tileSize = atlas.Width / 16;
|
||||
int srcIndex = 0, destIndex = 0;
|
||||
|
||||
for( int y = 0; y < 6; y++ ) {
|
||||
@ -150,16 +150,15 @@ namespace ClassicalSharp {
|
||||
for( int x = 0; x < 16; x++ ) {
|
||||
bool isUsed = ( flags & 1 << ( 15 - x ) ) != 0;
|
||||
if( isUsed && srcIndex != destIndex ) {
|
||||
int srcX = x * size;
|
||||
int srcY = y * size;
|
||||
int destX = ( destIndex & 0x0F ) * size;
|
||||
int destY = ( destIndex >> 4 ) * size;
|
||||
MovePortion( srcX, srcY, destX, destY, atlas, size );
|
||||
int srcX = x * tileSize;
|
||||
int srcY = y * tileSize;
|
||||
int destX = ( destIndex & 0x0F ) * tileSize;
|
||||
int destY = ( destIndex >> 4 ) * tileSize;
|
||||
MovePortion( srcX, srcY, destX, destY, atlas, tileSize );
|
||||
}
|
||||
|
||||
srcIndex++;
|
||||
destIndex++;
|
||||
if( !isUsed ) destIndex--;
|
||||
if( isUsed ) destIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ namespace ClassicalSharp {
|
||||
bool[] isLiquid = new bool[blocksCount];
|
||||
float[] heights = new float[blocksCount];
|
||||
bool[] blocksLight = new bool[blocksCount];
|
||||
const int blocksCount = 256;
|
||||
const byte blocksCount = (byte)Block.StoneBrick + 1;
|
||||
|
||||
public void Init() {
|
||||
for( int i = 1; i < blocksCount; i++ ) {
|
||||
heights[i] = 1;
|
||||
blocksLight[i] = true;
|
||||
isOpaque[i] = true;
|
||||
for( int tile = 1; tile < blocksCount; tile++ ) {
|
||||
heights[tile] = 1f;
|
||||
blocksLight[tile] = true;
|
||||
isOpaque[tile] = true;
|
||||
}
|
||||
SetupOptimTextures();
|
||||
|
||||
@ -43,9 +43,9 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public void SetDefaultBlockPermissions( bool[] canPlace, bool[] canDelete ) {
|
||||
for( int i = (int)Block.Stone; i <= (int)Block.Obsidian; i++ ) {
|
||||
canPlace[i] = true;
|
||||
canDelete[i] = true;
|
||||
for( int tile = (int)Block.Stone; tile <= (int)Block.Obsidian; tile++ ) {
|
||||
canPlace[tile] = true;
|
||||
canDelete[tile] = true;
|
||||
}
|
||||
canPlace[(int)Block.Grass] = false;
|
||||
canPlace[(int)Block.Lava] = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user