Ejemplo n.º 1
0
 private unsafe void ParseExistsTable(byte* mh2oChunk, SMLiquidInstance* instance)
 {
     if (instance->existsTable != 0 && UseExistsTable(instance->liquidObjectId, instance->liquidType))
     {
         var table = mh2oChunk + instance->existsTable;
         ExistsTable = new bool[TilesPerRow, TilesPerRow];
         for (int x = MinX; x < MaxX; x++)
         {
             for (int y = MinY; y < MaxY; y++)
             {
                 int index = y*(MaxX - MinX) + x;
                 ExistsTable[y, x] = (table[index/8] & (1 << (index & 7))) != 0;
             }
         }
     }
     else
     {
         ExistsTable = FullExistsTable;
     }
 }
Ejemplo n.º 2
0
 private unsafe void ParseHeightMap(byte* mh2oChunk, SMLiquidInstance* instance)
 {
     if (HasHeightMapData(instance) && UseExistsTable(instance->liquidObjectId, instance->liquidType))
     {
         var data = (float*)(mh2oChunk + instance->data);
         HeightMap = new float[VerticesPerRow, VerticesPerRow];
         for (int y = MinY; y <= MaxY; y++)
         {
             for (int x = MinX; x <= MaxX; x++)
             {
                 int index = y*(MaxX - MinX + 1) + x;
                 HeightMap[y, x] = data[index];
             }
         }
     }
     else
     {
         HeightMap = ArrayUtil.MakeTwoDimensionalArray(instance->maxWaterHeight, VerticesPerRow, VerticesPerRow);
     }
 }
Ejemplo n.º 3
0
 private static unsafe bool HasHeightMapData(SMLiquidInstance* instance)
 {
     return instance->data != 0;
 }