You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operating System: Ubuntu 22.04 Version / Commit SHA: v9.1.0 Other: Using the Python bindings
Describe the bug
When setting the background value of a (Float) grid, if the previous background value was NaN, the values of all inactive voxels get changed to the new value.
To Reproduce
Example script:
importpyopenvdbasvdbimportmathimportitertoolsgrid=vdb.FloatGrid()
grid.background=0.0accessor=grid.getAccessor()
# create a few blocks of active voxelson_list= [(5,5,5), (-5,-5,-5)]
forcoordsinon_list:
accessor.setValueOn(coords, 1.0)
# set a few off voxelsoff_list= [(-2,-2,-2),(2,2,2)]
forcoordsinoff_list:
accessor.setValueOff(coords, 5.0)
# check valuesunchanged= [(0,0,0)]
print("** initial values **")
forcoordsinitertools.chain(on_list, off_list, unchanged):
print(f"Voxel {coords} is {accessor.probeValue(coords)}")
# change backgroundgrid.background=-1.0print("** after background change to -1.0 **") # here, our custom inactive voxels are still at 5.0# check valuesforcoordsinitertools.chain(on_list, off_list, unchanged):
print(f"Voxel {coords} is {accessor.probeValue(coords)}")
# change background againgrid.background=math.nanprint("** after background change to nan **") # still at 5.0# check valuesforcoordsinitertools.chain(on_list, off_list, unchanged):
print(f"Voxel {coords} is {accessor.probeValue(coords)}")
# change background againgrid.background=-12.0print("** after background change to -12 **") # changed from 5.0 to -12# check valuesforcoordsinitertools.chain(on_list, off_list, unchanged):
print(f"Voxel {coords} is {accessor.probeValue(coords)}")
Output:
** initial values **
Voxel (5, 5, 5) is (1.0, True)
Voxel (-5, -5, -5) is (1.0, True)
Voxel (-2, -2, -2) is (5.0, False)
Voxel (2, 2, 2) is (5.0, False)
Voxel (0, 0, 0) is (0.0, False)
** after background change to -1.0 **
Voxel (5, 5, 5) is (1.0, True)
Voxel (-5, -5, -5) is (1.0, True)
Voxel (-2, -2, -2) is (5.0, False)
Voxel (2, 2, 2) is (5.0, False)
Voxel (0, 0, 0) is (-1.0, False)
** after background change to nan **
Voxel (5, 5, 5) is (1.0, True)
Voxel (-5, -5, -5) is (1.0, True)
Voxel (-2, -2, -2) is (5.0, False)
Voxel (2, 2, 2) is (5.0, False)
Voxel (0, 0, 0) is (nan, False)
** after background change to -12 **
Voxel (5, 5, 5) is (1.0, True)
Voxel (-5, -5, -5) is (1.0, True)
Voxel (-2, -2, -2) is (-12.0, False)
Voxel (2, 2, 2) is (-12.0, False)
Voxel (0, 0, 0) is (-12.0, False)
Expected behavior
Inactive voxels with a value different from the previous background value should not be changed when the background value is changed. This is specified in the documentation of tools::changeBackground which gets called when setting grid.background through the Python API
Additional context
As a side note, it is unclear from the python API that setting grid.background will change the values (by calling tools::changeBackground) instead of setting a reference value. Understanding this behaviour required digging through the pyopenvdb source code.
Environment
Operating System: Ubuntu 22.04
Version / Commit SHA: v9.1.0
Other: Using the Python bindings
Describe the bug
When setting the background value of a (Float) grid, if the previous background value was NaN, the values of all inactive voxels get changed to the new value.
To Reproduce
Example script:
Output:
Expected behavior
Inactive voxels with a value different from the previous background value should not be changed when the background value is changed. This is specified in the documentation of
tools::changeBackground
which gets called when settinggrid.background
through the Python APIAdditional context
As a side note, it is unclear from the python API that setting
grid.background
will change the values (by callingtools::changeBackground
) instead of setting a reference value. Understanding this behaviour required digging through the pyopenvdb source code.openvdb/openvdb/openvdb/python/pyGrid.h
Line 1476 in de7a496
openvdb/openvdb/openvdb/python/pyGrid.h
Line 119 in de7a496
The text was updated successfully, but these errors were encountered: