16 N_(
"For points, the portion of the spline's total length at the control point. For "
17 "Splines, the factor of that spline within the entire curve"));
21 N_(
"For points, the distance along the control point's spline, For splines, the "
22 "distance along the entire curve"));
35 curves.ensure_evaluated_lengths();
40 for (
const int i :
curves.curves_range()) {
42 length +=
curves.evaluated_length_total_for_curve(i, cyclic[i]);
60 curves.ensure_evaluated_lengths();
68 for (const int i_curve : range) {
69 const IndexRange points = curves.points_for_curve(i_curve);
70 const Span<float> evaluated_lengths = curves.evaluated_lengths_for_curve(i_curve,
72 MutableSpan<float> lengths = result.as_mutable_span().slice(points);
73 lengths.first() = 0.0f;
74 switch (types[i_curve]) {
75 case CURVE_TYPE_CATMULL_ROM: {
76 const int resolution = resolutions[i_curve];
77 for (const int i : IndexRange(points.size()).drop_back(1)) {
78 lengths[i + 1] = evaluated_lengths[resolution * (i + 1) - 1];
83 lengths.drop_front(1).copy_from(evaluated_lengths.take_front(lengths.size() - 1));
85 case CURVE_TYPE_BEZIER: {
86 const Span<int> offsets = curves.bezier_evaluated_offsets_for_curve(i_curve);
87 for (const int i : IndexRange(points.size()).drop_back(1)) {
88 lengths[i + 1] = evaluated_lengths[offsets[i] - 1];
92 case CURVE_TYPE_NURBS: {
93 const Span<float3> positions = curves.positions().slice(points);
95 for (const int i : positions.index_range().drop_back(1)) {
97 length += math::distance(positions[i], positions[i + 1]);
99 lengths.last() = length;
119 for (const int i_curve : range) {
120 const float total_length = curves.evaluated_length_total_for_curve(i_curve,
122 MutableSpan<float> curve_lengths = lengths.slice(curves.points_for_curve(i_curve));
123 if (total_length > 0.0f) {
124 const float factor = 1.0f / total_length;
125 for (float &value : curve_lengths) {
129 else if (curve_lengths.size() == 1) {
131 curve_lengths[0] = 0.0f;
137 for (const int i : curve_lengths.index_range()) {
138 curve_lengths[i] = i / (curve_lengths.size() - 1.0f);
149 const int last_index =
curves.curves_num() - 1;
150 const float total_length = lengths.
last() +
curves.evaluated_length_total_for_curve(
151 last_index, cyclic[last_index]);
152 if (total_length > 0.0f) {
153 const float factor = 1.0f / total_length;
154 for (
float &value : lengths) {
163 lengths[i] = i / (lengths.
size() - 1.0f);
175 curves.ensure_evaluated_lengths();
198 for (const int i_curve : range) {
199 MutableSpan<int> indices = span.slice(curves.points_for_curve(i_curve));
200 for (const int i : indices.index_range()) {
214 category_ = Category::Generated;
248 category_ = Category::Generated;
282 category_ = Category::Generated;
314 Field<float> parameter_field{std::make_shared<CurveParameterFieldInput>()};
315 Field<float> length_field{std::make_shared<CurveLengthParameterFieldInput>()};
316 Field<int> index_on_spline_field{std::make_shared<IndexOnSplineFieldInput>()};
317 params.set_output(
"Factor", std::move(parameter_field));
318 params.set_output(
"Length", std::move(length_field));
319 params.set_output(
"Index", std::move(index_on_spline_field));
typedef float(TangentPoint)[2]
Low-level operations for curves.
@ GEO_COMPONENT_TYPE_CURVE
#define GEO_NODE_CURVE_SPLINE_PARAMETER
void nodeRegisterType(struct bNodeType *ntype)
static uint8 component(Color32 c, uint i)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
const Curves * get_for_read() const
const T & last(const int64_t n=0) const
IndexRange index_range() const
static VArray ForContainer(ContainerT container)
StringRefNull description() const
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static struct PartialUpdateUser * wrap(PartialUpdateUserImpl *user)
T length(const vec_base< T, Size > &a)
static void node_declare(NodeDeclarationBuilder &b)
static Array< float > accumulated_lengths_curve_domain(const bke::CurvesGeometry &curves)
static void node_geo_exec(GeoNodeExecParams params)
static Array< float > curve_length_point_domain(const bke::CurvesGeometry &curves)
static VArray< int > construct_index_on_spline_varray(const bke::CurvesGeometry &curves, const IndexMask UNUSED(mask), const eAttrDomain domain)
static VArray< float > construct_curve_length_parameter_varray(const bke::CurvesGeometry &curves, const IndexMask UNUSED(mask), const eAttrDomain domain)
static VArray< float > construct_curve_parameter_varray(const bke::CurvesGeometry &curves, const IndexMask UNUSED(mask), const eAttrDomain domain)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_curve_spline_parameter()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
unsigned __int64 uint64_t
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare