diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-29 20:28:08 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-29 20:28:08 +0300 |
commit | 0ea282f7462070041b2599389ba61c7ef50426b5 (patch) | |
tree | 0c7468364f5c34d3bea3379f261717b3673503ac /source/blender/geometry/intern/mesh_to_volume.cc | |
parent | 4593fb52cf809de29bffa8f18af9a9a792def30d (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/intern/mesh_to_volume.cc')
-rw-r--r-- | source/blender/geometry/intern/mesh_to_volume.cc | 8 |
1 files changed, 6 insertions, 2 deletions
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); |