Fix #124160: crash when trying to load unavailable grid
The openvdb API was used incorrectly before. I didn't notice that this is a static function and requires the type to be passed in. Note that this does not solve the cache invalidation issue yet. Instead it handles the case more gracefully when the stored .vdb file changes when Blender doesn't expect it to change.
This commit is contained in:
parent
e969769a0c
commit
e4c9b73051
@ -275,14 +275,17 @@ void VolumeGridData::ensure_grid_loaded() const
|
||||
});
|
||||
if (!loaded_grid) {
|
||||
if (grid_) {
|
||||
/* Create a dummy grid of the expected type. */
|
||||
loaded_grid = grid_->createGrid("");
|
||||
}
|
||||
else {
|
||||
/* Create a dummy grid. We can't really know the expected data type here. */
|
||||
loaded_grid = openvdb::FloatGrid::create();
|
||||
const openvdb::Name &grid_type = grid_->type();
|
||||
if (openvdb::GridBase::isRegistered(grid_type)) {
|
||||
/* Create a dummy grid of the expected type. */
|
||||
loaded_grid = openvdb::GridBase::createGrid(grid_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!loaded_grid) {
|
||||
/* Create a dummy grid. We can't really know the expected data type here. */
|
||||
loaded_grid = openvdb::FloatGrid::create();
|
||||
}
|
||||
BLI_assert(loaded_grid);
|
||||
BLI_assert(loaded_grid.unique());
|
||||
BLI_assert(loaded_grid->isTreeUnique());
|
||||
|
Loading…
Reference in New Issue
Block a user