Guest User

Untitled

a guest
Jun 18th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. [Flags]
  2. enum Sides : byte
  3. {
  4.     None = 0x00,
  5.     Top = 0x01,
  6.     Bottom = 0x02,
  7.     Left = 0x04,
  8.     Right = 0x08,
  9.     Front = 0x10,
  10.     Back = 0x20
  11. }
  12.  
  13. public static Sides VisibleFacesFor(ChunkInfo chunk, IntVector3 voxel)
  14. {
  15.     var sides = Sides.None
  16.  
  17.     voxel.Y += 1;
  18.     if (chunk.GetVoxel(voxel).Weight <= 0)
  19.         sides |= Sides.Top;
  20.  
  21.     voxel.Y -= 2;
  22.     if (chunk.GetVoxel(voxel).Weight <= 0)
  23.         sides |= Sides.Bottom;
  24.  
  25.     voxel.Y += 1;
  26.     voxel.X -= 1;
  27.     if (chunk.GetVoxel(voxel).Weight <= 0)
  28.         sides |= Sides.Left;
  29.  
  30.     voxel.X += 2;
  31.     if (chunk.GetVoxel(voxel).Weight <= 0)
  32.         sides |= Sides.Right;
  33.  
  34.     voxel.X -= 1;
  35.     voxel.Z -= 1;
  36.     if (chunk.GetVoxel(voxel).Weight <= 0)
  37.         sides |= Sides.Front;
  38.  
  39.     voxel.Z += 2;
  40.     if (chunk.GetVoxel(voxel).Weight <= 0)
  41.         sides |= Sides.Back;
  42.  
  43.     voxel.Z -= 1;
  44.  
  45.     return result;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment