Skip to content

Commit 53a6017

Browse files
committed
Implemented preScale and postTranslate
1 parent b6e5568 commit 53a6017

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

gridData/OpenVDB.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def __init__(self, grid, origin, delta, name="density", tolerance=1e-10):
114114
Grid spacing (can be 1D array or diagonal matrix)
115115
name : str
116116
Name of the grid (will be visible in Blender), default 'density'
117-
threshold : float
118-
Values below this threshold are treated as background (sparse),
117+
tolerance : float
118+
Values below this tolerance are treated as background (sparse),
119119
default 1e-10
120120
121121
Raises
@@ -198,19 +198,9 @@ def write(self, filename):
198198
vdb_grid = vdb.FloatGrid()
199199
vdb_grid.name = self.name
200200

201-
# this is an explicit linear transform using per-axis voxel sizes
202-
# world = diag(delta) * index + corner_origin
203-
corner_origin = self.origin - 0.5 * self.delta
204-
205-
matrix = [
206-
[self.delta[0], 0.0, 0.0, 0.0],
207-
[0.0, self.delta[1], 0.0, 0.0],
208-
[0.0, 0.0, self.delta[2], 0.0],
209-
[corner_origin[0], corner_origin[1], corner_origin[2], 1.0],
210-
]
211-
212-
vdb_grid.background = 0.0
213-
vdb_grid.transform = vdb.createLinearTransform(matrix)
201+
vdb_grid.transform = vdb.createLinearTransform()
202+
vdb_grid.transform.preScale(self.delta.tolist())
203+
vdb_grid.transform.postTranslate(self.origin.tolist())
214204

215205
vdb_grid.copyFromArray(self.grid, tolerance=self.tolerance)
216206
vdb_grid.prune()

0 commit comments

Comments
 (0)