Fix T104136: Crash with Mesh to Volume & Simplify

Blender crashes when Simplify is enabled and set to 0.
This is because mesh_to_volume_grid returns nullptr at voxel size 0.
A simple null-check fixes this problem.

Differential Revision: https://developer.blender.org/D17122
This commit is contained in:
Erik Abrahamsson 2023-02-01 20:50:39 +01:00
parent 9b86741ae7
commit a4868f2058
Notes: blender-bot 2023-10-18 15:23:11 +02:00
Referenced by issue #104136, Blender crash when use simplify with "mesh to volume" modifier
1 changed files with 6 additions and 4 deletions

View File

@ -159,12 +159,14 @@ VolumeGrid *volume_grid_add_from_mesh(Volume *volume,
interior_band_width,
density);
/* Merge the generated grid. Should be cheap because grid has just been created. */
grid->merge(*mesh_grid);
if (mesh_grid != nullptr) {
/* Merge the generated grid. Should be cheap because grid has just been created. */
grid->merge(*mesh_grid);
/* Change transform so that the index space is correctly transformed to object space. */
grid->transform().postScale(voxel_size);
}
/* Set class to "Fog Volume". */
grid->setGridClass(openvdb::GRID_FOG_VOLUME);
/* Change transform so that the index space is correctly transformed to object space. */
grid->transform().postScale(voxel_size);
return c_grid;
}
} // namespace blender::geometry