Fix: Points to Volume node crashes with too small radius

OpenVDB likes to crash even in release builds when volumes become too small.
To fix this I used the same function that we use in other places already to
determine if the resulting volume will be too small.
This commit is contained in:
Jacques Lucke 2022-12-09 11:42:10 +01:00
parent f06a1368bb
commit 122d6d67e6
1 changed files with 6 additions and 1 deletions

View File

@ -209,9 +209,14 @@ static void initialize_volume_component_from_points(GeoNodeExecParams &params,
}
}
if (positions.is_empty()) {
return;
}
const float max_radius = *std::max_element(radii.begin(), radii.end());
const float voxel_size = compute_voxel_size(params, positions, max_radius);
if (voxel_size == 0.0f || positions.is_empty()) {
const double determinant = std::pow<double>(voxel_size, 3.0);
if (!BKE_volume_grid_determinant_valid(determinant)) {
return;
}