2015-01-31 06:56:10 +11:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ClassicalSharp {
|
|
|
|
|
|
|
|
|
|
public partial class BlockInfo {
|
|
|
|
|
|
2015-08-29 08:16:49 +10:00
|
|
|
|
bool[] hidden = new bool[BlocksCount * BlocksCount * TileSide.Sides];
|
2015-01-31 06:56:10 +11:00
|
|
|
|
|
|
|
|
|
void SetupCullingCache() {
|
2015-04-12 09:38:47 +10:00
|
|
|
|
for( byte tile = 1; tile < BlocksCount; tile++ ) {
|
|
|
|
|
for( byte neighbour = 1; neighbour < BlocksCount; neighbour++ ) {
|
2015-01-31 06:56:10 +11:00
|
|
|
|
bool hidden = IsHidden( tile, neighbour );
|
|
|
|
|
if( hidden ) {
|
|
|
|
|
SetHidden( tile, neighbour, TileSide.Left, true );
|
|
|
|
|
SetHidden( tile, neighbour, TileSide.Right, true );
|
|
|
|
|
SetHidden( tile, neighbour, TileSide.Front, true );
|
|
|
|
|
SetHidden( tile, neighbour, TileSide.Back, true );
|
|
|
|
|
SetHidden( tile, neighbour, TileSide.Top, BlockHeight( tile ) == 1 );
|
|
|
|
|
SetHidden( tile, neighbour, TileSide.Bottom, BlockHeight( neighbour ) == 1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IsHidden( byte tile, byte block ) {
|
|
|
|
|
return
|
|
|
|
|
( ( tile == block || ( IsOpaque( block ) && !IsLiquid( block ) ) ) && !IsSprite( tile ) ) ||
|
|
|
|
|
( IsLiquid( tile ) && block == (byte)Block.Ice );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
|
2015-08-29 08:16:49 +10:00
|
|
|
|
hidden[( tile * BlocksCount + block ) * TileSide.Sides + tileSide] = value;
|
2015-01-31 06:56:10 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsFaceHidden( byte tile, byte block, int tileSide ) {
|
2015-08-29 08:16:49 +10:00
|
|
|
|
return hidden[( tile * BlocksCount + block ) * TileSide.Sides + tileSide];
|
2015-01-31 06:56:10 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|