Blender V5.3
trim_curves.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
8
10
11#include "BKE_attribute.hh"
12#include "BKE_attribute_math.hh"
13#include "BKE_curves.hh"
14#include "BKE_curves_utils.hh"
15
16#include "GEO_trim_curves.hh"
17
18namespace blender::geometry {
19
20/* -------------------------------------------------------------------- */
23
37 const float sample_length,
38 const bool cyclic,
39 const int resolution,
40 const int num_curve_points)
41{
42 BLI_assert(!cyclic || lengths.size() / resolution >= 2);
43 const int last_index = num_curve_points - 1;
44 if (sample_length <= 0.0f) {
45 return {{0, 1}, 0.0f};
46 }
47 if (sample_length >= lengths.last()) {
48 return cyclic ? bke::curves::CurvePoint{{last_index, 0}, 1.0} :
49 bke::curves::CurvePoint{{last_index - 1, last_index}, 1.0};
50 }
51 int eval_index;
52 float eval_factor;
53 length_parameterize::sample_at_length(lengths, sample_length, eval_index, eval_factor);
54
55 const int index = eval_index / resolution;
56 const int next_index = (index == last_index) ? 0 : index + 1;
57 const float parameter = (eval_factor + eval_index) / resolution - index;
58
59 return bke::curves::CurvePoint{{index, next_index}, parameter};
60}
61
66 const float sample_length,
67 const bool cyclic,
68 const int evaluated_size)
69{
70 const int last_index = evaluated_size - 1;
71 if (sample_length <= 0.0f) {
72 return {{0, 1}, 0.0f};
73 }
74 if (sample_length >= lengths.last()) {
75 return cyclic ? bke::curves::CurvePoint{{last_index, 0}, 1.0} :
76 bke::curves::CurvePoint{{last_index - 1, last_index}, 1.0};
77 }
78
79 int eval_index;
80 float eval_factor;
81 length_parameterize::sample_at_length(lengths, sample_length, eval_index, eval_factor);
82
83 const int next_eval_index = (eval_index == last_index) ? 0 : eval_index + 1;
84 return bke::curves::CurvePoint{{eval_index, next_eval_index}, eval_factor};
85}
86
91 const Span<float> lengths,
92 const float sample_length,
93 const bool cyclic,
94 const int num_curve_points)
95{
96 const int last_index = num_curve_points - 1;
97 if (sample_length <= 0.0f) {
98 return {{0, 1}, 0.0f};
99 }
100 if (sample_length >= lengths.last()) {
101 return cyclic ? bke::curves::CurvePoint{{last_index, 0}, 1.0} :
102 bke::curves::CurvePoint{{last_index - 1, last_index}, 1.0};
103 }
104 int eval_index;
105 float eval_factor;
106 length_parameterize::sample_at_length(lengths, sample_length, eval_index, eval_factor);
107
108 /* Find the segment index from the offset mapping. */
109 const int *offset = std::upper_bound(bezier_offsets.begin(), bezier_offsets.end(), eval_index);
110 const int left = offset - bezier_offsets.begin() - 1;
111 const int right = left == last_index ? 0 : left + 1;
112
113 const int prev_offset = bezier_offsets[left];
114 const float offset_in_segment = eval_factor + (eval_index - prev_offset);
115 const int segment_resolution = bezier_offsets[left + 1] - prev_offset;
116 const float parameter = std::clamp(offset_in_segment / segment_resolution, 0.0f, 1.0f);
117
118 return {{left, right}, parameter};
119}
120
122 const bke::CurvesGeometry &src_curves,
123 const OffsetIndices<int> evaluated_points_by_curve,
124 const int64_t curve_index,
125 const Span<float> accumulated_lengths,
126 const float sample_length,
127 const bool cyclic,
128 const int resolution,
129 const int num_curve_points)
130{
132 num_curve_points, evaluated_points_by_curve[curve_index].size(), cyclic, resolution))
133 {
134 const Span<int> bezier_offsets = src_curves.bezier_evaluated_offsets_for_curve(curve_index);
135 return lookup_point_bezier(
136 bezier_offsets, accumulated_lengths, sample_length, cyclic, num_curve_points);
137 }
139 accumulated_lengths, sample_length, cyclic, resolution, num_curve_points);
140}
141
143 const bke::CurvesGeometry &src_curves,
144 const OffsetIndices<int> evaluated_points_by_curve,
145 const CurveType curve_type,
146 const int64_t curve_index,
147 const Span<float> accumulated_lengths,
148 const float sample_length,
149 const bool cyclic,
150 const int resolution,
151 const int num_curve_points)
152{
153 if (num_curve_points == 1) {
154 return {{0, 0}, 0.0f};
155 }
156
157 if (curve_type == CURVE_TYPE_CATMULL_ROM) {
159 accumulated_lengths, sample_length, cyclic, resolution, num_curve_points);
160 }
161 if (curve_type == CURVE_TYPE_BEZIER) {
162 return lookup_point_bezier(src_curves,
163 evaluated_points_by_curve,
164 curve_index,
165 accumulated_lengths,
166 sample_length,
167 cyclic,
168 resolution,
169 num_curve_points);
170 }
171 if (curve_type == CURVE_TYPE_POLY) {
172 return lookup_point_polygonal(accumulated_lengths, sample_length, cyclic, num_curve_points);
173 }
174 /* Handle evaluated curve. */
175 BLI_assert(resolution > 0);
177 accumulated_lengths, sample_length, cyclic, evaluated_points_by_curve[curve_index].size());
178}
179
181
182/* -------------------------------------------------------------------- */
185
186static void fill_bezier_data(bke::CurvesGeometry &dst_curves, const IndexMask &selection)
187{
188 if (!dst_curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
189 return;
190 }
191 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
192 MutableSpan<float3> handle_positions_left = dst_curves.handle_positions_left_for_write();
193 MutableSpan<float3> handle_positions_right = dst_curves.handle_positions_right_for_write();
194 MutableSpan<int8_t> handle_types_left = dst_curves.handle_types_left_for_write();
195 MutableSpan<int8_t> handle_types_right = dst_curves.handle_types_right_for_write();
196
197 selection.foreach_index(
198 [&](const int curve_i) {
199 const IndexRange points = dst_points_by_curve[curve_i];
200 handle_types_right.slice(points).fill(int8_t(BEZIER_HANDLE_FREE));
201 handle_types_left.slice(points).fill(int8_t(BEZIER_HANDLE_FREE));
202 handle_positions_left.slice(points).fill({0.0f, 0.0f, 0.0f});
203 handle_positions_right.slice(points).fill({0.0f, 0.0f, 0.0f});
204 },
206}
207static void fill_nurbs_data(bke::CurvesGeometry &dst_curves, const IndexMask &selection)
208{
209 if (!dst_curves.has_curve_with_type(CURVE_TYPE_NURBS)) {
210 return;
211 }
213 dst_curves.points_by_curve(), selection, 0.0f, dst_curves.nurbs_weights_for_write());
214}
215
216template<typename T>
218 MutableSpan<T> dst_data,
219 const bke::curves::IndexRangeCyclic src_range,
220 int64_t dst_index)
221{
222 int64_t increment;
223 if (src_range.cycles()) {
224 increment = src_range.size_before_loop();
225 dst_data.slice(dst_index, increment).copy_from(src_data.slice(src_range.first(), increment));
226 dst_index += increment;
227
228 increment = src_range.size_after_loop();
229 dst_data.slice(dst_index, increment)
230 .copy_from(src_data.slice(src_range.curve_range().first(), increment));
231 dst_index += increment;
232 }
233 else {
234 increment = src_range.one_after_last() - int64_t(src_range.first());
235 dst_data.slice(dst_index, increment).copy_from(src_data.slice(src_range.first(), increment));
236 dst_index += increment;
237 }
238 return dst_index;
239}
240
242
243/* -------------------------------------------------------------------- */
246
247template<typename T>
248static T interpolate_catmull_rom(const Span<T> src_data,
249 const bke::curves::CurvePoint insertion_point,
250 const bool src_cyclic)
251{
252 BLI_assert(insertion_point.index >= 0 && insertion_point.next_index < src_data.size());
253 int i0;
254 if (insertion_point.index == 0) {
255 i0 = src_cyclic ? src_data.size() - 1 : insertion_point.index;
256 }
257 else {
258 i0 = insertion_point.index - 1;
259 }
260 int i3 = insertion_point.next_index + 1;
261 if (i3 == src_data.size()) {
262 i3 = src_cyclic ? 0 : insertion_point.next_index;
263 }
265 src_data[insertion_point.index],
266 src_data[insertion_point.next_index],
267 src_data[i3],
268 insertion_point.parameter);
269}
270
272 const Span<float3> positions,
273 const Span<float3> handles_left,
274 const Span<float3> handles_right,
275 const bke::curves::CurvePoint insertion_point)
276{
278 insertion_point.index + 1 == insertion_point.next_index ||
279 (insertion_point.next_index >= 0 && insertion_point.next_index < insertion_point.index));
280 return bke::curves::bezier::insert(positions[insertion_point.index],
281 handles_right[insertion_point.index],
282 handles_left[insertion_point.next_index],
283 positions[insertion_point.next_index],
284 insertion_point.parameter);
285}
286
288
289/* -------------------------------------------------------------------- */
292
306template<typename T, bool include_start_point = true>
307static void sample_interval_linear(const Span<T> src_data,
308 MutableSpan<T> dst_data,
310 const IndexRange dst_range,
311 const bke::curves::CurvePoint start_point,
312 const bke::curves::CurvePoint end_point)
313{
314 int64_t dst_index = dst_range.first();
315
316 if (start_point.is_controlpoint()) {
317 /* 'start_point' is included in the copy iteration. */
318 if constexpr (!include_start_point) {
319 /* Skip first. */
320 src_range = src_range.drop_front();
321 }
322 }
323 else if constexpr (!include_start_point) {
324 /* Do nothing (excluded). */
325 }
326 else {
327 /* General case, sample 'start_point' */
328 dst_data[dst_index] = bke::attribute_math::mix2(
329 start_point.parameter, src_data[start_point.index], src_data[start_point.next_index]);
330 ++dst_index;
331 }
332
333 dst_index = copy_point_data_between_endpoints(src_data, dst_data, src_range, dst_index);
334 if (dst_range.size() == 1) {
335 BLI_assert(dst_index == dst_range.one_after_last());
336 return;
337 }
338
339 /* Handle last case */
340 if (end_point.is_controlpoint()) {
341 /* 'end_point' is included in the copy iteration. */
342 }
343 else {
344 dst_data[dst_index] = bke::attribute_math::mix2(
345 end_point.parameter, src_data[end_point.index], src_data[end_point.next_index]);
346#ifndef NDEBUG
347 ++dst_index;
348#endif
349 }
350 BLI_assert(dst_index == dst_range.one_after_last());
351}
352
353template<typename T>
354static void sample_interval_catmull_rom(const Span<T> src_data,
355 MutableSpan<T> dst_data,
357 const IndexRange dst_range,
358 const bke::curves::CurvePoint start_point,
359 const bke::curves::CurvePoint end_point,
360 const bool src_cyclic)
361{
362 int64_t dst_index = dst_range.first();
363
364 if (start_point.is_controlpoint()) {
365 }
366 else {
367 /* General case, sample 'start_point' */
368 dst_data[dst_index] = interpolate_catmull_rom(src_data, start_point, src_cyclic);
369 ++dst_index;
370 }
371
372 dst_index = copy_point_data_between_endpoints(src_data, dst_data, src_range, dst_index);
373 if (dst_range.size() == 1) {
374 BLI_assert(dst_index == dst_range.one_after_last());
375 return;
376 }
377
378 /* Handle last case */
379 if (end_point.is_controlpoint()) {
380 /* 'end_point' is included in the copy iteration. */
381 }
382 else {
383 dst_data[dst_index] = interpolate_catmull_rom(src_data, end_point, src_cyclic);
384#ifndef NDEBUG
385 ++dst_index;
386#endif
387 }
388 BLI_assert(dst_index == dst_range.one_after_last());
389}
390
391template<bool include_start_point = true>
392static void sample_interval_bezier(const Span<float3> src_positions,
393 const Span<float3> src_handles_l,
394 const Span<float3> src_handles_r,
395 const Span<int8_t> src_types_l,
396 const Span<int8_t> src_types_r,
397 MutableSpan<float3> dst_positions,
398 MutableSpan<float3> dst_handles_l,
399 MutableSpan<float3> dst_handles_r,
400 MutableSpan<int8_t> dst_types_l,
401 MutableSpan<int8_t> dst_types_r,
403 const IndexRange dst_range,
404 const bke::curves::CurvePoint start_point,
405 const bke::curves::CurvePoint end_point)
406{
407 bke::curves::bezier::Insertion start_point_insert;
408 int64_t dst_index = dst_range.first();
409
410 bool start_point_trimmed = false;
411 if (start_point.is_controlpoint()) {
412 /* The 'start_point' control point is included in the copy iteration. */
413 if constexpr (!include_start_point) {
414 src_range = src_range.drop_front();
415 }
416 }
417 else if constexpr (!include_start_point) {
418 /* Do nothing, 'start_point' is excluded. */
419 }
420 else {
421 /* General case, sample 'start_point'. */
422 start_point_insert = knot_insert_bezier(
423 src_positions, src_handles_l, src_handles_r, start_point);
424 dst_positions[dst_range.first()] = start_point_insert.position;
425 dst_handles_l[dst_range.first()] = start_point_insert.left_handle;
426 dst_handles_r[dst_range.first()] = start_point_insert.right_handle;
427 dst_types_l[dst_range.first()] = src_types_l[start_point.index];
428 dst_types_r[dst_range.first()] = src_types_r[start_point.index];
429
430 start_point_trimmed = true;
431 ++dst_index;
432 }
433
434 /* Copy point data between the 'start_point' and 'end_point'. */
435 int64_t increment = src_range.cycles() ? src_range.size_before_loop() :
436 src_range.one_after_last() - src_range.first();
437
438 const IndexRange dst_range_to_end(dst_index, increment);
439 const IndexRange src_range_to_end(src_range.first(), increment);
440 dst_positions.slice(dst_range_to_end).copy_from(src_positions.slice(src_range_to_end));
441 dst_handles_l.slice(dst_range_to_end).copy_from(src_handles_l.slice(src_range_to_end));
442 dst_handles_r.slice(dst_range_to_end).copy_from(src_handles_r.slice(src_range_to_end));
443 dst_types_l.slice(dst_range_to_end).copy_from(src_types_l.slice(src_range_to_end));
444 dst_types_r.slice(dst_range_to_end).copy_from(src_types_r.slice(src_range_to_end));
445 dst_index += increment;
446
447 if (dst_range.size() == 1) {
448 BLI_assert(dst_index == dst_range.one_after_last());
449 return;
450 }
451
452 increment = src_range.size_after_loop();
453 if (src_range.cycles() && increment > 0) {
454 const IndexRange dst_range_looped(dst_index, increment);
455 const IndexRange src_range_looped(src_range.curve_range().first(), increment);
456 dst_positions.slice(dst_range_looped).copy_from(src_positions.slice(src_range_looped));
457 dst_handles_l.slice(dst_range_looped).copy_from(src_handles_l.slice(src_range_looped));
458 dst_handles_r.slice(dst_range_looped).copy_from(src_handles_r.slice(src_range_looped));
459 dst_types_l.slice(dst_range_looped).copy_from(src_types_l.slice(src_range_looped));
460 dst_types_r.slice(dst_range_looped).copy_from(src_types_r.slice(src_range_looped));
461 dst_index += increment;
462 }
463
464 if (start_point_trimmed) {
465 dst_handles_l[dst_range.first() + 1] = start_point_insert.handle_next;
466 /* No need to change handle type (remains the same). */
467 }
468
469 /* Handle 'end_point' */
470 bke::curves::bezier::Insertion end_point_insert;
471 if (end_point.parameter == 0.0f) {
472 if (end_point.index == start_point.index) {
473 /* Start point is same point or in the same segment. */
474 if (start_point.parameter == 0.0f) {
475 /* Same point. */
476 BLI_assert(dst_range.size() == 1LL + src_range.size_range());
477 dst_handles_l[dst_range.first()] = dst_positions[dst_range.first()];
478 dst_handles_r[dst_range.last()] = dst_positions[dst_range.first()];
479 }
480 else if (start_point.parameter == 1.0f) {
481 /* Start is next controlpoint, do nothing. */
482 }
483 else {
484 /* Within the segment. */
485 BLI_assert(dst_range.size() == 1LL + src_range.size_range() || dst_range.size() == 2);
486 dst_handles_r[dst_range.last()] = start_point_insert.handle_prev;
487 }
488 }
489 /* Start point is considered 'before' the endpoint and ignored. */
490 }
491 else if (end_point.parameter == 1.0f) {
492 if (end_point.next_index == start_point.index) {
493 /* Start point is same or in 'next' segment. */
494 if (start_point.parameter == 0.0f) {
495 /* Same point */
496 BLI_assert(dst_range.size() == 1LL + src_range.size_range());
497 dst_handles_l[dst_range.first()] = dst_positions[dst_range.first()];
498 dst_handles_r[dst_range.last()] = dst_positions[dst_range.first()];
499 }
500 else if (start_point.parameter == 1.0f) {
501 /* Start is next controlpoint, do nothing. */
502 }
503 else {
504 /* In next segment. */
505 BLI_assert(dst_range.size() == 1LL + src_range.size_range() || dst_range.size() == 2);
506 dst_handles_r[dst_range.last()] = start_point_insert.handle_prev;
507 }
508 }
509 }
510 else {
511 /* Trimmed in both ends within the same (and only) segment! Ensure both end points is not a
512 * loop. */
513 if (start_point.index == end_point.index && start_point.parameter < 1.0f) {
514 BLI_assert(dst_range.size() == 2 || dst_range.size() == 2ll + src_range.size_range() ||
515 dst_range.size() == 1LL + src_range.size_range());
516
517 if (start_point.parameter > end_point.parameter && start_point.parameter < 1.0f) {
518 /* Start point comes after the endpoint within the segment. */
519 BLI_assert(end_point.parameter >= 0.0f);
520
521 const float parameter = end_point.parameter / start_point.parameter;
522 end_point_insert = bke::curves::bezier::insert(dst_positions[dst_index - 1],
523 start_point_insert.handle_prev,
524 start_point_insert.left_handle,
525 start_point_insert.position,
526 parameter);
527
528 /* Update start-point handle. */
529 dst_handles_l[dst_range.first()] = end_point_insert.handle_next;
530 }
531 else {
532 /* Start point lies before the endpoint within the segment. */
533
534 const float parameter = (end_point.parameter - start_point.parameter) /
535 (1.0f - start_point.parameter);
536 /* Unused only when parameter == 0.0f! */
537 const float3 handle_next = start_point.parameter == 0.0f ?
538 src_handles_l[end_point.next_index] :
539 start_point_insert.handle_next;
540 end_point_insert = bke::curves::bezier::insert(dst_positions[dst_index - 1],
541 dst_handles_r[dst_index - 1],
542 handle_next,
543 src_positions[end_point.next_index],
544 parameter);
545 }
546 }
547 else {
548 /* General case, compute the insertion point. */
549 end_point_insert = knot_insert_bezier(
550 src_positions, src_handles_l, src_handles_r, end_point);
551
552 if ((start_point.parameter >= end_point.parameter && end_point.index == start_point.index) ||
553 (start_point.parameter == 0.0f && end_point.next_index == start_point.index))
554 {
555 /* Start point is next controlpoint. */
556 dst_handles_l[dst_range.first()] = end_point_insert.handle_next;
557 /* No need to change handle type (remains the same). */
558 }
559 }
560
561 dst_handles_r[dst_index - 1] = end_point_insert.handle_prev;
562 dst_types_r[dst_index - 1] = src_types_l[end_point.index];
563
564 dst_handles_l[dst_index] = end_point_insert.left_handle;
565 dst_handles_r[dst_index] = end_point_insert.right_handle;
566 dst_positions[dst_index] = end_point_insert.position;
567 dst_types_l[dst_index] = src_types_l[end_point.next_index];
568 dst_types_r[dst_index] = src_types_r[end_point.next_index];
569#ifndef NDEBUG
570 ++dst_index;
571#endif
572 }
573 BLI_assert(dst_index == dst_range.one_after_last());
574}
575
577
578/* -------------------------------------------------------------------- */
581
582static void trim_attribute_linear(const bke::CurvesGeometry &src_curves,
583 bke::CurvesGeometry &dst_curves,
584 const IndexMask &selection,
585 const Span<bke::curves::CurvePoint> start_points,
586 const Span<bke::curves::CurvePoint> end_points,
588 MutableSpan<bke::AttributeTransferData> transfer_attributes)
589{
590 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
591 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
592 for (bke::AttributeTransferData &attribute : transfer_attributes) {
593 bke::attribute_math::to_static_type(attribute.meta_data.data_type, [&]<typename T>() {
594 if constexpr (!std::is_same_v<T, std::string>) {
595 selection.foreach_index(
596 [&](const int curve_i) {
597 const IndexRange src_points = src_points_by_curve[curve_i];
598 sample_interval_linear<T>(attribute.src.template typed<T>().slice(src_points),
599 attribute.dst.span.typed<T>(),
600 src_ranges[curve_i],
601 dst_points_by_curve[curve_i],
602 start_points[curve_i],
603 end_points[curve_i]);
604 },
605 exec_mode::grain_size(512));
606 }
607 });
608 }
609}
610
611static void trim_polygonal_curves(const bke::CurvesGeometry &src_curves,
612 bke::CurvesGeometry &dst_curves,
613 const IndexMask &selection,
614 const Span<bke::curves::CurvePoint> start_points,
615 const Span<bke::curves::CurvePoint> end_points,
617 MutableSpan<bke::AttributeTransferData> transfer_attributes)
618{
619 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
620 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
621 const Span<float3> src_positions = src_curves.positions();
622 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
623
624 selection.foreach_index(
625 [&](const int curve_i) {
626 const IndexRange src_points = src_points_by_curve[curve_i];
627 const IndexRange dst_points = dst_points_by_curve[curve_i];
628
629 sample_interval_linear<float3>(src_positions.slice(src_points),
630 dst_positions,
631 src_ranges[curve_i],
632 dst_points,
633 start_points[curve_i],
634 end_points[curve_i]);
635 },
637 fill_bezier_data(dst_curves, selection);
638 fill_nurbs_data(dst_curves, selection);
639 trim_attribute_linear(src_curves,
640 dst_curves,
641 selection,
642 start_points,
643 end_points,
644 src_ranges,
645 transfer_attributes);
646}
647
648static void trim_catmull_rom_curves(const bke::CurvesGeometry &src_curves,
649 bke::CurvesGeometry &dst_curves,
650 const IndexMask &selection,
651 const Span<bke::curves::CurvePoint> start_points,
652 const Span<bke::curves::CurvePoint> end_points,
654 MutableSpan<bke::AttributeTransferData> transfer_attributes)
655{
656 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
657 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
658 const Span<float3> src_positions = src_curves.positions();
659 const VArray<bool> src_cyclic = src_curves.cyclic();
660 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
661
662 selection.foreach_index(
663 [&](const int curve_i) {
664 const IndexRange src_points = src_points_by_curve[curve_i];
665 const IndexRange dst_points = dst_points_by_curve[curve_i];
666
667 sample_interval_catmull_rom<float3>(src_positions.slice(src_points),
668 dst_positions,
669 src_ranges[curve_i],
670 dst_points,
671 start_points[curve_i],
672 end_points[curve_i],
673 src_cyclic[curve_i]);
674 },
676 fill_bezier_data(dst_curves, selection);
677 fill_nurbs_data(dst_curves, selection);
678
679 for (bke::AttributeTransferData &attribute : transfer_attributes) {
680 bke::attribute_math::to_static_type(attribute.meta_data.data_type, [&]<typename T>() {
681 if constexpr (!std::is_same_v<T, std::string>) {
682 selection.foreach_index(
683 [&](const int curve_i) {
684 const IndexRange src_points = src_points_by_curve[curve_i];
685 const IndexRange dst_points = dst_points_by_curve[curve_i];
686
687 sample_interval_catmull_rom<T>(attribute.src.template typed<T>().slice(src_points),
688 attribute.dst.span.typed<T>(),
689 src_ranges[curve_i],
690 dst_points,
691 start_points[curve_i],
692 end_points[curve_i],
693 src_cyclic[curve_i]);
694 },
695 exec_mode::grain_size(512));
696 }
697 });
698 }
699}
700
701static void trim_bezier_curves(const bke::CurvesGeometry &src_curves,
702 bke::CurvesGeometry &dst_curves,
703 const IndexMask &selection,
704 const Span<bke::curves::CurvePoint> start_points,
705 const Span<bke::curves::CurvePoint> end_points,
707 MutableSpan<bke::AttributeTransferData> transfer_attributes)
708{
709 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
710 const Span<float3> src_positions = src_curves.positions();
711 const VArraySpan<int8_t> src_types_l{src_curves.handle_types_left()};
712 const VArraySpan<int8_t> src_types_r{src_curves.handle_types_right()};
713 const Span<float3> src_handles_l = *src_curves.handle_positions_left();
714 const Span<float3> src_handles_r = *src_curves.handle_positions_right();
715
716 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
717 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
718 MutableSpan<int8_t> dst_types_l = dst_curves.handle_types_left_for_write();
719 MutableSpan<int8_t> dst_types_r = dst_curves.handle_types_right_for_write();
720 MutableSpan<float3> dst_handles_l = dst_curves.handle_positions_left_for_write();
721 MutableSpan<float3> dst_handles_r = dst_curves.handle_positions_right_for_write();
722
723 selection.foreach_index(
724 [&](const int curve_i) {
725 const IndexRange src_points = src_points_by_curve[curve_i];
726 const IndexRange dst_points = dst_points_by_curve[curve_i];
727
728 sample_interval_bezier(src_positions.slice(src_points),
729 src_handles_l.slice(src_points),
730 src_handles_r.slice(src_points),
731 src_types_l.slice(src_points),
732 src_types_r.slice(src_points),
733 dst_positions,
734 dst_handles_l,
735 dst_handles_r,
736 dst_types_l,
737 dst_types_r,
738 src_ranges[curve_i],
739 dst_points,
740 start_points[curve_i],
741 end_points[curve_i]);
742 },
744 fill_nurbs_data(dst_curves, selection);
745 trim_attribute_linear(src_curves,
746 dst_curves,
747 selection,
748 start_points,
749 end_points,
750 src_ranges,
751 transfer_attributes);
752}
753
754static void trim_evaluated_curves(const bke::CurvesGeometry &src_curves,
755 bke::CurvesGeometry &dst_curves,
756 const IndexMask &selection,
757 const Span<bke::curves::CurvePoint> start_points,
758 const Span<bke::curves::CurvePoint> end_points,
760 MutableSpan<bke::AttributeTransferData> transfer_attributes)
761{
762 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
763 const OffsetIndices src_evaluated_points_by_curve = src_curves.evaluated_points_by_curve();
764 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
765 const Span<float3> src_eval_positions = src_curves.evaluated_positions();
766 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
767
768 selection.foreach_index(
769 [&](const int curve_i) {
770 const IndexRange src_evaluated_points = src_evaluated_points_by_curve[curve_i];
771 const IndexRange dst_points = dst_points_by_curve[curve_i];
772 sample_interval_linear<float3>(src_eval_positions.slice(src_evaluated_points),
773 dst_positions,
774 src_ranges[curve_i],
775 dst_points,
776 start_points[curve_i],
777 end_points[curve_i]);
778 },
780 fill_bezier_data(dst_curves, selection);
781 fill_nurbs_data(dst_curves, selection);
782
783 for (bke::AttributeTransferData &attribute : transfer_attributes) {
784 bke::attribute_math::to_static_type(attribute.meta_data.data_type, [&]<typename T>() {
785 if constexpr (!std::is_same_v<T, std::string>) {
786 selection.foreach_segment(
787 [&](const IndexMaskSegment segment) {
788 Vector<std::byte> evaluated_buffer;
789 for (const int64_t curve_i : segment) {
790 const IndexRange src_points = src_points_by_curve[curve_i];
791
792 /* Interpolate onto the evaluated point domain and sample the evaluated domain. */
793 evaluated_buffer.reinitialize(sizeof(T) *
794 src_evaluated_points_by_curve[curve_i].size());
795 MutableSpan<T> evaluated = evaluated_buffer.as_mutable_span().cast<T>();
796 src_curves.interpolate_to_evaluated(
797 curve_i, attribute.src.slice(src_points), evaluated);
798 sample_interval_linear<T>(evaluated,
799 attribute.dst.span.typed<T>(),
800 src_ranges[curve_i],
801 dst_points_by_curve[curve_i],
802 start_points[curve_i],
803 end_points[curve_i]);
804 }
805 },
806 exec_mode::grain_size(512));
807 }
808 });
809 }
810}
811
813
814/* -------------------------------------------------------------------- */
817
818static float trim_sample_length(const Span<float> accumulated_lengths,
819 const float sample_length,
821{
822 float length = mode == GEO_NODE_CURVE_SAMPLE_FACTOR ?
823 sample_length * accumulated_lengths.last() :
824 sample_length;
825 return std::clamp(length, 0.0f, accumulated_lengths.last());
826}
827
832 const IndexMask &selection,
833 const VArray<float> &starts,
834 const VArray<float> &ends,
836 MutableSpan<int> dst_curve_size,
840{
842 const OffsetIndices points_by_curve = curves.points_by_curve();
843 const OffsetIndices evaluated_points_by_curve = curves.evaluated_points_by_curve();
844 const VArray<bool> src_cyclic = curves.cyclic();
845 const VArray<int> resolution = curves.resolution();
846 const VArray<int8_t> curve_types = curves.curve_types();
847 curves.ensure_can_interpolate_to_evaluated();
848
849 selection.foreach_index(
850 [&](const int curve_i) {
851 CurveType curve_type = CurveType(curve_types[curve_i]);
852
853 int point_count;
854 if (curve_type == CURVE_TYPE_NURBS) {
855 /* The result curve is a poly curve. */
856 point_count = evaluated_points_by_curve[curve_i].size();
857 }
858 else {
859 point_count = points_by_curve[curve_i].size();
860 }
861 if (point_count == 1) {
862 /* Single point. */
863 dst_curve_size[curve_i] = 1;
864 src_ranges[curve_i] = bke::curves::IndexRangeCyclic(0, 0, 1, 1);
865 start_points[curve_i] = {{0, 0}, 0.0f};
866 end_points[curve_i] = {{0, 0}, 0.0f};
867 return;
868 }
869
870 const bool cyclic = src_cyclic[curve_i];
871 const Span<float> lengths = curves.evaluated_lengths_for_curve(curve_i, cyclic);
872 BLI_assert(lengths.size() > 0);
873
874 const float start_length = trim_sample_length(lengths, starts[curve_i], mode);
875 float end_length;
876
877 bool equal_sample_point;
878 if (cyclic) {
879 end_length = trim_sample_length(lengths, ends[curve_i], mode);
880 const float cyclic_start = start_length == lengths.last() ? 0.0f : start_length;
881 const float cyclic_end = end_length == lengths.last() ? 0.0f : end_length;
882 equal_sample_point = cyclic_start == cyclic_end;
883 }
884 else {
885 end_length = ends[curve_i] <= starts[curve_i] ?
886 start_length :
887 trim_sample_length(lengths, ends[curve_i], mode);
888 equal_sample_point = start_length == end_length;
889 }
890
891 start_points[curve_i] = lookup_curve_point(curves,
892 evaluated_points_by_curve,
893 curve_type,
894 curve_i,
895 lengths,
896 start_length,
897 cyclic,
898 resolution[curve_i],
899 point_count);
900 if (equal_sample_point) {
901 end_points[curve_i] = start_points[curve_i];
902 if (end_length <= start_length) {
903 /* Single point. */
904 dst_curve_size[curve_i] = 1;
905 if (start_points[curve_i].is_controlpoint()) {
906 /* Only iterate if control point. */
907 const int single_point_index = start_points[curve_i].parameter == 1.0f ?
908 start_points[curve_i].next_index :
909 start_points[curve_i].index;
911 single_point_index, 1, point_count);
912 }
913 /* else: leave empty range */
914 }
915 else {
916 /* Split. */
918 start_points[curve_i], end_points[curve_i], point_count)
919 .push_loop();
920 const int count = 1 + !start_points[curve_i].is_controlpoint() + point_count;
921 BLI_assert(count > 1);
922 dst_curve_size[curve_i] = count;
923 }
924 }
925 else {
926 /* General case. */
927 end_points[curve_i] = lookup_curve_point(curves,
928 evaluated_points_by_curve,
929 curve_type,
930 curve_i,
931 lengths,
932 end_length,
933 cyclic,
934 resolution[curve_i],
935 point_count);
936
938 start_points[curve_i], end_points[curve_i], point_count);
939 const int count = src_ranges[curve_i].size() + !start_points[curve_i].is_controlpoint() +
940 !end_points[curve_i].is_controlpoint();
941 BLI_assert(count > 1);
942 dst_curve_size[curve_i] = count;
943 }
944 BLI_assert(dst_curve_size[curve_i] > 0);
945 },
947}
948
950
951/* -------------------------------------------------------------------- */
954
956 const IndexMask &selection,
957 const VArray<float> &starts,
958 const VArray<float> &ends,
960 const bke::AttributeFilter &attribute_filter)
961{
963 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
964 IndexMaskMemory memory;
965 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
966
967 BLI_assert(selection.size() > 0);
968 BLI_assert(selection.last() <= src_curves.curves_num());
969 BLI_assert(starts.size() == src_curves.curves_num());
970 BLI_assert(starts.size() == ends.size());
971 src_curves.ensure_evaluated_lengths();
972
974 MutableSpan<int> dst_curve_offsets = dst_curves.offsets_for_write();
975 Array<bke::curves::CurvePoint, 16> start_points(src_curves.curves_num());
976 Array<bke::curves::CurvePoint, 16> end_points(src_curves.curves_num());
979 selection,
980 starts,
981 ends,
982 mode,
983 dst_curve_offsets,
984 start_points,
985 end_points,
986 src_ranges);
987 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_curve_offsets);
989 dst_curve_offsets);
990 dst_curves.resize(dst_curves.offsets().last(), dst_curves.curves_num());
991
992 /* Populate curve domain. */
993 const bke::AttributeAccessor src_attributes = src_curves.attributes();
994 bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
995 Set<std::string> transfer_curve_skip = {"cyclic", "curve_type", "nurbs_order", "knots_mode"};
996 if (dst_curves.has_curve_with_type(CURVE_TYPE_NURBS)) {
997 /* If a NURBS curve is copied keep */
998 transfer_curve_skip.remove("nurbs_order");
999 transfer_curve_skip.remove("knots_mode");
1000 }
1001
1002 /* Fetch custom point domain attributes for transfer (copy). */
1004 src_attributes,
1005 dst_attributes,
1007 bke::attribute_filter_with_skip_ref(attribute_filter,
1008 {"position",
1009 "handle_left",
1010 "handle_right",
1011 "handle_type_left",
1012 "handle_type_right",
1013 "nurbs_weight"}));
1014
1015 auto trim_catmull = [&](const IndexMask &selection) {
1016 trim_catmull_rom_curves(src_curves,
1017 dst_curves,
1018 selection,
1019 start_points,
1020 end_points,
1021 src_ranges,
1022 transfer_attributes);
1023 };
1024 auto trim_poly = [&](const IndexMask &selection) {
1025 trim_polygonal_curves(src_curves,
1026 dst_curves,
1027 selection,
1028 start_points,
1029 end_points,
1030 src_ranges,
1031 transfer_attributes);
1032 };
1033 auto trim_bezier = [&](const IndexMask &selection) {
1034 trim_bezier_curves(src_curves,
1035 dst_curves,
1036 selection,
1037 start_points,
1038 end_points,
1039 src_ranges,
1040 transfer_attributes);
1041 };
1042 auto trim_evaluated = [&](const IndexMask &selection) {
1043 dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY);
1044 /* Ensure evaluated positions are available. */
1045 src_curves.evaluated_positions();
1046 trim_evaluated_curves(src_curves,
1047 dst_curves,
1048 selection,
1049 start_points,
1050 end_points,
1051 src_ranges,
1052 transfer_attributes);
1053 };
1054
1055 /* Populate point domain. */
1057 src_curves.curve_type_counts(),
1058 selection,
1059 trim_catmull,
1060 trim_poly,
1061 trim_bezier,
1062 trim_evaluated);
1063
1064 /* Cleanup/close context */
1065 for (bke::AttributeTransferData &attribute : transfer_attributes) {
1066 attribute.dst.finish();
1067 }
1068
1069 /* Copy unselected */
1070 if (unselected.is_empty()) {
1071 /* Since all curves were trimmed, none of them are cyclic and the attribute can be removed. */
1072 dst_curves.attributes_for_write().remove("cyclic");
1073 }
1074 else {
1075 /* Only trimmed curves are no longer cyclic. */
1076 if (bke::SpanAttributeWriter cyclic = dst_attributes.lookup_for_write_span<bool>("cyclic")) {
1077 index_mask::masked_fill(cyclic.span, false, selection);
1078 cyclic.finish();
1079 }
1080
1081 Set<std::string> copy_point_skip;
1082 if (!dst_curves.has_curve_with_type(CURVE_TYPE_NURBS) &&
1084 {
1085 copy_point_skip.add("nurbs_weight");
1086 }
1087
1089 src_attributes,
1092 bke::attribute_filter_with_skip_ref(attribute_filter, copy_point_skip),
1093 src_points_by_curve,
1094 dst_points_by_curve,
1095 unselected,
1096 dst_attributes);
1097 }
1098
1100 dst_curves.tag_topology_changed();
1101 if (src_curves.nurbs_has_custom_knots()) {
1104 }
1105 return dst_curves;
1106}
1107
1109
1110} // namespace blender::geometry
Low-level operations for curves.
Low-level operations for curves.
#define PRF_scope(category)
constexpr int64_t first() const
constexpr int64_t one_after_last() const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr int64_t size() const
Definition BLI_span.hh:499
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
Definition BLI_span.hh:579
constexpr void fill(const T &value) const
Definition BLI_span.hh:523
constexpr void copy_from(Span< T > values) const
Definition BLI_span.hh:745
bool add(const Key &key)
Definition BLI_set.hh:248
bool remove(const Key &key)
Definition BLI_set.hh:404
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:141
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr const T & last(const int64_t n=0) const
Definition BLI_span.hh:329
constexpr const T * end() const
Definition BLI_span.hh:228
constexpr const T * begin() const
Definition BLI_span.hh:224
MutableSpan< int8_t > handle_types_left_for_write()
VArray< int8_t > curve_types() const
MutableSpan< float3 > positions_for_write()
MutableSpan< int8_t > handle_types_right_for_write()
std::optional< Span< float3 > > handle_positions_right() const
void resize(int points_num, int curves_num)
VArray< bool > cyclic() const
AttributeAccessor attributes() const
Span< float3 > positions() const
MutableSpan< float3 > handle_positions_right_for_write()
std::optional< Span< float3 > > handle_positions_left() const
Span< int > bezier_evaluated_offsets_for_curve(int curve_index) const
IndexRange curves_range() const
VArray< int8_t > handle_types_left() const
OffsetIndices< int > evaluated_points_by_curve() const
MutableSpan< float3 > handle_positions_left_for_write()
bool has_curve_with_type(CurveType type) const
MutableSpan< int > offsets_for_write()
void fill_curve_types(CurveType type)
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts() const
Span< float3 > evaluated_positions() const
MutableSpan< float > nurbs_weights_for_write()
VArray< int8_t > handle_types_right() const
OffsetIndices< int > points_by_curve() const
MutableAttributeAccessor attributes_for_write()
GSpanAttributeWriter lookup_for_write_span(StringRef name)
constexpr IndexRangeCyclic drop_front(const int n=1) const
constexpr IndexRange curve_range() const
static IndexRangeCyclic get_range_between_endpoints(const CurvePoint start_point, const CurvePoint end_point, const int iterable_range_size)
static IndexRangeCyclic get_range_from_size(const int start_index, const int iterator_size, const int iterable_range_size)
constexpr Span slice(int64_t start, int64_t size) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexMask complement(const IndexMask &universe, LinearAllocator<> &memory) const
#define attribute(slot)
float length(VecOp< float, D >) RET
#define T
void to_static_type(const CPPType &cpp_type, Fn &&fn)
T mix2(float factor, const T &a, const T &b)
Insertion insert(const float3 &point_prev, const float3 &handle_prev, const float3 &handle_next, const float3 &point_next, float parameter)
bool has_vector_handles(int num_curve_points, int64_t evaluated_size, bool cyclic, int resolution)
T interpolate(const T &a, const T &b, const T &c, const T &d, const float parameter)
void update_custom_knot_modes(const IndexMask &mask, const KnotsMode mode_for_regular, const KnotsMode mode_for_cyclic, bke::CurvesGeometry &curves)
bke::CurvesGeometry copy_only_curve_domain(const bke::CurvesGeometry &src_curves)
void fill_points(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, GPointer value, GMutableSpan dst)
void foreach_curve_by_type(const VArray< int8_t > &types, const std::array< int, CURVE_TYPES_NUM > &type_counts, const IndexMask &selection, FunctionRef< void(IndexMask)> catmull_rom_fn, FunctionRef< void(IndexMask)> poly_fn, FunctionRef< void(IndexMask)> bezier_fn, FunctionRef< void(IndexMask)> nurbs_fn)
auto attribute_filter_with_skip_ref(const AttributeFilter &filter, const Span< StringRef > skip)
Vector< AttributeTransferData > retrieve_attributes_for_transfer(const AttributeAccessor src_attributes, MutableAttributeAccessor dst_attributes, Span< AttrDomain > domains, const AttributeFilter &attribute_filter={})
void copy_attributes_group_to_group(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
constexpr ParallelGrainSize grain_size(int grain_size)
static void trim_bezier_curves(const bke::CurvesGeometry &src_curves, bke::CurvesGeometry &dst_curves, const IndexMask &selection, const Span< bke::curves::CurvePoint > start_points, const Span< bke::curves::CurvePoint > end_points, const Span< bke::curves::IndexRangeCyclic > src_ranges, MutableSpan< bke::AttributeTransferData > transfer_attributes)
static bke::curves::CurvePoint lookup_point_bezier(const Span< int > bezier_offsets, const Span< float > lengths, const float sample_length, const bool cyclic, const int num_curve_points)
static void sample_interval_linear(const Span< T > src_data, MutableSpan< T > dst_data, bke::curves::IndexRangeCyclic src_range, const IndexRange dst_range, const bke::curves::CurvePoint start_point, const bke::curves::CurvePoint end_point)
static bke::curves::CurvePoint lookup_curve_point(const bke::CurvesGeometry &src_curves, const OffsetIndices< int > evaluated_points_by_curve, const CurveType curve_type, const int64_t curve_index, const Span< float > accumulated_lengths, const float sample_length, const bool cyclic, const int resolution, const int num_curve_points)
static bke::curves::bezier::Insertion knot_insert_bezier(const Span< float3 > positions, const Span< float3 > handles_left, const Span< float3 > handles_right, const bke::curves::CurvePoint insertion_point)
bke::CurvesGeometry trim_curves(const bke::CurvesGeometry &src_curves, const IndexMask &selection, const VArray< float > &starts, const VArray< float > &ends, GeometryNodeCurveSampleMode mode, const bke::AttributeFilter &attribute_filter)
static int64_t copy_point_data_between_endpoints(const Span< T > src_data, MutableSpan< T > dst_data, const bke::curves::IndexRangeCyclic src_range, int64_t dst_index)
static void trim_polygonal_curves(const bke::CurvesGeometry &src_curves, bke::CurvesGeometry &dst_curves, const IndexMask &selection, const Span< bke::curves::CurvePoint > start_points, const Span< bke::curves::CurvePoint > end_points, const Span< bke::curves::IndexRangeCyclic > src_ranges, MutableSpan< bke::AttributeTransferData > transfer_attributes)
static float trim_sample_length(const Span< float > accumulated_lengths, const float sample_length, const GeometryNodeCurveSampleMode mode)
static T interpolate_catmull_rom(const Span< T > src_data, const bke::curves::CurvePoint insertion_point, const bool src_cyclic)
static bke::curves::CurvePoint lookup_point_polygonal(const Span< float > lengths, const float sample_length, const bool cyclic, const int evaluated_size)
static bke::curves::CurvePoint lookup_point_uniform_spacing(const Span< float > lengths, const float sample_length, const bool cyclic, const int resolution, const int num_curve_points)
static void trim_attribute_linear(const bke::CurvesGeometry &src_curves, bke::CurvesGeometry &dst_curves, const IndexMask &selection, const Span< bke::curves::CurvePoint > start_points, const Span< bke::curves::CurvePoint > end_points, const Span< bke::curves::IndexRangeCyclic > src_ranges, MutableSpan< bke::AttributeTransferData > transfer_attributes)
static void compute_curve_trim_parameters(const bke::CurvesGeometry &curves, const IndexMask &selection, const VArray< float > &starts, const VArray< float > &ends, const GeometryNodeCurveSampleMode mode, MutableSpan< int > dst_curve_size, MutableSpan< bke::curves::CurvePoint > start_points, MutableSpan< bke::curves::CurvePoint > end_points, MutableSpan< bke::curves::IndexRangeCyclic > src_ranges)
static void sample_interval_catmull_rom(const Span< T > src_data, MutableSpan< T > dst_data, bke::curves::IndexRangeCyclic src_range, const IndexRange dst_range, const bke::curves::CurvePoint start_point, const bke::curves::CurvePoint end_point, const bool src_cyclic)
static void trim_catmull_rom_curves(const bke::CurvesGeometry &src_curves, bke::CurvesGeometry &dst_curves, const IndexMask &selection, const Span< bke::curves::CurvePoint > start_points, const Span< bke::curves::CurvePoint > end_points, const Span< bke::curves::IndexRangeCyclic > src_ranges, MutableSpan< bke::AttributeTransferData > transfer_attributes)
static void fill_nurbs_data(bke::CurvesGeometry &dst_curves, const IndexMask &selection)
static void sample_interval_bezier(const Span< float3 > src_positions, const Span< float3 > src_handles_l, const Span< float3 > src_handles_r, const Span< int8_t > src_types_l, const Span< int8_t > src_types_r, MutableSpan< float3 > dst_positions, MutableSpan< float3 > dst_handles_l, MutableSpan< float3 > dst_handles_r, MutableSpan< int8_t > dst_types_l, MutableSpan< int8_t > dst_types_r, bke::curves::IndexRangeCyclic src_range, const IndexRange dst_range, const bke::curves::CurvePoint start_point, const bke::curves::CurvePoint end_point)
static void trim_evaluated_curves(const bke::CurvesGeometry &src_curves, bke::CurvesGeometry &dst_curves, const IndexMask &selection, const Span< bke::curves::CurvePoint > start_points, const Span< bke::curves::CurvePoint > end_points, const Span< bke::curves::IndexRangeCyclic > src_ranges, MutableSpan< bke::AttributeTransferData > transfer_attributes)
static void fill_bezier_data(bke::CurvesGeometry &dst_curves, const IndexMask &selection)
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 copy_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
@ NURBS_KNOT_MODE_NORMAL
@ CURVE_TYPE_CATMULL_ROM
VecBase< float, 3 > float3
signed char int8_t
Definition BKE_text.h:76
GeometryNodeCurveSampleMode
@ GEO_NODE_CURVE_SAMPLE_FACTOR