From 48737a4989f53eadc64d1a361a3d1c49ebe00394 Mon Sep 17 00:00:00 2001 From: Yannis Kommana Date: Tue, 21 Jul 2015 11:46:03 +0200 Subject: [PATCH] fix holes fixes #731 --- .../voxelization/HullVoxelWorker.coffee | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/plugins/newBrickator/pipeline/voxelization/HullVoxelWorker.coffee b/src/plugins/newBrickator/pipeline/voxelization/HullVoxelWorker.coffee index d03ece7d..6daf1b25 100644 --- a/src/plugins/newBrickator/pipeline/voxelization/HullVoxelWorker.coffee +++ b/src/plugins/newBrickator/pipeline/voxelization/HullVoxelWorker.coffee @@ -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