Cleanup: Further clarification and renaming of curve field inputs

Differentiate the total length of curves and the accumulated length
at each control point.
This commit is contained in:
Hans Goudey
2022-05-05 12:21:17 +02:00
parent c7a345bd60
commit 622c4e4953
3 changed files with 16 additions and 16 deletions

View File

@@ -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(

View File

@@ -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));

View File

@@ -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 {};
}