Blender V5.3
node_geo_curve_sample.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_math_color.hh"
7#include "BLI_math_vector.hh"
8
11
12#include "BKE_curves.hh"
13
15#include "UI_resources.hh"
16
18
19#include "node_geometry_util.hh"
20
22
24
26{
27 b.add_input<decl::Geometry>("Curves"_ustr)
29 .supported_type(GeometryComponent::Type::Curve)
30 .description("Curves to sample positions on");
31
32 if (const bNode *node = b.node_or_null()) {
33 const NodeGeometryCurveSample &storage = node_storage(*node);
34 b.add_input(eCustomDataType(storage.data_type), "Value"_ustr)
35 .hide_value()
36 .evaluated_geometry_field();
37 }
38
39 auto &factor = b.add_input<decl::Float>("Factor"_ustr)
40 .min(0.0f)
41 .max(1.0f)
43 .structure_type(StructureType::Dynamic)
44 .make_available([](bNode &node) {
45 node_storage(node).mode = GEO_NODE_CURVE_SAMPLE_FACTOR;
46 });
47 auto &length = b.add_input<decl::Float>("Length"_ustr)
48 .min(0.0f)
50 .structure_type(StructureType::Dynamic)
51 .make_available([](bNode &node) {
52 node_storage(node).mode = GEO_NODE_CURVE_SAMPLE_LENGTH;
53 });
54 auto &index = b.add_input<decl::Int>("Curve Index"_ustr)
55 .structure_type(StructureType::Dynamic)
56 .make_available(
57 [](bNode &node) { node_storage(node).use_all_curves = false; });
58
59 const std::array<int, 3> dynamic_inputs = {factor.index(), length.index(), index.index()};
60
61 if (const bNode *node = b.node_or_null()) {
62 const NodeGeometryCurveSample &storage = node_storage(*node);
63 const GeometryNodeCurveSampleMode mode = GeometryNodeCurveSampleMode(storage.mode);
64 b.add_output(eCustomDataType(storage.data_type), "Value"_ustr)
65 .propagate_references(dynamic_inputs)
66 .inferred_structure_type(dynamic_inputs);
67
68 factor.available(mode == GEO_NODE_CURVE_SAMPLE_FACTOR);
69 length.available(mode == GEO_NODE_CURVE_SAMPLE_LENGTH);
70 index.available(!storage.use_all_curves);
71 }
72
73 b.add_output<decl::Vector>("Position"_ustr)
74 .propagate_references(dynamic_inputs)
75 .inferred_structure_type(dynamic_inputs);
76 b.add_output<decl::Vector>("Tangent"_ustr)
77 .propagate_references(dynamic_inputs)
78 .inferred_structure_type(dynamic_inputs);
79 b.add_output<decl::Vector>("Normal"_ustr)
80 .propagate_references(dynamic_inputs)
81 .inferred_structure_type(dynamic_inputs);
82}
83
84static void node_layout(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
85{
86 layout.prop(ptr, "data_type", UI_ITEM_NONE, "", ICON_NONE);
87 layout.prop(ptr, "mode", ui::ITEM_R_EXPAND, std::nullopt, ICON_NONE);
88 layout.prop(ptr, "use_all_curves", UI_ITEM_NONE, std::nullopt, ICON_NONE);
89}
90
91static void node_init(bNodeTree * /*tree*/, bNode *node)
92{
93 NodeGeometryCurveSample *data = MEM_new<NodeGeometryCurveSample>(__func__);
95 data->use_all_curves = false;
96 data->data_type = CD_PROP_FLOAT;
97 node->storage = data;
98}
99
101{
102 const NodeDeclaration &declaration = *params.node_type().static_declaration;
103 search_link_ops_for_declarations(params, declaration.inputs.as_span().take_front(1));
104 search_link_ops_for_declarations(params, declaration.inputs.as_span().take_back(3));
105 search_link_ops_for_declarations(params, declaration.outputs.as_span().take_back(3));
106
107 const std::optional<eCustomDataType> type = bke::socket_type_to_custom_data_type(
108 params.other_socket().type);
109 if (type && *type != CD_PROP_STRING) {
110 /* The input and output sockets have the same name. */
111 params.add_item(IFACE_("Value"), [type](LinkSearchOpParams &params) {
112 bNode &node = params.add_node("GeometryNodeSampleCurve"_ustr);
113 node_storage(node).data_type = *type;
114 params.update_and_connect_available_socket(node, "Value"_ustr);
115 });
116 }
117}
118
119static void sample_indices_and_lengths(const Span<float> accumulated_lengths,
120 const Span<float> sample_lengths,
121 const GeometryNodeCurveSampleMode length_mode,
122 const IndexMask &mask,
123 MutableSpan<int> r_segment_indices,
124 MutableSpan<float> r_length_in_segment)
125{
126 const float total_length = accumulated_lengths.last();
128
129 mask.foreach_index([&](const int i) {
130 const float sample_length = length_mode == GEO_NODE_CURVE_SAMPLE_FACTOR ?
131 sample_lengths[i] * total_length :
132 sample_lengths[i];
133 int segment_i;
134 float factor_in_segment;
135 length_parameterize::sample_at_length(accumulated_lengths,
136 std::clamp(sample_length, 0.0f, total_length),
137 segment_i,
138 factor_in_segment,
139 &hint);
140 const float segment_start = segment_i == 0 ? 0.0f : accumulated_lengths[segment_i - 1];
141 const float segment_end = accumulated_lengths[segment_i];
142 const float segment_length = segment_end - segment_start;
143
144 r_segment_indices[i] = segment_i;
145 r_length_in_segment[i] = factor_in_segment * segment_length;
146 });
147}
148
149static void sample_indices_and_factors_to_compressed(const Span<float> accumulated_lengths,
150 const Span<float> sample_lengths,
151 const GeometryNodeCurveSampleMode length_mode,
152 const IndexMask &mask,
153 MutableSpan<int> r_segment_indices,
154 MutableSpan<float> r_factor_in_segment)
155{
156 const float total_length = accumulated_lengths.last();
158
159 switch (length_mode) {
161 mask.foreach_index([&](const int i, const int pos) {
162 const float length = sample_lengths[i] * total_length;
163 length_parameterize::sample_at_length(accumulated_lengths,
164 std::clamp(length, 0.0f, total_length),
165 r_segment_indices[pos],
166 r_factor_in_segment[pos],
167 &hint);
168 });
169 break;
171 mask.foreach_index([&](const int i, const int pos) {
172 const float length = sample_lengths[i];
173 length_parameterize::sample_at_length(accumulated_lengths,
174 std::clamp(length, 0.0f, total_length),
175 r_segment_indices[pos],
176 r_factor_in_segment[pos],
177 &hint);
178 });
179 break;
180 }
181}
182
187class SampleFloatSegmentsFunction : public mf::MultiFunction {
188 private:
189 Array<float> accumulated_lengths_;
190 GeometryNodeCurveSampleMode length_mode_;
191
192 public:
194 const GeometryNodeCurveSampleMode length_mode)
195 : accumulated_lengths_(std::move(accumulated_lengths)), length_mode_(length_mode)
196 {
197 static const mf::Signature signature = []() {
198 mf::Signature signature;
199 mf::SignatureBuilder builder{"Sample Curve Index", signature};
200 builder.single_input<float>("Length");
201
202 builder.single_output<int>("Curve Index");
203 builder.single_output<float>("Length in Curve");
204 return signature;
205 }();
206 this->set_signature(&signature);
207 }
208
209 void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override
210 {
211 const VArraySpan<float> lengths = params.readonly_single_input<float>(0, "Length");
212 MutableSpan<int> indices = params.uninitialized_single_output<int>(1, "Curve Index");
213 MutableSpan<float> lengths_in_segments = params.uninitialized_single_output<float>(
214 2, "Length in Curve");
215
217 accumulated_lengths_, lengths, length_mode_, mask, indices, lengths_in_segments);
218 }
219};
220
221class SampleCurveFunction : public mf::MultiFunction {
222 private:
228 GeometrySet geometry_set_;
229 GField src_field_;
230 GeometryNodeCurveSampleMode length_mode_;
231
232 mf::Signature signature_;
233
234 mutable CacheMutex mutex_;
235 mutable std::optional<bke::CurvesFieldContext> source_context_;
236 mutable std::unique_ptr<FieldEvaluator> source_evaluator_;
237 mutable const GVArray *source_data_;
238
239 public:
241 const GeometryNodeCurveSampleMode length_mode,
242 GField src_field)
243 : geometry_set_(std::move(geometry_set)),
244 src_field_(std::move(src_field)),
245 length_mode_(length_mode)
246 {
247 mf::SignatureBuilder builder{"Sample Curve", signature_};
248 builder.single_input<int>("Curve Index");
249 builder.single_input<float>("Length");
250 builder.single_output<float3>("Position", mf::ParamFlag::SupportsUnusedOutput);
251 builder.single_output<float3>("Tangent", mf::ParamFlag::SupportsUnusedOutput);
252 builder.single_output<float3>("Normal", mf::ParamFlag::SupportsUnusedOutput);
253 builder.single_output("Value", src_field_.cpp_type(), mf::ParamFlag::SupportsUnusedOutput);
254 this->set_signature(&signature_);
255 }
256
257 void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override
258 {
259 MutableSpan<float3> sampled_positions = params.uninitialized_single_output_if_required<float3>(
260 2, "Position");
261 MutableSpan<float3> sampled_tangents = params.uninitialized_single_output_if_required<float3>(
262 3, "Tangent");
263 MutableSpan<float3> sampled_normals = params.uninitialized_single_output_if_required<float3>(
264 4, "Normal");
265 GMutableSpan sampled_values = params.uninitialized_single_output_if_required(5, "Value");
266
267 auto return_default = [&]() {
268 if (!sampled_positions.is_empty()) {
269 index_mask::masked_fill(sampled_positions, {0, 0, 0}, mask);
270 }
271 if (!sampled_tangents.is_empty()) {
272 index_mask::masked_fill(sampled_tangents, {0, 0, 0}, mask);
273 }
274 if (!sampled_normals.is_empty()) {
275 index_mask::masked_fill(sampled_normals, {0, 0, 0}, mask);
276 }
277 };
278
279 if (!geometry_set_.has_curves()) {
280 return_default();
281 return;
282 }
283
284 const Curves &curves_id = *geometry_set_.get_curves();
285 const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
286 if (curves.is_empty()) {
287 return_default();
288 return;
289 }
290 curves.ensure_can_interpolate_to_evaluated();
291 Span<float3> evaluated_positions = curves.evaluated_positions();
292 Span<float3> evaluated_tangents;
293 Span<float3> evaluated_normals;
294 if (!sampled_tangents.is_empty()) {
295 evaluated_tangents = curves.evaluated_tangents();
296 }
297 if (!sampled_normals.is_empty()) {
298 evaluated_normals = curves.evaluated_normals();
299 }
300
301 const OffsetIndices points_by_curve = curves.points_by_curve();
302 const OffsetIndices evaluated_points_by_curve = curves.evaluated_points_by_curve();
303 const VArray<int> curve_indices = params.readonly_single_input<int>(0, "Curve Index");
304 const VArraySpan<float> lengths = params.readonly_single_input<float>(1, "Length");
305 const VArray<bool> cyclic = curves.cyclic();
306
307 Array<int> indices;
308 Array<float> factors;
309 GArray<> src_original_values(source_data_->type());
310 GArray<> src_evaluated_values(source_data_->type());
311
312 auto fill_invalid = [&](const IndexMask &mask) {
313 if (!sampled_positions.is_empty()) {
314 index_mask::masked_fill(sampled_positions, float3(0), mask);
315 }
316 if (!sampled_tangents.is_empty()) {
317 index_mask::masked_fill(sampled_tangents, float3(0), mask);
318 }
319 if (!sampled_normals.is_empty()) {
320 index_mask::masked_fill(sampled_normals, float3(0), mask);
321 }
322 if (!sampled_values.is_empty()) {
323 sampled_values.type().fill_construct_indices(
324 sampled_values.type().default_value(), sampled_values.data(), mask);
325 }
326 };
327
328 auto sample_curve = [&](const int curve_i, const IndexMask &mask) {
329 const IndexRange evaluated_points = evaluated_points_by_curve[curve_i];
330 if (evaluated_points.size() == 1) {
331 if (!sampled_positions.is_empty()) {
333 sampled_positions, evaluated_positions[evaluated_points.first()], mask);
334 }
335 if (!sampled_tangents.is_empty()) {
337 sampled_tangents, evaluated_tangents[evaluated_points.first()], mask);
338 }
339 if (!sampled_normals.is_empty()) {
341 sampled_normals, evaluated_normals[evaluated_points.first()], mask);
342 }
343 if (!sampled_values.is_empty()) {
344 BUFFER_FOR_CPP_TYPE_VALUE(source_data_->type(), value);
345 source_data_->get(points_by_curve[curve_i].first(), value);
346 source_data_->type().fill_construct_indices(value, sampled_values.data(), mask);
347 }
348 return;
349 }
350
351 const Span<float> accumulated_lengths = curves.evaluated_lengths_for_curve(curve_i,
352 cyclic[curve_i]);
353 if (accumulated_lengths.is_empty()) {
354 /* Sanity check in case of invalid evaluation (for example NURBS with invalid order). */
355 fill_invalid(mask);
356 return;
357 }
358
359 /* Store the sampled indices and factors in arrays the size of the mask.
360 * Then, during interpolation, move the results back to the masked indices. */
361 indices.reinitialize(mask.size());
362 factors.reinitialize(mask.size());
364 accumulated_lengths, lengths, length_mode_, mask, indices, factors);
365
366 if (!sampled_positions.is_empty()) {
368 evaluated_positions.slice(evaluated_points),
369 indices,
370 factors,
371 mask,
372 sampled_positions);
373 }
374 if (!sampled_tangents.is_empty()) {
376 evaluated_tangents.slice(evaluated_points), indices, factors, mask, sampled_tangents);
377 mask.foreach_index(
378 [&](const int i) { sampled_tangents[i] = math::normalize(sampled_tangents[i]); });
379 }
380 if (!sampled_normals.is_empty()) {
382 evaluated_normals.slice(evaluated_points), indices, factors, mask, sampled_normals);
383 mask.foreach_index(
384 [&](const int i) { sampled_normals[i] = math::normalize(sampled_normals[i]); });
385 }
386 if (!sampled_values.is_empty()) {
387 const IndexRange points = points_by_curve[curve_i];
388 src_original_values.reinitialize(points.size());
389 source_data_->materialize_compressed_to_uninitialized(points, src_original_values.data());
390 src_evaluated_values.reinitialize(evaluated_points.size());
391 curves.interpolate_to_evaluated(curve_i, src_original_values, src_evaluated_values);
392 bke::attribute_math::to_static_type(source_data_->type(), [&]<typename T>() {
393 if constexpr (!std::is_same_v<T, std::string>) {
394 const Span<T> src_evaluated_values_typed = src_evaluated_values.as_span().typed<T>();
395 MutableSpan<T> sampled_values_typed = sampled_values.typed<T>();
396 length_parameterize::interpolate_to_masked<T>(
397 src_evaluated_values_typed, indices, factors, mask, sampled_values_typed);
398 }
399 });
400 }
401 };
402
403 if (const std::optional<int> curve_i = curve_indices.get_if_single()) {
404 if (curves.curves_range().contains(*curve_i)) {
405 sample_curve(*curve_i, mask);
406 }
407 else {
408 fill_invalid(mask);
409 }
410 }
411 else {
412 const VArraySpan<int> curve_indices_span(curve_indices);
413 IndexMaskMemory memory;
414 const IndexMask valid_mask = IndexMask::from_predicate(mask, memory, [&](const int i) {
415 return curves.curves_range().contains(curve_indices_span[i]);
416 });
417 const IndexMask invalid_mask = IndexMask::from_difference(mask, valid_mask, memory);
418 const Vector<IndexMask, 4> mask_by_curve = IndexMask::from_group_ids(
419 valid_mask, curve_indices, memory);
420 for (const IndexMask &curve_mask : mask_by_curve) {
421 sample_curve(curve_indices_span[curve_mask.first()], curve_mask);
422 }
423 fill_invalid(invalid_mask);
424 }
425 }
426
427 void prepare_for_execution() const override
428 {
429 mutex_.ensure([&]() {
430 const Curves &curves_id = *geometry_set_.get_curves();
431 const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
432 source_context_.emplace(bke::CurvesFieldContext{curves_id, AttrDomain::Point});
433 source_evaluator_ = std::make_unique<FieldEvaluator>(*source_context_, curves.points_num());
434 source_evaluator_->add(src_field_);
435 source_evaluator_->evaluate();
436 source_data_ = &source_evaluator_->get_evaluated(0);
437 });
438 }
439
440 void hash_unique(UniqueHashBytes &hash) const override
441 {
442 static constexpr int8_t id = 0;
443 hash.add(&id);
444 hash.add(geometry_set_.get_curves());
445 hash.add(length_mode_);
446 fn::FieldHashDeep field_hash;
447 hash.add(field_hash.ensure(src_field_));
448 }
449};
450
452{
453
454 Array<float> curve_lengths(curves.curves_num());
455 const VArray<bool> cyclic = curves.cyclic();
456 float length = 0.0f;
457 for (const int i : curves.curves_range()) {
458 length += curves.evaluated_length_total_for_curve(i, cyclic[i]);
459 curve_lengths[i] = length;
460 }
461 return curve_lengths;
462}
463
465{
466 GeometrySet geometry_set = params.extract_input<GeometrySet>("Curves"_ustr);
467 if (!geometry_set.has_curves()) {
469 return;
470 }
471
472 const Curves &curves_id = *geometry_set.get_curves();
473 const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
474 if (curves.is_empty()) {
476 return;
477 }
478
479 curves.ensure_evaluated_lengths();
480
481 const NodeGeometryCurveSample &storage = node_storage(params.node());
483
484 const UString length_input_name = mode == GEO_NODE_CURVE_SAMPLE_FACTOR ? "Factor"_ustr :
485 "Length"_ustr;
486 auto sample_length = params.extract_input<bke::SocketValueVariant>(length_input_name);
487
488 GField src_values_field = params.extract_input<GField>("Value"_ustr);
489
490 std::string error_message;
491
496 std::shared_ptr<FieldOperation> sample_op;
497 if (curves.curves_num() == 1) {
498 auto curve_index = bke::SocketValueVariant::from(fn::Field<int>(0));
500 std::make_unique<SampleCurveFunction>(
501 std::move(geometry_set), mode, std::move(src_values_field)),
502 {&curve_index, &sample_length},
503 {&position, &tangent, &normal, &value},
504 params.user_data(),
505 error_message))
506 {
508 params.error_message_add(NodeWarningType::Error, std::move(error_message));
509 return;
510 }
511 }
512 else {
513 if (storage.use_all_curves) {
514 bke::SocketValueVariant curve_index;
515 bke::SocketValueVariant length_in_curve;
516 if (!execute_multi_function_on_value_variant(std::make_unique<SampleFloatSegmentsFunction>(
518 {&sample_length},
519 {&curve_index, &length_in_curve},
520 params.user_data(),
521 error_message))
522 {
524 params.error_message_add(NodeWarningType::Error, std::move(error_message));
525 return;
526 }
528 std::make_shared<SampleCurveFunction>(std::move(geometry_set),
530 std::move(src_values_field)),
531 {&curve_index, &length_in_curve},
532 {&position, &tangent, &normal, &value},
533 params.user_data(),
534 error_message))
535 {
537 params.error_message_add(NodeWarningType::Error, std::move(error_message));
538 return;
539 }
540 }
541 else {
542 auto curve_index = params.extract_input<bke::SocketValueVariant>("Curve Index"_ustr);
544 std::make_shared<SampleCurveFunction>(
545 std::move(geometry_set), mode, std::move(src_values_field)),
546 {&curve_index, &sample_length},
547 {&position, &tangent, &normal, &value},
548 params.user_data(),
549 error_message))
550 {
552 params.error_message_add(NodeWarningType::Error, std::move(error_message));
553 return;
554 }
555 }
556 }
557
558 params.set_output("Position"_ustr, std::move(position));
559 params.set_output("Tangent"_ustr, std::move(tangent));
560 params.set_output("Normal"_ustr, std::move(normal));
561 params.set_output("Value"_ustr, std::move(value));
562}
563
564static void node_register()
565{
566 static bke::bNodeType ntype;
567
568 geo_node_type_base(&ntype, "GeometryNodeSampleCurve"_ustr, GEO_NODE_SAMPLE_CURVE);
569 ntype.ui_name = "Sample Curve";
570 ntype.ui_description =
571 "Retrieve data from a point on a curve at a certain distance from its start";
572 ntype.enum_name_legacy = "SAMPLE_CURVE";
575 ntype.declare = node_declare;
576 ntype.initfunc = node_init;
578 ntype, "NodeGeometryCurveSample", node_free_standard_storage, node_copy_standard_storage);
582}
583NOD_REGISTER_NODE(node_register)
584
585} // namespace blender::nodes::node_geo_curve_sample_cc
Low-level operations for curves.
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1353
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:492
#define GEO_NODE_SAMPLE_CURVE
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define IFACE_(msgid)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define UI_ITEM_NONE
void reinitialize(const int64_t new_size)
Definition BLI_array.hh:430
void reinitialize(const int64_t new_size)
const void * data() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_difference(const IndexMask &mask_a, const IndexMask &mask_b, LinearAllocator<> &memory)
static Vector< IndexMask, 4 > from_group_ids(const VArray< int > &group_ids, LinearAllocator<> &memory)
constexpr int64_t first() const
constexpr int64_t size() const
constexpr bool is_empty() const
Definition BLI_span.hh:515
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:141
constexpr const T & last(const int64_t n=0) const
Definition BLI_span.hh:329
constexpr bool is_empty() const
Definition BLI_span.hh:264
static SocketValueVariant from(T &&value)
void set_signature(const Signature *signature)
const bke::bNodeType & node_type() const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
GeoNodesUserData * user_data() const
void set_output(const UString identifier, T &&value)
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
Vector< SocketDeclaration * > inputs
Vector< SocketDeclaration * > outputs
SampleCurveFunction(GeometrySet geometry_set, const GeometryNodeCurveSampleMode length_mode, GField src_field)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
SampleFloatSegmentsFunction(Array< float > accumulated_lengths, const GeometryNodeCurveSampleMode length_mode)
#define storage(slot, qualifiers)
#define position
float length(VecOp< float, D >) RET
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
#define T
void to_static_type(const CPPType &cpp_type, Fn &&fn)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:6166
std::optional< eCustomDataType > socket_type_to_custom_data_type(eNodeSocketDatatype type)
Definition node.cc:5911
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
void sample_at_length(const Span< float > accumulated_segment_lengths, const float sample_length, int &r_segment_index, float &r_factor, SampleSegmentHint *hint=nullptr)
void interpolate_to_masked(const Span< T > src, const Span< int > indices, const Span< float > factors, const IndexMask &dst_mask, MutableSpan< T > dst)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
static void sample_indices_and_factors_to_compressed(const Span< float > accumulated_lengths, const Span< float > sample_lengths, const GeometryNodeCurveSampleMode length_mode, const IndexMask &mask, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factor_in_segment)
static Array< float > curve_accumulated_lengths(const bke::CurvesGeometry &curves)
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
static void node_gather_link_searches(GatherLinkSearchOpParams &params)
static void sample_indices_and_lengths(const Span< float > accumulated_lengths, const Span< float > sample_lengths, const GeometryNodeCurveSampleMode length_mode, const IndexMask &mask, MutableSpan< int > r_segment_indices, MutableSpan< float > r_length_in_segment)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
void search_link_ops_for_declarations(GatherLinkSearchOpParams &params, Span< SocketDeclaration * > declarations)
bool execute_multi_function_on_value_variant(const MultiFunction &fn, const std::shared_ptr< MultiFunction > &owned_fn, const Span< SocketValueVariant * > input_values, const Span< SocketValueVariant * > output_values, GeoNodesUserData *user_data, std::string &r_error_message)
BMesh const char void * data
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:57
void node_free_standard_storage(bNode *node)
Definition node_util.cc:45
VecBase< float, 3 > float3
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_DISTANCE
Definition RNA_types.hh:313
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
signed char int8_t
Definition BKE_text.h:76
GeometryNodeCurveSampleMode
@ GEO_NODE_CURVE_SAMPLE_LENGTH
@ GEO_NODE_CURVE_SAMPLE_FACTOR
#define hash
Definition noise_c.cc:156
eNodeSocketDatatype type
const Curves * get_curves() const
Defines a node type.
Definition BKE_node.hh:265
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:290
std::string ui_description
Definition BKE_node.hh:271
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
void(*) initfunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:320
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393
nodes::NodeDeclaration * static_declaration
Definition BKE_node.hh:402
UniqueHash ensure(const GFieldRef &field)
Definition field.cc:113
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)