Skip to content

Commit

Permalink
fix holes
Browse files Browse the repository at this point in the history
fixes #731
  • Loading branch information
Yannis Kommana committed Jul 21, 2015
1 parent 91ce83a commit 48737a4
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,27 @@ module.exports =
grid[x][y] = [] unless grid[x][y]
oldValue = grid[x][y][z]
if oldValue
# Update dir if new zValue is higher than the old one
# by at least floatDelta to avoid setting direction to -1 if it is
# within the tolerance of floatDelta
if (direction isnt 0 and zValue > oldValue.z + @floatDelta) or
# Prefer setting direction to 1 (i.e. close the voxel)
(direction is 1 and zValue > oldValue.z - @floatDelta)
oldValue.z = zValue
oldValue.dir = direction
@_setNewVoxelValue zValue, direction, oldValue
else
grid[x][y][z] = z: zValue, dir: direction

_setNewVoxelValue: (zValue, direction, oldValue) ->
if zValue > oldValue.z + @floatDelta
# New zValue is higher than the old one by more than floatDelta.
# --> set new values
oldValue.z = zValue
oldValue.dir = direction
else if Math.abs(zValue - oldValue.z) < @floatDelta and
# New zValue is the same as the old one.
Math.abs(direction) > oldValue.dir
# And new direction is steeper than the old one.
# Because the two lines (i.e. faces) meet within this voxel they can
# either point away or towards one another. This can be determined by
# comparing the angles. The steeper one determines the arrangement.
# See https://github.com/brickify/brickify/issues/731
oldValue.z = zValue
oldValue.dir = direction

_resetProgress: ->
@lastProgress = -1

Expand Down

0 comments on commit 48737a4

Please sign in to comment.