Fix T82016: Cycles assert with empty OpenVDB volumes

This commit is contained in:
Brecht Van Lommel 2020-11-04 15:50:32 +01:00
parent 3ffa0452af
commit 4dddd54393
Notes: blender-bot 2023-02-14 06:00:47 +01:00
Referenced by issue #82016, Crash on Cycles render preview when using Volume objects
1 changed files with 6 additions and 1 deletions

View File

@ -438,10 +438,15 @@ static openvdb::GridBase::ConstPtr openvdb_grid_from_device_texture(device_textu
image_memory->data_width - 1,
image_memory->data_height - 1,
image_memory->data_depth - 1);
typename GridType::Ptr sparse = GridType::create(ValueType(0.0f));
if (dense_bbox.empty()) {
return sparse;
}
openvdb::tools::Dense<ValueType, openvdb::tools::MemoryLayout::LayoutXYZ> dense(
dense_bbox, static_cast<ValueType *>(image_memory->host_pointer));
typename GridType::Ptr sparse = GridType::create(ValueType(0.0f));
openvdb::tools::copyFromDense(dense, *sparse, ValueType(volume_clipping));
/* #copyFromDense will remove any leaf node that contains constant data and replace it with a