[Bf-blender-cvs] [7ae78733ef3] master: Volumes: use bounding box diagonal to compute adaptive voxel size

Jacques Lucke noreply at git.blender.org
Mon Oct 12 12:30:57 CEST 2020


Commit: 7ae78733ef3e6dac3776748d7b97a044fde87005
Author: Jacques Lucke
Date:   Mon Oct 12 12:13:01 2020 +0200
Branches: master
https://developer.blender.org/rB7ae78733ef3e6dac3776748d7b97a044fde87005

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.

===================================================================

M	source/blender/modifiers/intern/MOD_mesh_to_volume.cc

===================================================================

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;
 }



More information about the Bf-blender-cvs mailing list