Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Explicit steps for range loops

  • Loading branch information...
commit d1248270012e76ac92311c804c1c83c6438260d2 1 parent 83b5b3b
@mitsuhiko authored
Showing with 15 additions and 15 deletions.
  1. +9 −9 src/world.coffee
  2. +6 −6 src/worldgen.coffee
View
18 src/world.coffee
@@ -179,9 +179,9 @@ class World
maker.addSide side, (offX + cx) * CUBE_SIZE, (offY + cy) * CUBE_SIZE,
(offZ + cz) * CUBE_SIZE, blockTextures[blockID]
- for cz in [0...chunkSize]
- for cy in [0...chunkSize]
- for cx in [0...chunkSize]
+ for cz in [0...chunkSize] by 1
+ for cy in [0...chunkSize] by 1
+ for cx in [0...chunkSize] by 1
blockID = chunk[cx + cy * chunkSize + cz * chunkSize * chunkSize]
if blockID == 0
continue
@@ -219,9 +219,9 @@ class World
chunkSize = CUBE_SIZE * @chunkSize
[ccx, ccy, ccz] = this.chunkAtCameraPosition()
- for x in [ccx - VIEW_DISTANCE_X..ccx + VIEW_DISTANCE_X]
- for y in [ccy - VIEW_DISTANCE_Y..ccy + VIEW_DISTANCE_Y]
- for z in [ccz - VIEW_DISTANCE_Z..ccz + VIEW_DISTANCE_Z]
+ for x in [ccx - VIEW_DISTANCE_X..ccx + VIEW_DISTANCE_X] by 1
+ for y in [ccy - VIEW_DISTANCE_Y..ccy + VIEW_DISTANCE_Y] by 1
+ for z in [ccz - VIEW_DISTANCE_Z..ccz + VIEW_DISTANCE_Z] by 1
vbo = this.getChunkVBO x, y, z
if !vbo
continue
@@ -244,9 +244,9 @@ class World
requestMissingChunks: ->
[x, y, z] = this.chunkAtCameraPosition()
- for cx in [x - GENERATE_DISTANCE_X..x + GENERATE_DISTANCE_X]
- for cy in [y - GENERATE_DISTANCE_Y..y + GENERATE_DISTANCE_Y]
- for cz in [z - GENERATE_DISTANCE_Z..z + GENERATE_DISTANCE_Z]
+ for cx in [x - GENERATE_DISTANCE_X..x + GENERATE_DISTANCE_X] by 1
+ for cy in [y - GENERATE_DISTANCE_Y..y + GENERATE_DISTANCE_Y] by 1
+ for cz in [z - GENERATE_DISTANCE_Z..z + GENERATE_DISTANCE_Z] by 1
chunk = this.getChunk cx, cy, cz
if !chunk
this.requestChunk cx, cy, cz
View
12 src/worldgen.coffee
@@ -20,9 +20,9 @@ class GeneratorState
@offZ = offZ
sc = @blockSourceCache
- for cz in [0...cacheSizeZ]
- for cy in [0...cacheSizeY]
- for cx in [0...cacheSizeX]
+ for cz in [0...cacheSizeZ] by 1
+ for cy in [0...cacheSizeY] by 1
+ for cx in [0...cacheSizeX] by 1
source = gen.getBlockSource offX + cx, offY + cy, offZ + cz
sc[cx + cy * cacheSizeX + cz * cacheSizeX * cacheSizeY] = source
@@ -150,9 +150,9 @@ class WorldGeneratorProcess extends webglmc.Process
state = this.getGeneratorState offX, offY, offZ, chunkSize
chunk = this.getChunkArray chunkSize
- for cz in [0...chunkSize]
- for cy in [0...chunkSize]
- for cx in [0...chunkSize]
+ for cz in [0...chunkSize] by 1
+ for cy in [0...chunkSize] by 1
+ for cx in [0...chunkSize] by 1
blockID = this.getBlock state, cx, cy, cz
chunk[cx + cy * chunkSize + cz * chunkSize * chunkSize] = blockID
Please sign in to comment.
Something went wrong with that request. Please try again.