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>2021-06-08 18:51:52 +0300
committerHans Goudey <h.goudey@me.com>2021-06-08 18:51:52 +0300
commitf5a2d932249ad9639bdc1f8ebd73120d9d71ad20 (patch)
tree97e67f0aba6f15d5aa4ee26d091d95b08e07b4d5 /source/blender/nodes
parenta31bd2609f04368136dada7c4024c7547e8723f5 (diff)
Geometry Nodes: Support curve instances in the bounding box node
Currently curve instances are misleading, since `CurveEval` is created from scratch from the original `Curve`, but this won't always be true.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc27
1 files changed, 27 insertions, 0 deletions
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 b6fa4c0d48f..f1731052515 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,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "BKE_spline.hh"
#include "BKE_volume.h"
#include "node_geometry_util.hh"
@@ -81,6 +82,28 @@ static void compute_min_max_from_volume_and_transforms(const VolumeComponent &vo
#endif
}
+static void compute_min_max_from_curve_and_transforms(const CurveComponent &curve_component,
+ Span<float4x4> transforms,
+ float3 &r_min,
+ float3 &r_max)
+{
+ const CurveEval *curve = curve_component.get_for_read();
+ if (curve == nullptr) {
+ return;
+ }
+ for (const SplinePtr &spline : curve->splines()) {
+ Span<float3> positions = spline->evaluated_positions();
+
+ for (const float4x4 &transform : transforms) {
+ for (const int i : positions.index_range()) {
+ const float3 position = positions[i];
+ const float3 transformed_position = transform * position;
+ minmax_v3v3_v3(r_min, r_max, transformed_position);
+ }
+ }
+ }
+}
+
static void compute_geometry_set_instances_boundbox(const GeometrySet &geometry_set,
float3 &r_min,
float3 &r_max)
@@ -104,6 +127,10 @@ static void compute_geometry_set_instances_boundbox(const GeometrySet &geometry_
compute_min_max_from_volume_and_transforms(
*set.get_component_for_read<VolumeComponent>(), transforms, r_min, r_max);
}
+ if (set.has<CurveComponent>()) {
+ compute_min_max_from_curve_and_transforms(
+ *set.get_component_for_read<CurveComponent>(), transforms, r_min, r_max);
+ }
}
}