[Bf-blender-cvs] [46bfc3ec465] geometry-nodes-curve-support: Splines: Add bounding box node support
Hans Goudey
noreply at git.blender.org
Sun Apr 25 22:50:54 CEST 2021
Commit: 46bfc3ec4653149fb29a3caf4a45dba417d0bd26
Author: Hans Goudey
Date: Sun Apr 25 15:50:46 2021 -0500
Branches: geometry-nodes-curve-support
https://developer.blender.org/rB46bfc3ec4653149fb29a3caf4a45dba417d0bd26
Splines: Add bounding box node support
===================================================================
M source/blender/blenkernel/BKE_spline.hh
M source/blender/blenkernel/intern/derived_curve.cc
M source/blender/blenkernel/intern/geometry_set.cc
M source/blender/blenkernel/intern/spline_base.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
index e4d2e366b56..4831805210f 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -130,6 +130,8 @@ class Spline {
blender::Span<blender::float3> evaluated_tangents() const;
blender::Span<blender::float3> evaluated_normals() const;
+ void bounds_min_max(blender::float3 &min, blender::float3 &max, const bool use_evaluated) const;
+
struct LookupResult {
/*
* The index of the evaluated point before the result location.
@@ -409,14 +411,11 @@ class DCurve {
public:
blender::Vector<SplinePtr> splines;
- // bool is_2d;
-
DCurve *copy();
- // DCurve *copy();
-
void translate(const blender::float3 translation);
void transform(const blender::float4x4 &matrix);
+ void bounds_min_max(blender::float3 &min, blender::float3 &max, const bool use_evaluated) const;
};
DCurve *dcurve_from_dna_curve(const Curve &curve);
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/derived_curve.cc b/source/blender/blenkernel/intern/derived_curve.cc
index 7d2fc201742..eed075f8b19 100644
--- a/source/blender/blenkernel/intern/derived_curve.cc
+++ b/source/blender/blenkernel/intern/derived_curve.cc
@@ -88,6 +88,13 @@ void DCurve::transform(const float4x4 &matrix)
}
}
+void DCurve::bounds_min_max(float3 &min, float3 &max, const bool use_evaluated) const
+{
+ for (const SplinePtr &spline : this->splines) {
+ spline->bounds_min_max(min, max, use_evaluated);
+ }
+}
+
static BezierSpline::HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type)
{
switch (dna_handle_type) {
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index 646afcc702f..533fb3f2f22 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -185,7 +185,13 @@ void GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_ma
if (volume != nullptr) {
BKE_volume_min_max(volume, *r_min, *r_max);
}
- /* TODO: Curve boundbox. */
+ const DCurve *curve = this->get_curve_for_read();
+ if (curve != nullptr) {
+ /* Note the the choice of using the evaluated positions is somewhat arbitrary, and may counter
+ * the idea that the curve is the reduced set of control point information, but it may also be
+ * the expected result. */
+ curve->bounds_min_max(*r_min, *r_max, true);
+ }
}
std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set)
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc
index f4e9ec73813..93535fd4036 100644
--- a/source/blender/blenkernel/intern/spline_base.cc
+++ b/source/blender/blenkernel/intern/spline_base.cc
@@ -329,3 +329,11 @@ Spline::LookupResult Spline::lookup_evaluated_length(const float length) const
return LookupResult{index, next_index, factor};
}
+
+void Spline::bounds_min_max(float3 &min, float3 &max, const bool use_evaluated) const
+{
+ Span<float3> positions = use_evaluated ? this->evaluated_positions() : this->positions();
+ for (const float3 &position : positions) {
+ minmax_v3v3_v3(min, max, position);
+ }
+}
More information about the Bf-blender-cvs
mailing list