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:
authorHans Goudey <h.goudey@me.com>2022-06-29 20:28:08 +0300
committerHans Goudey <h.goudey@me.com>2022-06-29 20:28:08 +0300
commit0ea282f7462070041b2599389ba61c7ef50426b5 (patch)
tree0c7468364f5c34d3bea3379f261717b3673503ac /source/blender/geometry
parent4593fb52cf809de29bffa8f18af9a9a792def30d (diff)
Geometry Nodes: Only calculate mesh to volume bounds when necessary
In "size" voxel resolution mode, calculating the bounds of the mesh to volume node's input mesh isn't necessary. For high poly this can take a few milliseconds, so this commit skips the calculation unless we need it for the "Amount" mode. Differential Revision: https://developer.blender.org/D15324
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);