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-09-21 04:23:26 +0300
committerHans Goudey <h.goudey@me.com>2021-09-21 04:23:26 +0300
commit17021adceaee28295b89301b4f715b6bcd8d5fca (patch)
treea8854e95ccf4a895cf16d4dab389b9d0ec150b1c /source/blender/blenkernel/intern/curve_eval.cc
parent9e939a614ec5cda5dd6e5392bf9c209d21127c33 (diff)
Geometry Nodes: Curve Sample Node
This node allows sampling positions, tangents, and normals at any arbitrary point along a curve. The curve can include multiple splines, all are taken into account. The node does not yet support transferring generic attributes like radius, because some more general tooling will make that much more feasible and useful in different scenarios. This is a field node, so it is evaluated in the context of a data-flow node like "Set Position". One nice thing about that is it can easily be used to move an entire geometry like the follow path constraint. The point along the curve is chosen either with a factor of the total length of the curve, or a length into the curve, the same choice used in the curve trim node. Differential Revision: https://developer.blender.org/D12565
Diffstat (limited to 'source/blender/blenkernel/intern/curve_eval.cc')
-rw-r--r--source/blender/blenkernel/intern/curve_eval.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc
index ea84766943d..8eec7f5dfab 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -143,6 +143,23 @@ blender::Array<int> CurveEval::evaluated_point_offsets() const
return offsets;
}
+/**
+ * Return the accumulated length at the start of every spline in the curve.
+ *
+ * \note The result is one longer than the spline count; the last element is the total length.
+ */
+blender::Array<float> CurveEval::accumulated_spline_lengths() const
+{
+ Array<float> spline_lengths(splines_.size() + 1);
+ float spline_length = 0.0f;
+ for (const int i : splines_.index_range()) {
+ spline_lengths[i] = spline_length;
+ spline_length += splines_[i]->length();
+ }
+ spline_lengths.last() = spline_length;
+ return spline_lengths;
+}
+
static BezierSpline::HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type)
{
switch (dna_handle_type) {