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/nodes/geometry | |
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/nodes/geometry')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc index 9d8a77c3947..5890e070b2f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc @@ -106,18 +106,22 @@ static Volume *create_volume_from_mesh(const Mesh &mesh, GeoNodeExecParams ¶ } } - float3 min, max; - INIT_MINMAX(min, max); - if (!BKE_mesh_wrapper_minmax(&mesh, min, max)) { - min = float3(-1.0f); - max = float3(1.0f); + if (mesh.totvert == 0 || mesh.totpoly == 0) { + return nullptr; } const float4x4 mesh_to_volume_space_transform = float4x4::identity(); + auto bounds_fn = [&](float3 &r_min, float3 &r_max) { + float3 min{std::numeric_limits<float>::max()}; + float3 max{-std::numeric_limits<float>::max()}; + BKE_mesh_wrapper_minmax(&mesh, min, max); + r_min = min; + r_max = max; + }; + const float voxel_size = geometry::volume_compute_voxel_size(params.depsgraph(), - min, - max, + bounds_fn, resolution, exterior_band_width, mesh_to_volume_space_transform); |