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:
Diffstat (limited to 'source/blender/geometry')
-rw-r--r--source/blender/geometry/GEO_mesh_to_volume.hh9
-rw-r--r--source/blender/geometry/intern/mesh_to_volume.cc8
2 files changed, 13 insertions, 4 deletions
diff --git a/source/blender/geometry/GEO_mesh_to_volume.hh b/source/blender/geometry/GEO_mesh_to_volume.hh
index 384293df336..c95b472936b 100644
--- a/source/blender/geometry/GEO_mesh_to_volume.hh
+++ b/source/blender/geometry/GEO_mesh_to_volume.hh
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_float4x4.hh"
+#include "BLI_function_ref.hh"
#include "BLI_string_ref.hh"
#include "DNA_mesh_types.h"
@@ -28,9 +29,13 @@ struct MeshToVolumeResolution {
};
#ifdef WITH_OPENVDB
+
+/**
+ * \param bounds_fn: Return the bounds of the mesh positions,
+ * used for deciding the voxel size in "Amount" mode.
+ */
float volume_compute_voxel_size(const Depsgraph *depsgraph,
- const float3 &bb_min,
- const float3 &bb_max,
+ FunctionRef<void(float3 &r_min, float3 &r_max)> bounds_fn,
const MeshToVolumeResolution resolution,
float exterior_band_width,
const float4x4 &transform);
diff --git a/source/blender/geometry/intern/mesh_to_volume.cc b/source/blender/geometry/intern/mesh_to_volume.cc
index 93a424f9a94..ae98b048a6c 100644
--- a/source/blender/geometry/intern/mesh_to_volume.cc
+++ b/source/blender/geometry/intern/mesh_to_volume.cc
@@ -64,8 +64,7 @@ void OpenVDBMeshAdapter::getIndexSpacePoint(size_t polygon_index,
}
float volume_compute_voxel_size(const Depsgraph *depsgraph,
- const float3 &bb_min,
- const float3 &bb_max,
+ FunctionRef<void(float3 &r_min, float3 &r_max)> bounds_fn,
const MeshToVolumeResolution res,
const float exterior_band_width,
const float4x4 &transform)
@@ -81,6 +80,11 @@ float volume_compute_voxel_size(const Depsgraph *depsgraph,
if (res.settings.voxel_amount <= 0) {
return 0;
}
+
+ float3 bb_min;
+ float3 bb_max;
+ bounds_fn(bb_min, bb_max);
+
/* Compute the voxel size based on the desired number of voxels and the approximated bounding
* box of the volume. */
const float diagonal = math::distance(transform * bb_max, transform * bb_min);