[Bf-blender-cvs] [622c4e4953a] master: Cleanup: Further clarification and renaming of curve field inputs

Hans Goudey noreply at git.blender.org
Thu May 5 12:21:36 CEST 2022


Commit: 622c4e4953a0bd774bcbe3e1051ff56dc1933282
Author: Hans Goudey
Date:   Thu May 5 12:21:17 2022 +0200
Branches: master
https://developer.blender.org/rB622c4e4953a0bd774bcbe3e1051ff56dc1933282

Cleanup: Further clarification and renaming of curve field inputs

Differentiate the total length of curves and the accumulated length
at each control point.

===================================================================

M	source/blender/blenkernel/intern/curve_poly.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
M	source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/curve_poly.cc b/source/blender/blenkernel/intern/curve_poly.cc
index 2db7cd71ad3..1b337379604 100644
--- a/source/blender/blenkernel/intern/curve_poly.cc
+++ b/source/blender/blenkernel/intern/curve_poly.cc
@@ -110,7 +110,7 @@ void calculate_normals_minimum(const Span<float3> tangents,
     normals.first() = math::normalize(float3(first_tangent.y, -first_tangent.x, 0.0f));
   }
 
-  /* Forward normal with minimum twist along the entire spline. */
+  /* Forward normal with minimum twist along the entire curve. */
   for (const int i : IndexRange(1, normals.size() - 1)) {
     normals[i] = calculate_next_normal(normals[i - 1], tangents[i - 1], tangents[i]);
   }
@@ -120,7 +120,7 @@ void calculate_normals_minimum(const Span<float3> tangents,
   }
 
   /* Compute how much the first normal deviates from the normal that has been forwarded along the
-   * entire cyclic spline. */
+   * entire cyclic curve. */
   const float3 uncorrected_last_normal = calculate_next_normal(
       normals.last(), tangents.last(), tangents.first());
   float correction_angle = angle_signed_on_axis_v3v3_v3(
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
index 5d97720a4f8..a548becf24e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
@@ -144,9 +144,9 @@ static VArray<float> construct_curve_parameter_varray(const bke::CurvesGeometry
   return {};
 }
 
-static VArray<float> construct_curve_length_varray(const bke::CurvesGeometry &curves,
-                                                   const IndexMask UNUSED(mask),
-                                                   const AttributeDomain domain)
+static VArray<float> construct_curve_length_parameter_varray(const bke::CurvesGeometry &curves,
+                                                             const IndexMask UNUSED(mask),
+                                                             const AttributeDomain domain)
 {
   curves.ensure_evaluated_lengths();
 
@@ -217,9 +217,9 @@ class CurveParameterFieldInput final : public GeometryFieldInput {
   }
 };
 
-class CurveLengthFieldInput final : public GeometryFieldInput {
+class CurveLengthParameterFieldInput final : public GeometryFieldInput {
  public:
-  CurveLengthFieldInput() : GeometryFieldInput(CPPType::get<float>(), "Curve Length node")
+  CurveLengthParameterFieldInput() : GeometryFieldInput(CPPType::get<float>(), "Curve Length node")
   {
     category_ = Category::Generated;
   }
@@ -233,7 +233,7 @@ class CurveLengthFieldInput final : public GeometryFieldInput {
       if (curve_component.has_curves()) {
         const Curves &curves_id = *curve_component.get_for_read();
         const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
-        return construct_curve_length_varray(curves, mask, domain);
+        return construct_curve_length_parameter_varray(curves, mask, domain);
       }
     }
     return {};
@@ -247,7 +247,7 @@ class CurveLengthFieldInput final : public GeometryFieldInput {
 
   bool is_equal_to(const fn::FieldNode &other) const override
   {
-    return dynamic_cast<const CurveLengthFieldInput *>(&other) != nullptr;
+    return dynamic_cast<const CurveLengthParameterFieldInput *>(&other) != nullptr;
   }
 };
 
@@ -288,7 +288,7 @@ class IndexOnSplineFieldInput final : public GeometryFieldInput {
 static void node_geo_exec(GeoNodeExecParams params)
 {
   Field<float> parameter_field{std::make_shared<CurveParameterFieldInput>()};
-  Field<float> length_field{std::make_shared<CurveLengthFieldInput>()};
+  Field<float> length_field{std::make_shared<CurveLengthParameterFieldInput>()};
   Field<int> index_on_spline_field{std::make_shared<IndexOnSplineFieldInput>()};
   params.set_output("Factor", std::move(parameter_field));
   params.set_output("Length", std::move(length_field));
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc b/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
index 0b1bc03360e..db1b0d5a2f8 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
@@ -10,8 +10,8 @@ namespace blender::nodes {
  * Spline Length
  */
 
-static VArray<float> construct_spline_length_gvarray(const CurveComponent &component,
-                                                     const AttributeDomain domain)
+static VArray<float> construct_curve_length_gvarray(const CurveComponent &component,
+                                                    const AttributeDomain domain)
 {
   if (!component.has_curves()) {
     return {};
@@ -51,7 +51,7 @@ GVArray CurveLengthFieldInput::get_varray_for_context(const GeometryComponent &c
 {
   if (component.type() == GEO_COMPONENT_TYPE_CURVE) {
     const CurveComponent &curve_component = static_cast<const CurveComponent &>(component);
-    return construct_spline_length_gvarray(curve_component, domain);
+    return construct_curve_length_gvarray(curve_component, domain);
   }
   return {};
 }
@@ -81,8 +81,8 @@ static void node_declare(NodeDeclarationBuilder &b)
  * Spline Count
  */
 
-static VArray<int> construct_spline_count_gvarray(const CurveComponent &component,
-                                                  const AttributeDomain domain)
+static VArray<int> construct_curve_point_count_gvarray(const CurveComponent &component,
+                                                       const AttributeDomain domain)
 {
   if (!component.has_curves()) {
     return {};
@@ -117,7 +117,7 @@ class SplineCountFieldInput final : public GeometryFieldInput {
   {
     if (component.type() == GEO_COMPONENT_TYPE_CURVE) {
       const CurveComponent &curve_component = static_cast<const CurveComponent &>(component);
-      return construct_spline_count_gvarray(curve_component, domain);
+      return construct_curve_point_count_gvarray(curve_component, domain);
     }
     return {};
   }



More information about the Bf-blender-cvs mailing list