Differential D16083 Diff 56395 source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
| Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | threading::parallel_for(curves.curves_range(), 1024, [&](IndexRange range) { | ||||
| cyclic[i_curve]); | cyclic[i_curve]); | ||||
| MutableSpan<float> curve_lengths = lengths.slice(curves.points_for_curve(i_curve)); | MutableSpan<float> curve_lengths = lengths.slice(curves.points_for_curve(i_curve)); | ||||
| if (total_length > 0.0f) { | if (total_length > 0.0f) { | ||||
| const float factor = 1.0f / total_length; | const float factor = 1.0f / total_length; | ||||
| for (float &value : curve_lengths) { | for (float &value : curve_lengths) { | ||||
| value *= factor; | value *= factor; | ||||
| } | } | ||||
| } | } | ||||
| else if (curve_lengths.size() == 1) { | |||||
| /* The curve is a single point. */ | |||||
| curve_lengths[0] = 0.0f; | |||||
| } | |||||
| else { | else { | ||||
| /* It is arbitrary what to do in those rare cases when all the points are | /* It is arbitrary what to do in those rare cases when all the points are | ||||
| * in the same position. In this case we are just arbitrarily giving a valid | * in the same position. In this case we are just arbitrarily giving a valid | ||||
| * value in the range based on the point index. */ | * value in the range based on the point index. */ | ||||
| for (const int i : curve_lengths.index_range()) { | for (const int i : curve_lengths.index_range()) { | ||||
| curve_lengths[i] = i / (curve_lengths.size() - 1.0f); | curve_lengths[i] = i / (curve_lengths.size() - 1.0f); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | uint64_t hash() const override | ||||
| /* Some random constant hash. */ | /* Some random constant hash. */ | ||||
| return 4536246522; | return 4536246522; | ||||
| } | } | ||||
| bool is_equal_to(const fn::FieldNode &other) const override | bool is_equal_to(const fn::FieldNode &other) const override | ||||
| { | { | ||||
| return dynamic_cast<const IndexOnSplineFieldInput *>(&other) != nullptr; | return dynamic_cast<const IndexOnSplineFieldInput *>(&other) != nullptr; | ||||
| } | } | ||||
| std::optional<eAttrDomain> preferred_domain(const CurvesGeometry & /*curves*/) const | |||||
| { | |||||
| return ATTR_DOMAIN_POINT; | |||||
| } | |||||
| }; | }; | ||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| Field<float> parameter_field{std::make_shared<CurveParameterFieldInput>()}; | Field<float> parameter_field{std::make_shared<CurveParameterFieldInput>()}; | ||||
| Field<float> length_field{std::make_shared<CurveLengthParameterFieldInput>()}; | Field<float> length_field{std::make_shared<CurveLengthParameterFieldInput>()}; | ||||
| Field<int> index_on_spline_field{std::make_shared<IndexOnSplineFieldInput>()}; | Field<int> index_on_spline_field{std::make_shared<IndexOnSplineFieldInput>()}; | ||||
| params.set_output("Factor", std::move(parameter_field)); | params.set_output("Factor", std::move(parameter_field)); | ||||
| Show All 17 Lines | |||||