diff options
author | Jacques Lucke <jacques@blender.org> | 2020-10-12 13:13:01 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-10-12 13:13:09 +0300 |
commit | 7ae78733ef3e6dac3776748d7b97a044fde87005 (patch) | |
tree | 134332b5621037522ee5050795cd2d338e7ee7fc /source/blender/modifiers/intern/MOD_mesh_to_volume.cc | |
parent | cf778a9e423700b8e0595087bcdf2831a160ac82 (diff) |
Volumes: use bounding box diagonal to compute adaptive voxel size
Using the diagonal has the benefit, that the adaptive voxel size changes
when the bounding box changes its shape in any way. Having a changing
voxel size looks bad when rendering an animation, therefore one should
usually use a fixed voxel size when rendering an animated volume.
This becomes apparent earlier, when the adaptive voxel size changes
when the bounding box changes in any way.
Otherwise this can easily go unnoticed when rendering only a few frames
of an animated volume.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_mesh_to_volume.cc')
-rw-r--r-- | source/blender/modifiers/intern/MOD_mesh_to_volume.cc | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc index ba6c4207497..508c84c3e8f 100644 --- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc +++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc @@ -189,13 +189,9 @@ static float compute_voxel_size(const MeshToVolumeModifierData *mvmd, /* 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); - const float3 x_axis = float3(bb->vec[4]) - float3(bb->vec[0]); - const float3 y_axis = float3(bb->vec[3]) - float3(bb->vec[0]); - const float3 z_axis = float3(bb->vec[1]) - float3(bb->vec[0]); - const float max_dimension = std::max({(transform.ref_3x3() * x_axis).length(), - (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 diagonal = float3::distance(transform * float3(bb->vec[6]), + transform * float3(bb->vec[0])); + const float approximate_volume_side_length = diagonal + mvmd->exterior_band_width * 2.0f; const float voxel_size = approximate_volume_side_length / mvmd->voxel_amount; return voxel_size; } |