 
 # Macros
 # should work as normal functions, as well
-tileIndexByTileMacro = (tile) ->
-
-  tile[0] * (1 << @TEXTURE_SIZE_P - @cube.BUCKET_SIZE_P) + tile[1]
+tileIndexByTileMacro = (_this, tile) ->
+
+  tile[0] * (1 << @TEXTURE_SIZE_P - _this.cube.BUCKET_SIZE_P) + tile[1]
 
 
 subTileMacro = (tile, index) ->

        # If the tile is part of the texture, mark it as changed
        if u in [0...@BUCKETS_PER_ROW] and v in [0...@BUCKETS_PER_ROW]
          tile = [u, v]
          @dataTexture.tiles[tileIndexByTileMacro(tile)] = false
          @dataTexture.ready &= not (u in [@dataTexture.area[0]..@dataTexture.area[2]] and v in [@dataTexture.area[1]..@dataTexture.area[3]])

    @cube.on "volumeLabled", =>

  [(tile[0] << 1) + (index % 2), (tile[1] << 1) + (index >> 1)]


bufferOffsetByTileMacro = (_this, tile, tileSize) ->

  tile[0] * (1 << tileSize) + tile[1] * (1 << tileSize) * (1 << _this.TEXTURE_SIZE_P)


class Plane2D
