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:
-rw-r--r--source/blender/blenkernel/intern/geometry_set.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc36
2 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index fd86f4e550c..3e457e48076 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -178,6 +178,10 @@ void GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_ma
if (mesh != nullptr) {
BKE_mesh_wrapper_minmax(mesh, *r_min, *r_max);
}
+ const Volume *volume = this->get_volume_for_read();
+ if (volume != nullptr) {
+ BKE_volume_min_max(volume, *r_min, *r_max);
+ }
}
std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
index 702fca242ea..96455f080e7 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
@@ -14,6 +14,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "BKE_volume.h"
+
#include "node_geometry_util.hh"
static bNodeSocketTemplate geo_node_bounding_box_in[] = {
@@ -52,6 +54,36 @@ static void compute_min_max_from_position_and_transform(const GeometryComponent
}
}
+static void compute_min_max_from_volume_and_transforms(const VolumeComponent &volume_component,
+ Span<float4x4> transforms,
+ float3 &r_min,
+ float3 &r_max)
+{
+#ifdef WITH_OPENVDB
+ const Volume *volume = volume_component.get_for_read();
+ if (volume == nullptr) {
+ return;
+ }
+ for (const int i : IndexRange(BKE_volume_num_grids(volume))) {
+ const VolumeGrid *volume_grid = BKE_volume_grid_get_for_read(volume, i);
+ openvdb::GridBase::ConstPtr grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
+
+ for (const float4x4 &transform : transforms) {
+ openvdb::GridBase::ConstPtr instance_grid = BKE_volume_grid_shallow_transform(grid,
+ transform);
+ float3 grid_min = float3(FLT_MAX);
+ float3 grid_max = float3(-FLT_MAX);
+ if (BKE_volume_grid_bounds(instance_grid, grid_min, grid_max)) {
+ DO_MIN(grid_min, r_min);
+ DO_MAX(grid_max, r_max);
+ }
+ }
+ }
+#else
+ UNUSED_VARS(volume_component, transforms, r_min, r_max);
+#endif
+}
+
static void compute_geometry_set_instances_boundbox(const GeometrySet &geometry_set,
float3 &r_min,
float3 &r_max)
@@ -71,6 +103,10 @@ static void compute_geometry_set_instances_boundbox(const GeometrySet &geometry_
compute_min_max_from_position_and_transform(
*set.get_component_for_read<MeshComponent>(), transforms, r_min, r_max);
}
+ if (set.has<VolumeComponent>()) {
+ compute_min_max_from_volume_and_transforms(
+ *set.get_component_for_read<VolumeComponent>(), transforms, r_min, r_max);
+ }
}
}