                 uint ipos = index * 24;
 
                 // Перед
-                indices[ipos++] = vpos + 0;
-                indices[ipos++] = vpos + 4;
-                indices[ipos++] = vpos + 5;
-                indices[ipos++] = vpos + 1;
+                indices[ipos++] = vpos + 0; indices[ipos++] = vpos + 4;
+                indices[ipos++] = vpos + 5; indices[ipos++] = vpos + 1;
 
                 // Зад
-                indices[ipos++] = vpos + 2;
-                indices[ipos++] = vpos + 3;
-                indices[ipos++] = vpos + 7;
-                indices[ipos++] = vpos + 6;
+                indices[ipos++] = vpos + 2; indices[ipos++] = vpos + 3;
+                indices[ipos++] = vpos + 7; indices[ipos++] = vpos + 6;
 
                 // Верх
-                indices[ipos++] = vpos + 1;
-                indices[ipos++] = vpos + 5;
-                indices[ipos++] = vpos + 7;
-                indices[ipos++] = vpos + 3;
+                indices[ipos++] = vpos + 1; indices[ipos++] = vpos + 5;
+                indices[ipos++] = vpos + 7; indices[ipos++] = vpos + 3;
 
                 // Низ
-                indices[ipos++] = vpos + 0;
-                indices[ipos++] = vpos + 2;
-                indices[ipos++] = vpos + 6;
-                indices[ipos++] = vpos + 4;
+                indices[ipos++] = vpos + 0; indices[ipos++] = vpos + 2;
+                indices[ipos++] = vpos + 6; indices[ipos++] = vpos + 4;
 
                 // Лево
-                indices[ipos++] = vpos + 0;
-                indices[ipos++] = vpos + 1;
-                indices[ipos++] = vpos + 3;
-                indices[ipos++] = vpos + 2;
+                indices[ipos++] = vpos + 0; indices[ipos++] = vpos + 1;
+                indices[ipos++] = vpos + 3; indices[ipos++] = vpos + 2;
 
                 // Право
-                indices[ipos++] = vpos + 4;
-                indices[ipos++] = vpos + 6;
-                indices[ipos++] = vpos + 7;
-                indices[ipos++] = vpos + 5;
+                indices[ipos++] = vpos + 4; indices[ipos++] = vpos + 6;
+                indices[ipos++] = vpos + 7; indices[ipos++] = vpos + 5;
             }
         }
     }


                gridSpinEnergy = externalField;

                for (int x = (int) i - radiusX; x <= (int) i + radiusX; x++)
                {
                    for (int y = (int) j - radiusY; y <= (int) j + radiusY; y++)
                    {
                        for (int z = (int) k - radiusZ; z <= (int) k + radiusZ; z++)
                        {
                            xx = (xSize + x) % xSize;
                            yy = (ySize + y) % ySize;

    uint offsetz = gridDim.z * blockDim.z;

    float gridSize = 5.0f;
    uint maxSize = max(xSize, max(ySize, zSize));
    float cubeSize = (gridSize / maxSize) * (0.01f * percentOfCube);
    float cubeSpace = (gridSize / maxSize) * (0.01f * (100 - percentOfCube));

    float lengthX = xSize * cubeSize + (xSize - 1) * cubeSpace;
    float lengthY = ySize * cubeSize + (ySize - 1) * cubeSpace;
