Blender V5.3
resample_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
9#include "BLI_array_utils.hh"
10#include "BLI_math_color.hh"
12#include "BLI_math_vector.hh"
13
15#include "BLI_task.hh"
16
17#include "FN_field.hh"
20
21#include "BKE_attribute_math.hh"
22#include "BKE_curves.hh"
23#include "BKE_curves_utils.hh"
24#include "BKE_deform.hh"
26
28
29namespace blender::geometry {
30
32{
33 return fn::Field<int>(
35 {fn::Field<int>(1), count_field}));
36}
37
38static int get_count_from_length(const float curve_length,
39 const float sample_length,
40 const bool keep_last_segment)
41{
42 /* Find the number of sampled segments by dividing the total length by
43 * the sample length. Then there is one more sampled point than segment. */
44 if (sample_length == 0.0f) [[unlikely]] {
45 return 1;
46 }
47 const int count = int(curve_length / sample_length) + 1;
48 return std::max(keep_last_segment ? 2 : 1, count);
49}
50
52 const bool keep_last_segment)
53{
54 static auto get_count_fn = mf::build::SI3_SO<float, float, bool, int>(
55 "Length Input to Count",
57 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
58
59 auto get_count_op = fn::FieldOperation::from(
60 get_count_fn,
62 length_field,
63 fn::Field<bool>(keep_last_segment)});
64
65 return fn::Field<int>(std::move(get_count_op));
66}
67
73 const std::array<int, CURVE_TYPES_NUM> &type_counts)
74{
76 return true;
77 }
78 if (ELEM(name, "handle_type_left", "handle_type_right", "handle_left", "handle_right")) {
79 return type_counts[CURVE_TYPE_BEZIER] != 0;
80 }
81 if (ELEM(name, "nurbs_weight")) {
82 return type_counts[CURVE_TYPE_NURBS] != 0;
83 }
84 return true;
85}
86
91{
92 static const Set<StringRef> no_interpolation{{
93 "handle_type_left",
94 "handle_type_right",
95 "handle_right",
96 "handle_left",
97 "nurbs_weight",
98 }};
99 return !no_interpolation.contains(name);
100}
101
106 const CurvesGeometry &src_curves,
107 CurvesGeometry &dst_curves,
108 Vector<GVArraySpan> &src_arrays,
109 Vector<GMutableSpan> &dst_arrays,
111{
112 const bke::AttributeAccessor src_attributes = src_curves.attributes();
113 bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
114 for (const int i : names.index_range()) {
115 GVArray src_attribute = *src_attributes.lookup(names[i], bke::AttrDomain::Point);
116 const bke::AttrType data_type = bke::cpp_type_to_attribute_type(src_attribute.type());
117
118 const CommonVArrayInfo info = src_attribute.common_info();
120 const bke::AttributeInitValue init(GPointer(src_attribute.type(), info.data));
121 dst_attributes.add(names[i], bke::AttrDomain::Point, data_type, init);
122 continue;
123 }
124
125 src_arrays.append(std::move(src_attribute));
126
128 names[i], bke::AttrDomain::Point, data_type);
129 dst_arrays.append(dst_attribute.span);
130 dst_writers.append(std::move(dst_attribute));
131 }
132}
133
148
153 const CurvesGeometry &src_curves,
154 CurvesGeometry &dst_curves,
156 const ResampleCurvesOutputAttributeIDs &output_ids)
157{
159 VectorSet<StringRef> names_no_interpolation;
160 src_curves.attributes().foreach_attribute([&](const bke::AttributeIter &iter) {
161 if (iter.domain != bke::AttrDomain::Point) {
162 return;
163 }
164 if (iter.data_type == bke::AttrType::String) {
165 return;
166 }
167 if (!interpolate_attribute_to_curves(iter.name, dst_curves.curve_type_counts())) {
168 return;
169 }
171 names.add_new(iter.name);
172 }
173 else {
174 names_no_interpolation.add_new(iter.name);
175 }
176 });
177
178 /* Position is handled differently since it has non-generic interpolation for Bezier
179 * curves and because the evaluated positions are cached for each evaluated point. */
180 names.remove_contained("position");
181
183 names, src_curves, dst_curves, result.src, result.dst, result.dst_attributes);
184
185 /* Attributes that aren't interpolated like Bezier handles still have to be copied
186 * to the result when there are any unselected curves of the corresponding type. */
187 retrieve_attribute_spans(names_no_interpolation,
188 src_curves,
189 dst_curves,
190 result.src_no_interpolation,
191 result.dst_no_interpolation,
192 result.dst_attributes);
193
194 bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
195 if (output_ids.tangent_id) {
196 result.src_evaluated_tangents = src_curves.evaluated_tangents();
199 result.dst_tangents = dst_attribute.span.typed<float3>();
200 result.dst_attributes.append(std::move(dst_attribute));
201 }
202 if (output_ids.normal_id) {
203 result.src_evaluated_normals = src_curves.evaluated_normals();
206 result.dst_normals = dst_attribute.span.typed<float3>();
207 result.dst_attributes.append(std::move(dst_attribute));
208 }
209}
210
212 const IndexMask &unselected_curves,
213 const AttributesForResample &attributes,
214 CurvesGeometry &dst_curves)
215{
216 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
217 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
218 array_utils::copy_group_to_group(src_points_by_curve,
219 dst_points_by_curve,
220 unselected_curves,
221 src_curves.positions(),
222 dst_curves.positions_for_write());
223
224 for (const int i : attributes.src.index_range()) {
225 array_utils::copy_group_to_group(src_points_by_curve,
226 dst_points_by_curve,
227 unselected_curves,
228 attributes.src[i],
229 attributes.dst[i]);
230 }
231 for (const int i : attributes.src_no_interpolation.index_range()) {
232 array_utils::copy_group_to_group(src_points_by_curve,
233 dst_points_by_curve,
234 unselected_curves,
235 attributes.src_no_interpolation[i],
236 attributes.dst_no_interpolation[i]);
237 }
238
239 if (!attributes.dst_tangents.is_empty()) {
241 dst_points_by_curve, unselected_curves, float3(0), attributes.dst_tangents);
242 }
243 if (!attributes.dst_normals.is_empty()) {
245 dst_points_by_curve, unselected_curves, float3(0), attributes.dst_normals);
246 }
247}
248
250{
251 for (const int i : data.index_range()) {
252 data[i] = math::normalize(data[i]);
253 }
254}
255
256static void normalize_curve_point_data(const IndexMaskSegment curve_selection,
257 const OffsetIndices<int> points_by_curve,
259{
260 for (const int i_curve : curve_selection) {
261 normalize_span(data.slice(points_by_curve[i_curve]));
262 }
263}
264
271 /* Use a default alignment that works for all attribute types, and don't use the inline buffer
272 * because it doesn't necessarily have the correct alignment. */
274 alignas(AllocatorType::min_alignment) std::array<std::byte, 1024> inline_buffer;
275
276 template<typename T> MutableSpan<T> resize(const int64_t size)
277 {
278 const int64_t size_in_bytes = sizeof(T) * size;
279 if (size_in_bytes <= this->inline_buffer.size()) {
280 return MutableSpan<std::byte>(this->inline_buffer).slice(0, size_in_bytes).cast<T>();
281 }
282 this->heap_allocated.resize(size_in_bytes);
283 return this->heap_allocated.as_mutable_span().cast<T>();
284 }
285};
286
287static void resample_to_uniform(const CurvesGeometry &src_curves,
288 const IndexMask &selection,
289 const ResampleCurvesOutputAttributeIDs &output_ids,
290 CurvesGeometry &dst_curves)
291{
292 if (src_curves.curves_range().is_empty()) {
293 return;
294 }
295
296 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
297 const OffsetIndices evaluated_points_by_curve = src_curves.evaluated_points_by_curve();
298 const VArray<bool> curves_cyclic = src_curves.cyclic();
299 const VArray<int8_t> curve_types = src_curves.curve_types();
300 const Span<float3> evaluated_positions = src_curves.evaluated_positions();
301
302 /* All resampled curves are poly curves. */
303 dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY);
304
305 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
306
307 AttributesForResample attributes;
308 gather_point_attributes_to_interpolate(src_curves, dst_curves, attributes, output_ids);
309
310 src_curves.ensure_evaluated_lengths();
311
312 /* Sampling arbitrary attributes works by first interpolating them to the curve's standard
313 * "evaluated points" and then interpolating that result with the uniform samples. This is
314 * potentially wasteful when down-sampling a curve to many fewer points. There are two possible
315 * solutions: only sample the necessary points for interpolation, or first sample curve
316 * parameter/segment indices and evaluate the curve directly. */
317 Array<int> sample_indices(dst_curves.points_num());
318 Array<float> sample_factors(dst_curves.points_num());
319
320 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
321
322 /* Use a "for each group of curves: for each attribute: for each curve" pattern to work on
323 * smaller sections of data that ideally fit into CPU cache better than simply one attribute at a
324 * time or one curve at a time. */
325 selection.foreach_segment(
326 [&](const IndexMaskSegment selection_segment) {
327 EvalDataBuffer evaluated_buffer;
328
329 /* Gather uniform samples based on the accumulated lengths of the original curve. */
330 for (const int i_curve : selection_segment) {
331 const bool cyclic = curves_cyclic[i_curve];
332 const IndexRange dst_points = dst_points_by_curve[i_curve];
333 const Span<float> lengths = src_curves.evaluated_lengths_for_curve(i_curve, cyclic);
334 if (lengths.is_empty()) {
335 /* Handle curves with only one evaluated point. */
336 sample_indices.as_mutable_span().slice(dst_points).fill(0);
337 sample_factors.as_mutable_span().slice(dst_points).fill(0.0f);
338 }
339 else {
341 lengths,
342 !curves_cyclic[i_curve],
343 sample_indices.as_mutable_span().slice(dst_points),
344 sample_factors.as_mutable_span().slice(dst_points));
345 }
346 }
347
348 /* For every attribute, evaluate attributes from every curve in the range in the original
349 * curve's "evaluated points", then use linear interpolation to sample to the result. */
350 for (const int i_attribute : attributes.dst.index_range()) {
351 const CPPType &type = attributes.src[i_attribute].type();
352 bke::attribute_math::to_static_type(type, [&]<typename T>() {
353 if constexpr (!std::is_same_v<T, std::string>) {
354 Span<T> src = attributes.src[i_attribute].typed<T>();
355 MutableSpan<T> dst = attributes.dst[i_attribute].typed<T>();
356
357 for (const int i_curve : selection_segment) {
358 const IndexRange src_points = src_points_by_curve[i_curve];
359 const IndexRange dst_points = dst_points_by_curve[i_curve];
360
361 if (curve_types[i_curve] == CURVE_TYPE_POLY) {
363 sample_indices.as_span().slice(dst_points),
364 sample_factors.as_span().slice(dst_points),
365 dst.slice(dst_points));
366 }
367 else {
368 MutableSpan evaluated = evaluated_buffer.resize<T>(
369 evaluated_points_by_curve[i_curve].size());
370 src_curves.interpolate_to_evaluated(i_curve, src.slice(src_points), evaluated);
371
373 sample_indices.as_span().slice(dst_points),
374 sample_factors.as_span().slice(dst_points),
375 dst.slice(dst_points));
376 }
377 }
378 }
379 });
380 }
381
382 auto interpolate_evaluated_data = [&](const Span<float3> src, MutableSpan<float3> dst) {
383 for (const int i_curve : selection_segment) {
384 const IndexRange src_points = evaluated_points_by_curve[i_curve];
385 const IndexRange dst_points = dst_points_by_curve[i_curve];
387 sample_indices.as_span().slice(dst_points),
388 sample_factors.as_span().slice(dst_points),
389 dst.slice(dst_points));
390 }
391 };
392
393 /* Interpolate the evaluated positions to the resampled curves. */
394 interpolate_evaluated_data(evaluated_positions, dst_positions);
395
396 if (!attributes.dst_tangents.is_empty()) {
397 interpolate_evaluated_data(attributes.src_evaluated_tangents, attributes.dst_tangents);
399 selection_segment, dst_points_by_curve, attributes.dst_tangents);
400 }
401 if (!attributes.dst_normals.is_empty()) {
402 interpolate_evaluated_data(attributes.src_evaluated_normals, attributes.dst_normals);
404 selection_segment, dst_points_by_curve, attributes.dst_normals);
405 }
406
407 /* Fill the default value for non-interpolating attributes that still must be copied. */
408 for (GMutableSpan dst : attributes.dst_no_interpolation) {
409 for (const int i_curve : selection_segment) {
410 const IndexRange dst_points = dst_points_by_curve[i_curve];
411 dst.type().value_initialize_n(dst.slice(dst_points).data(), dst_points.size());
412 }
413 }
414 },
416
417 IndexMaskMemory memory;
418 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
419 copy_or_defaults_for_unselected_curves(src_curves, unselected, attributes, dst_curves);
420
422 attribute.finish();
423 }
424}
425
427 const fn::FieldContext &field_context,
428 const fn::Field<bool> &selection_field,
429 const fn::Field<int> &count_field,
430 const ResampleCurvesOutputAttributeIDs &output_ids)
431{
432 if (src_curves.curves_range().is_empty()) {
433 return {};
434 }
435 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
436
438 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
440 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
441
442 fn::FieldEvaluator evaluator{field_context, src_curves.curves_num()};
443 evaluator.set_selection(selection_field);
444 evaluator.add_with_destination(count_field, dst_offsets.drop_back(1));
445 evaluator.evaluate();
446 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
447 IndexMaskMemory memory;
448 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
449
450 /* Fill the counts for the curves that aren't selected and accumulate the counts into offsets. */
451 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
453 return {};
454 }
455 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
456
457 resample_to_uniform(src_curves, selection, output_ids, dst_curves);
458
459 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
460 return dst_curves;
461}
462
464 const IndexMask &selection,
465 const VArray<int> &counts,
466 const ResampleCurvesOutputAttributeIDs &output_ids)
467{
468 if (src_curves.curves_range().is_empty()) {
469 return {};
470 }
471 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
472
474 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
476 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
477
478 array_utils::copy(counts, selection, dst_offsets);
479
480 IndexMaskMemory memory;
481 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
482
483 /* Fill the counts for the curves that aren't selected and accumulate the counts into offsets. */
484 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
485 /* We assume the counts are at least 1. */
486 BLI_assert(std::all_of(dst_offsets.begin(),
487 dst_offsets.drop_back(1).end(),
488 [&](const int count) { return count > 0; }));
490 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
491
492 resample_to_uniform(src_curves, selection, output_ids, dst_curves);
493
494 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
495 return dst_curves;
496}
497
499 const fn::FieldContext &field_context,
500 const fn::Field<bool> &selection_field,
501 const fn::Field<int> &count_field,
502 const ResampleCurvesOutputAttributeIDs &output_ids)
503{
504 return resample_to_uniform(src_curves,
505 field_context,
506 selection_field,
507 get_count_input_max_one(count_field),
508 output_ids);
509}
510
512 const IndexMask &selection,
513 const VArray<float> &sample_lengths,
514 const ResampleCurvesOutputAttributeIDs &output_ids,
515 const bool keep_last_segment)
516{
517 if (src_curves.curves_range().is_empty()) {
518 return {};
519 }
520 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
521 const VArray<bool> curves_cyclic = src_curves.cyclic();
522
524 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
526 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
527
528 src_curves.ensure_evaluated_lengths();
529 selection.foreach_index(
530 [&](const int curve_i) {
531 const float curve_length = src_curves.evaluated_length_total_for_curve(
532 curve_i, curves_cyclic[curve_i]);
533 dst_offsets[curve_i] = get_count_from_length(
534 curve_length, sample_lengths[curve_i], keep_last_segment);
535 },
537
538 IndexMaskMemory memory;
539 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
540
541 /* Fill the counts for the curves that aren't selected and accumulate the counts into offsets. */
542 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
544 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
545
546 resample_to_uniform(src_curves, selection, output_ids, dst_curves);
547
548 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
549 return dst_curves;
550}
551
553 const fn::FieldContext &field_context,
554 const fn::Field<bool> &selection_field,
555 const fn::Field<float> &segment_length_field,
556 const ResampleCurvesOutputAttributeIDs &output_ids,
557 const bool keep_last_segment)
558{
559 return resample_to_uniform(src_curves,
560 field_context,
561 selection_field,
562 get_count_input_from_length(segment_length_field, keep_last_segment),
563 output_ids);
564}
565
567 const IndexMask &selection,
568 const ResampleCurvesOutputAttributeIDs &output_ids)
569{
570 if (src_curves.curves_range().is_empty()) {
571 return {};
572 }
573 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
574 const OffsetIndices src_evaluated_points_by_curve = src_curves.evaluated_points_by_curve();
575 const Span<float3> evaluated_positions = src_curves.evaluated_positions();
576
577 IndexMaskMemory memory;
578 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
579
581 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
583 dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY);
584 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
585 offset_indices::copy_group_sizes(src_evaluated_points_by_curve, selection, dst_offsets);
586 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
588 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
589
590 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
591
592 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
593
594 AttributesForResample attributes;
595 gather_point_attributes_to_interpolate(src_curves, dst_curves, attributes, output_ids);
596
598 selection.foreach_segment(
599 [&](const IndexMaskSegment selection_segment) {
600 /* Evaluate generic point attributes directly to the result attributes. */
601 for (const int i_attribute : attributes.dst.index_range()) {
602 for (const int i_curve : selection_segment) {
603 const IndexRange src_points = src_points_by_curve[i_curve];
604 const IndexRange dst_points = dst_points_by_curve[i_curve];
605 src_curves.interpolate_to_evaluated(i_curve,
606 attributes.src[i_attribute].slice(src_points),
607 attributes.dst[i_attribute].slice(dst_points));
608 }
609 }
610
611 auto copy_evaluated_data = [&](const Span<float3> src, MutableSpan<float3> dst) {
612 for (const int i_curve : selection_segment) {
613 const IndexRange src_points = src_evaluated_points_by_curve[i_curve];
614 const IndexRange dst_points = dst_points_by_curve[i_curve];
615 dst.slice(dst_points).copy_from(src.slice(src_points));
616 }
617 };
618
619 /* Copy the evaluated positions to the selected curves. */
620 copy_evaluated_data(evaluated_positions, dst_positions);
621
622 if (!attributes.dst_tangents.is_empty()) {
623 copy_evaluated_data(attributes.src_evaluated_tangents, attributes.dst_tangents);
625 selection_segment, dst_points_by_curve, attributes.dst_tangents);
626 }
627 if (!attributes.dst_normals.is_empty()) {
628 copy_evaluated_data(attributes.src_evaluated_normals, attributes.dst_normals);
630 selection_segment, dst_points_by_curve, attributes.dst_normals);
631 }
632
633 /* Fill the default value for non-interpolating attributes that still must be copied. */
634 for (GMutableSpan dst : attributes.dst_no_interpolation) {
635 for (const int i_curve : selection_segment) {
636 const IndexRange dst_points = dst_points_by_curve[i_curve];
637 dst.type().value_initialize_n(dst.slice(dst_points).data(), dst_points.size());
638 }
639 }
640 },
642
643 copy_or_defaults_for_unselected_curves(src_curves, unselected, attributes, dst_curves);
644
646 attribute.finish();
647 }
648
649 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
650 return dst_curves;
651}
652
654 const fn::FieldContext &field_context,
655 const fn::Field<bool> &selection_field,
656 const ResampleCurvesOutputAttributeIDs &output_ids)
657{
658 if (src_curves.curves_range().is_empty()) {
659 return {};
660 }
661 fn::FieldEvaluator evaluator{field_context, src_curves.curves_num()};
662 evaluator.set_selection(selection_field);
663 evaluator.evaluate();
665 src_curves, evaluator.get_evaluated_selection_as_mask(), output_ids);
666}
667
668} // namespace blender::geometry
Low-level operations for curves.
Low-level operations for curves.
support for deformation groups and hooks.
#define ELEM(...)
Span< T > as_span() const
Definition BLI_array.hh:254
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:259
void value_initialize_n(void *ptr, int64_t n) const
GMutableSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
MutableSpan< T > typed() const
GPointer()=default
CommonVArrayInfo common_info() const
static constexpr size_t min_alignment
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
Definition BLI_span.hh:579
constexpr MutableSpan< NewT > cast() const
Definition BLI_span.hh:755
constexpr MutableSpan drop_back(const int64_t n) const
Definition BLI_span.hh:624
constexpr Span< T > as_span() const
Definition BLI_span.hh:667
constexpr T * end() const
Definition BLI_span.hh:554
constexpr T * begin() const
Definition BLI_span.hh:550
constexpr T & last(const int64_t n=0) const
Definition BLI_span.hh:695
bool contains(const Key &key) const
Definition BLI_set.hh:310
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:141
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr bool is_empty() const
Definition BLI_span.hh:264
void add_new(const Key &key)
void remove_contained(const Key &key)
void append(const T &value)
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup(const StringRef name) const
Span< float3 > evaluated_tangents() const
VArray< int8_t > curve_types() const
void ensure_can_interpolate_to_evaluated() const
MutableSpan< float3 > positions_for_write()
void resize(int points_num, int curves_num)
VArray< bool > cyclic() const
AttributeAccessor attributes() const
Span< float3 > positions() const
void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const
IndexRange curves_range() const
Span< float > evaluated_lengths_for_curve(int curve_index, bool cyclic) const
OffsetIndices< int > evaluated_points_by_curve() 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
float evaluated_length_total_for_curve(int curve_index, bool cyclic) const
OffsetIndices< int > points_by_curve() const
Span< float3 > evaluated_normals() const
MutableAttributeAccessor attributes_for_write()
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
void set_selection(Field< bool > selection)
IndexMask get_evaluated_selection_as_mask() const
int add_with_destination(GField field, GVMutableArray dst)
static FieldOperationPtr from(std::shared_ptr< const mf::MultiFunction > fn, Vector< GField > inputs)
Definition field.cc:252
static Field from_input(Args &&...args)
void foreach_segment(Fn &&fn, Mode mode=exec_mode::serial) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexMask complement(const IndexMask &universe, LinearAllocator<> &memory) const
OffsetIndices slice(const IndexRange range) const
#define attribute(slot)
#define T
void copy_group_to_group(OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, GSpan src, GMutableSpan dst)
void copy(const GVArray &src, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
void to_static_type(const CPPType &cpp_type, Fn &&fn)
void copy_custom_knots(const bke::CurvesGeometry &src_curves, const IndexMask &exclude_curves, bke::CurvesGeometry &dst_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)
bool attribute_name_is_anonymous(const StringRef name)
AttrType cpp_type_to_attribute_type(const CPPType &type)
constexpr ParallelGrainSize grain_size(int grain_size)
const MultiFunction & lookup(UString id)
static AttributesForInterpolation retrieve_attribute_spans(const Span< StringRef > names, const CurvesGeometry &src_from_curves, const CurvesGeometry &src_to_curves, const bke::AttrDomain domain, CurvesGeometry &dst_curves)
static fn::Field< int > get_count_input_max_one(const fn::Field< int > &count_field)
static void normalize_span(MutableSpan< float3 > data)
static void copy_or_defaults_for_unselected_curves(const CurvesGeometry &src_curves, const IndexMask &unselected_curves, const AttributesForResample &attributes, CurvesGeometry &dst_curves)
CurvesGeometry resample_to_count(const CurvesGeometry &src_curves, const IndexMask &selection, const VArray< int > &counts, const ResampleCurvesOutputAttributeIDs &output_ids={})
CurvesGeometry resample_to_evaluated(const CurvesGeometry &src_curves, const IndexMask &selection, const ResampleCurvesOutputAttributeIDs &output_ids={})
static int get_count_from_length(const float curve_length, const float sample_length, const bool keep_last_segment)
CurvesGeometry resample_to_length(const CurvesGeometry &src_curves, const IndexMask &selection, const VArray< float > &sample_lengths, const ResampleCurvesOutputAttributeIDs &output_ids={}, bool keep_last_segment=false)
static bool interpolate_attribute_to_curves(const StringRef name, const std::array< int, CURVE_TYPES_NUM > &type_counts)
static void resample_to_uniform(const CurvesGeometry &src_curves, const IndexMask &selection, const ResampleCurvesOutputAttributeIDs &output_ids, CurvesGeometry &dst_curves)
static AttributesForInterpolation gather_point_attributes_to_interpolate(const CurvesGeometry &from_curves, const CurvesGeometry &to_curves, CurvesGeometry &dst_curves)
static bool interpolate_attribute_to_poly_curve(const StringRef name)
static fn::Field< int > get_count_input_from_length(const fn::Field< float > &length_field, const bool keep_last_segment)
static void normalize_curve_point_data(const IndexMaskSegment curve_selection, const OffsetIndices< int > points_by_curve, MutableSpan< float3 > data)
void interpolate(const Span< T > src, const Span< int > indices, const Span< float > factors, MutableSpan< T > dst)
void sample_uniform(Span< float > accumulated_segment_lengths, bool include_last_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
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)
std::optional< OffsetIndices< int > > accumulate_counts_to_offsets_with_overflow_check(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
BMesh const char void * data
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
Definition deform.cc:75
VecBase< float, 3 > float3
ListBaseT< struct bDeformGroup > vertex_group_names
Vector< bke::GSpanAttributeWriter > dst_attributes
GuardedAlignedAllocator<> AllocatorType
MutableSpan< T > resize(const int64_t size)
std::array< std::byte, 1024 > inline_buffer
Vector< std::byte, 0, AllocatorType > heap_allocated