Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-10-09 13:55:13 +0300
committerJacques Lucke <jacques@blender.org>2020-10-09 13:55:13 +0300
commit701fc52cc6dcbe4f3fd3af7070f1e985c280a7cb (patch)
treebea5d20fb8239d3c1dd0f0d94bc2bf1393b46718 /source/blender/modifiers
parent2f339eb745df31c3035c737a1013dc8bb450beb6 (diff)
Volumes: lower minimal voxel size in Mesh to Volume modifier
The 0.1 limit was too large. The issue with making it smaller is that one can easily crash blender by making it to small. To counteract this, the step has been reduced as well. A voxel size/amount of 0 disables the modifier.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_mesh_to_volume.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
index 6fdc78c6ce9..ba6c4207497 100644
--- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
+++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
@@ -181,9 +181,11 @@ static float compute_voxel_size(const MeshToVolumeModifierData *mvmd,
{
using namespace blender;
if (mvmd->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE) {
- return MAX2(0.0001, mvmd->voxel_size);
+ return mvmd->voxel_size;
+ }
+ if (mvmd->voxel_amount <= 0) {
+ return 0;
}
-
/* Compute the voxel size based on the desired number of voxels and the approximated bounding box
* of the volume. */
const BoundBox *bb = BKE_object_boundbox_get(mvmd->object);
@@ -194,7 +196,7 @@ static float compute_voxel_size(const MeshToVolumeModifierData *mvmd,
(transform.ref_3x3() * y_axis).length(),
(transform.ref_3x3() * z_axis).length()});
const float approximate_volume_side_length = max_dimension + mvmd->exterior_band_width * 2.0f;
- const float voxel_size = approximate_volume_side_length / MAX2(1, mvmd->voxel_amount);
+ const float voxel_size = approximate_volume_side_length / mvmd->voxel_amount;
return voxel_size;
}
@@ -218,6 +220,9 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
const float4x4 mesh_to_own_object_space_transform = float4x4(ctx->object->imat) *
float4x4(object_to_convert->obmat);
const float voxel_size = compute_voxel_size(mvmd, mesh_to_own_object_space_transform);
+ if (voxel_size == 0.0f) {
+ return input_volume;
+ }
float4x4 mesh_to_index_space_transform;
scale_m4_fl(mesh_to_index_space_transform.values, 1.0f / voxel_size);