Fix #145762: Ensure a valid background value before pruning SDF grid
OpenVDB will throw an exception when trying to prune a SDF/Level-Set grid with a negative background value. The geometry nodes in this case are constructing a nominal SDF grid from a generic "density" volume cube. The negative background value results from processing the background value the same way as all other grid values in the new field+grid math feature (`blender::nodes::process_background`). Since any grid can be constructed with a negative background value we have to check and correct this before calling the OpenVDB prune function. Pull Request: https://projects.blender.org/blender/blender/pulls/146837
This commit is contained in:
@@ -28,6 +28,11 @@ openvdb::FloatGrid &resample_sdf_grid_if_necessary(bke::VolumeGrid<float> &volum
|
||||
|
||||
/* TODO: Using #doResampleToMatch when the transform is affine and non-scaled may be faster. */
|
||||
openvdb::tools::resampleToMatch<openvdb::tools::BoxSampler>(grid, *storage);
|
||||
/* Ensure valid background value for level set grids, otherwise pruning will throw an exception.
|
||||
*/
|
||||
if (storage->background() < 0.0f) {
|
||||
storage->tree().root().setBackground(0.0f, true);
|
||||
}
|
||||
openvdb::tools::pruneLevelSet(storage->tree());
|
||||
|
||||
return *storage;
|
||||
|
||||
Reference in New Issue
Block a user