Blender V5.3
BKE_curves.hh
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#pragma once
6
11
12#include "BLI_array_utils.hh"
13#include "BLI_bounds_types.hh"
15#include "BLI_index_mask_fwd.hh"
19#include "BLI_offset_indices.hh"
20#include "BLI_shared_cache.hh"
21#include "BLI_span.hh"
22#include "BLI_vector.hh"
24
25#include "BKE_attribute_math.hh"
27#include "BKE_curves.h"
28
29namespace blender {
30
31struct BlendDataReader;
32struct BlendWriter;
33struct MDeformVert;
34namespace bke {
35struct GeometrySet;
38enum class AttrDomain : int8_t;
40} // namespace bke
41namespace bke::bake {
43}
44class GVArray;
45
46namespace bke {
47
48namespace curves::nurbs {
49
69
70} // namespace curves::nurbs
71
150
157 public:
164 CurvesGeometry(const CurvesGeometry &other);
169
170 /* --------------------------------------------------------------------
171 * Accessors.
172 */
173
177 int points_num() const;
181 int curves_num() const;
185 bool is_empty() const;
186
187 IndexRange points_range() const;
188 IndexRange curves_range() const;
189
196 Span<int> offsets() const;
198
203
212 void fill_curve_types(CurveType type);
214 void fill_curve_types(const IndexMask &selection, CurveType type);
216 void update_curve_types();
217
218 bool has_curve_with_type(CurveType type) const;
219 bool has_curve_with_type(Span<CurveType> types) const;
221 bool is_single_type(CurveType type) const;
223 const std::array<int, CURVE_TYPES_NUM> &curve_type_counts() const;
229 const IndexMask &selection,
230 IndexMaskMemory &memory) const;
231
233
234 Span<float3> positions() const;
236
237 VArray<float> radius() const;
239
241 VArray<bool> cyclic() const;
244
249 VArray<int> resolution() const;
252
257 VArray<float> tilt() const;
259
266
274
281 std::optional<Span<float3>> handle_positions_left() const;
283 std::optional<Span<float3>> handle_positions_right() const;
285
292
299
303 std::optional<Span<float>> nurbs_weights() const;
305
309 std::optional<Span<float2>> surface_uv_coords() const;
311
317
323
328
329 bool nurbs_has_custom_knots() const;
330
337
342 void nurbs_custom_knots_resize(int knots_num);
343
350
354 std::optional<Bounds<float3>> bounds_min_max(bool use_radius = true) const;
355
356 void count_memory(MemoryCounter &memory) const;
357
363 std::optional<int> material_index_max() const;
364
365 private:
366 /* --------------------------------------------------------------------
367 * Evaluation.
368 */
369
370 public:
375 int evaluated_points_num() const;
376
381
387 Span<int> bezier_evaluated_offsets_for_curve(int curve_index) const;
388
389 bool has_cyclic_curve() const;
390
394
404 Span<float> evaluated_lengths_for_curve(int curve_index, bool cyclic) const;
405 float evaluated_length_total_for_curve(int curve_index, bool cyclic) const;
406
408 void ensure_evaluated_lengths() const;
409
411
419 void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const;
423 void interpolate_to_evaluated(GSpan src, GMutableSpan dst) const;
424
425 private:
429 void ensure_nurbs_basis_cache() const;
430
432 IndexRange lengths_range_for_curve(int curve_index, bool cyclic) const;
433
434 /* --------------------------------------------------------------------
435 * Operations.
436 */
437
438 public:
445 void resize(int points_num, int curves_num);
446
455 void tag_normals_changed();
460 void tag_radii_changed();
463
464 void translate(const float3 &translation);
465 void transform(const float4x4 &matrix);
466
476
477 void remove_points(const IndexMask &points_to_delete, const AttributeFilter &attribute_filter);
478 void remove_curves(const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter);
479
484 void reverse_curves(const IndexMask &curves_to_reverse);
485
490
493
494 /* --------------------------------------------------------------------
495 * Attributes.
496 */
497
498 GVArray adapt_domain(const GVArray &varray, AttrDomain from, AttrDomain to) const;
499 template<typename T>
500 VArray<T> adapt_domain(const VArray<T> &varray, AttrDomain from, AttrDomain to) const
501 {
502 return this->adapt_domain(GVArray(varray), from, to).typed<T>();
503 }
504
505 /* --------------------------------------------------------------------
506 * File Read/Write.
507 */
508 void blend_read(BlendDataReader &reader);
519
523 void blend_write_prepare(BlendWriteData &write_data, bool use_5_0_compatibility);
524 void blend_write(BlendWriter &writer, ID &id, const BlendWriteData &write_data);
525};
526
527static_assert(sizeof(bke::CurvesGeometry) == sizeof(CurvesGeometry));
528
534 public:
548 std::optional<Array<float3x3>> deform_mats;
549
551
552 std::optional<Span<float3>> positions() const;
553 std::optional<MutableSpan<float3>> positions_for_write();
554
559 bool is_valid() const;
560};
561
563
564namespace curves {
565
566/* -------------------------------------------------------------------- */
569
574inline int segments_num(const int points_num, const bool cyclic)
575{
576 BLI_assert(points_num > 0);
577 return (cyclic && points_num > 1) ? points_num : points_num - 1;
578}
579
581{
582 BLI_assert(std::abs(v.x + v.y + v.z - 1.0f) < 0.00001f);
583 return {v.x, v.y};
584}
585
587{
588 return {v.x, v.y, 1.0f - v.x - v.y};
589}
590
597inline IndexRange per_curve_point_offsets_range(const IndexRange points, const int curve_index)
598{
599 return {curve_index + points.start(), points.size() + 1};
600}
601
603
604/* -------------------------------------------------------------------- */
607
608namespace poly {
609
616void calculate_tangents(Span<float3> positions, bool is_cyclic, MutableSpan<float3> tangents);
617
623void calculate_normals_minimum(Span<float3> tangents, bool cyclic, MutableSpan<float3> normals);
624
630
631} // namespace poly
632
634
635/* -------------------------------------------------------------------- */
638
639namespace bezier {
640
645bool segment_is_vector(const HandleType left, const HandleType right);
646bool segment_is_vector(const int8_t left, const int8_t right);
647bool segment_is_vector(Span<int8_t> handle_types_left,
648 Span<int8_t> handle_types_right,
649 int segment_index);
650
659bool has_vector_handles(int num_curve_points, int64_t evaluated_size, bool cyclic, int resolution);
660
665bool last_cyclic_segment_is_vector(Span<int8_t> handle_types_left,
666 Span<int8_t> handle_types_right);
667
673bool point_is_sharp(Span<int8_t> handle_types_left, Span<int8_t> handle_types_right, int index);
674
684void calculate_evaluated_offsets(Span<int8_t> handle_types_left,
685 Span<int8_t> handle_types_right,
686 bool cyclic,
687 int resolution,
688 MutableSpan<int> evaluated_offsets);
689
698
717Insertion insert(const float3 &point_prev,
718 const float3 &handle_prev,
719 const float3 &handle_next,
720 const float3 &point_next,
721 float parameter);
722
729float3 calculate_vector_handle(const float3 &point, const float3 &next_point);
730
737void calculate_auto_handles(bool cyclic,
738 Span<int8_t> types_left,
739 Span<int8_t> types_right,
740 Span<float3> positions,
741 MutableSpan<float3> positions_left,
742 MutableSpan<float3> positions_right);
743
744void calculate_single_aligned_handles(const IndexMask &selection,
745 Span<float3> positions,
746 Span<float3> align_with,
747 MutableSpan<float3> align_handles);
748
749void calculate_aligned_handles(const IndexMask &selection,
750 Span<float3> positions,
751 Span<float3> handles_left,
752 Span<float3> handles_right,
753 MutableSpan<float3> align_handles_left,
754 MutableSpan<float3> align_handles_right);
763 HandleType type,
764 HandleType type_other,
765 const float3 &new_handle,
766 float3 &handle,
767 float3 &handle_other);
768
775template<typename T>
777 const T &point_0, const T &point_1, const T &point_2, const T &point_3, MutableSpan<T> result);
778
789 Span<float3> handles_left,
790 Span<float3> handles_right,
791 OffsetIndices<int> evaluated_offsets,
792 MutableSpan<float3> evaluated_positions);
793
799void interpolate_to_evaluated(GSpan src, OffsetIndices<int> evaluated_offsets, GMutableSpan dst);
800
801} // namespace bezier
802
804
805/* -------------------------------------------------------------------- */
808
809namespace catmull_rom {
810
816int calculate_evaluated_num(int points_num, bool cyclic, int resolution);
817
822void interpolate_to_evaluated(GSpan src, bool cyclic, int resolution, GMutableSpan dst);
823
828void interpolate_to_evaluated(const GSpan src,
829 const bool cyclic,
830 const OffsetIndices<int> evaluated_offsets,
831 GMutableSpan dst);
832
833float4 calculate_basis(const float parameter);
834
841template<typename T>
842T interpolate(const T &a, const T &b, const T &c, const T &d, const float parameter)
843{
844 BLI_assert(0.0f <= parameter && parameter <= 1.0f);
845 const float4 weights = calculate_basis(parameter);
847 /* Save multiplications by adjusting weights after mix. */
848 return 0.5f * attribute_math::mix4<T>(weights, a, b, c, d);
849 }
850 else {
851 return attribute_math::mix4<T>(weights * 0.5f, a, b, c, d);
852 }
853}
854
855} // namespace catmull_rom
856
858
859/* -------------------------------------------------------------------- */
862
863namespace nurbs {
864
869 int points_num, int8_t order, bool cyclic, KnotsMode knots_mode, int resolution);
870
879int calculate_evaluated_num(int points_num,
880 int8_t order,
881 bool cyclic,
882 int resolution,
883 KnotsMode knots_mode,
884 Span<float> knots);
885
891int knots_num(int points_num, int8_t order, bool cyclic);
892
897int control_points_num(int points_num, int8_t order, bool cyclic);
898
904 int points_num,
905 int8_t order,
906 bool cyclic,
907 IndexRange curve_knots,
908 Span<float> custom_knots,
909 MutableSpan<float> knots);
910
919void calculate_knots(
920 int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan<float> knots);
921
931
938void calculate_basis_cache(int points_num,
939 int evaluated_num,
940 int8_t order,
941 int resolution,
942 bool cyclic,
943 KnotsMode knots_mode,
944 Span<float> knots,
945 BasisCache &basis_cache);
946
955void interpolate_to_evaluated(const BasisCache &basis_cache,
956 int8_t order,
957 Span<float> control_weights,
958 GSpan src,
959 GMutableSpan dst);
960
961} // namespace nurbs
962
964
965} // namespace curves
966
967Curves *curves_new_nomain(int points_num, int curves_num);
968Curves *curves_new_nomain(CurvesGeometry curves);
969
973Curves *curves_new_nomain_single(int points_num, CurveType type);
974
979void curves_copy_parameters(const Curves &src, Curves &dst);
980
981void curves_store_surface_in_geometry_bundle(const Depsgraph &depsgraph,
982 const Curves &curves,
983 GeometrySet &geometry);
984
985CurvesGeometry curves_copy_point_selection(const CurvesGeometry &curves,
986 const IndexMask &points_to_copy,
987 const AttributeFilter &attribute_filter);
988
989CurvesGeometry curves_copy_curve_selection(const CurvesGeometry &curves,
990 const IndexMask &curves_to_copy,
991 const AttributeFilter &attribute_filter);
992
993CurvesGeometry curves_new_no_attributes(int point_num, int curve_num);
994
995std::array<int, CURVE_TYPES_NUM> calculate_type_counts(const VArray<int8_t> &types);
996
997/* -------------------------------------------------------------------- */
1000
1002{
1003 return this->point_num;
1004}
1006{
1007 return this->curve_num;
1008}
1010{
1011 return this->custom_knot_num != 0;
1012}
1013inline bool CurvesGeometry::is_empty() const
1014{
1015 /* Each curve must have at least one point. */
1016 BLI_assert((this->curve_num == 0) == (this->point_num == 0));
1017 return this->curve_num == 0;
1018}
1020{
1021 return IndexRange(this->points_num());
1022}
1024{
1025 return IndexRange(this->curves_num());
1026}
1027
1028inline bool CurvesGeometry::is_single_type(const CurveType type) const
1029{
1030 return this->curve_type_counts()[type] == this->curves_num();
1031}
1032
1034{
1035 return this->curve_type_counts()[type] > 0;
1036}
1037
1039{
1040 return std::any_of(
1041 types.begin(), types.end(), [&](CurveType type) { return this->has_curve_with_type(type); });
1042}
1043
1044inline const std::array<int, CURVE_TYPES_NUM> &CurvesGeometry::curve_type_counts() const
1045{
1046#ifndef NDEBUG
1047
1048 if (this->runtime->check_type_counts) {
1049 const std::array<int, CURVE_TYPES_NUM> actual_type_counts = calculate_type_counts(
1050 this->curve_types());
1051 BLI_assert(this->runtime->type_counts == actual_type_counts);
1052 this->runtime->check_type_counts = false;
1053 }
1054#endif
1055 return this->runtime->type_counts;
1056}
1057
1063
1065{
1066 /* This could avoid calculating offsets in the future in simple circumstances. */
1067 return this->evaluated_points_by_curve().total_size();
1068}
1069
1071{
1072 const OffsetIndices points_by_curve = this->points_by_curve();
1073 const IndexRange points = points_by_curve[curve_index];
1074 const IndexRange range = curves::per_curve_point_offsets_range(points, curve_index);
1075 const Span<int> offsets = this->runtime->evaluated_offsets_cache.data().all_bezier_offsets;
1076 return offsets.slice(range);
1077}
1078
1079inline IndexRange CurvesGeometry::lengths_range_for_curve(const int curve_index,
1080 const bool cyclic) const
1081{
1082 BLI_assert(cyclic == this->cyclic()[curve_index]);
1083 const IndexRange points = this->evaluated_points_by_curve()[curve_index];
1084 const int start = points.start() + curve_index;
1085 return {start, curves::segments_num(points.size(), cyclic)};
1086}
1087
1089 const bool cyclic) const
1090{
1091 const IndexRange range = this->lengths_range_for_curve(curve_index, cyclic);
1092 return this->runtime->evaluated_length_cache.data().as_span().slice(range);
1093}
1094
1095inline float CurvesGeometry::evaluated_length_total_for_curve(const int curve_index,
1096 const bool cyclic) const
1097{
1098 const Span<float> lengths = this->evaluated_lengths_for_curve(curve_index, cyclic);
1099 if (lengths.is_empty()) {
1100 return 0.0f;
1101 }
1102 return lengths.last();
1103}
1104
1106
1107namespace curves {
1108
1109/* -------------------------------------------------------------------- */
1112
1113namespace bezier {
1114
1115inline bool point_is_sharp(const Span<int8_t> handle_types_left,
1116 const Span<int8_t> handle_types_right,
1117 const int index)
1118{
1119 return ELEM(handle_types_left[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE) ||
1120 ELEM(handle_types_right[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE);
1121}
1122
1123inline bool segment_is_vector(const HandleType left, const HandleType right)
1124{
1125 return left == BEZIER_HANDLE_VECTOR && right == BEZIER_HANDLE_VECTOR;
1126}
1127
1128inline bool segment_is_vector(const int8_t left, const int8_t right)
1129{
1130 return segment_is_vector(HandleType(left), HandleType(right));
1131}
1132
1133inline bool has_vector_handles(const int num_curve_points,
1134 const int64_t evaluated_size,
1135 const bool cyclic,
1136 const int resolution)
1137{
1138 return evaluated_size - !cyclic != int64_t(segments_num(num_curve_points, cyclic)) * resolution;
1139}
1140
1141inline float3 calculate_vector_handle(const float3 &point, const float3 &next_point)
1142{
1143 return math::interpolate(point, next_point, 1.0f / 3.0f);
1144}
1145
1146} // namespace bezier
1147
1149
1150/* -------------------------------------------------------------------- */
1153
1154namespace nurbs {
1155
1156inline int knots_num(const int points_num, const int8_t order, const bool cyclic)
1157{
1158 /* Cyclic: points_num + order * 2 - 1 */
1159 return points_num + order + cyclic * (order - 1);
1160}
1161
1162inline int control_points_num(const int points_num, const int8_t order, const bool cyclic)
1163{
1164 return points_num + cyclic * (order - 1);
1165}
1166
1167} // namespace nurbs
1168
1170
1172
1173} // namespace curves
1174
1187
1188} // namespace bke
1189
1190inline bke::CurvesGeometry &CurvesGeometry::wrap()
1191{
1192 return *reinterpret_cast<bke::CurvesGeometry *>(this);
1193}
1194inline const bke::CurvesGeometry &CurvesGeometry::wrap() const
1195{
1196 return *reinterpret_cast<const bke::CurvesGeometry *>(this);
1197}
1198
1199} // namespace blender
Low-level operations for curves that cannot be defined in the C++ header yet.
#define ELEM(...)
GVArray()=default
constexpr int64_t size() const
constexpr IndexRange()=default
constexpr int64_t start() const
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 const T * end() const
Definition BLI_span.hh:228
constexpr const T * begin() const
Definition BLI_span.hh:224
constexpr bool is_empty() const
Definition BLI_span.hh:264
std::optional< MutableSpan< float3 > > positions_for_write()
ImplicitSharingPtrAndData positions_data
std::optional< Span< float3 > > positions() const
CurvesEditHints(const Curves &curves_id_orig)
std::optional< Array< float3x3 > > deform_mats
SharedCache< Vector< curves::nurbs::BasisCache > > nurbs_basis_cache
SharedCache< Vector< float > > evaluated_length_cache
SharedCache< Bounds< float3 > > bounds_with_radius_cache
SharedCache< Vector< int > > custom_knot_offsets_cache
SharedCache< Vector< float3 > > evaluated_tangent_cache
SharedCache< EvaluatedOffsets > evaluated_offsets_cache
Definition BKE_curves.hh:97
SharedCache< Vector< float3 > > evaluated_normal_cache
std::unique_ptr< bake::BakeMaterialsList > bake_materials
const ImplicitSharingInfo * custom_knots_sharing_info
Definition BKE_curves.hh:81
SharedCache< std::optional< int > > max_material_index_cache
SharedCache< Bounds< float3 > > bounds_cache
SharedCache< Vector< float3 > > evaluated_position_cache
const ImplicitSharingInfo * curve_offsets_sharing_info
Definition BKE_curves.hh:78
SharedCache< bool > has_cyclic_curve_cache
Definition BKE_curves.hh:99
std::array< int, CURVE_TYPES_NUM > type_counts
Definition BKE_curves.hh:87
Span< float3 > evaluated_tangents() const
MutableSpan< MDeformVert > deform_verts_for_write()
MutableSpan< int8_t > handle_types_left_for_write()
VArray< int8_t > curve_types() const
void ensure_can_interpolate_to_evaluated() const
VArray< int8_t > nurbs_orders() const
std::optional< Span< float > > nurbs_weights() const
MutableSpan< int8_t > nurbs_orders_for_write()
void blend_write(BlendWriter &writer, ID &id, const BlendWriteData &write_data)
Span< float > nurbs_custom_knots() const
std::optional< int > material_index_max() const
MutableSpan< float3 > positions_for_write()
MutableSpan< int8_t > handle_types_right_for_write()
std::optional< Bounds< float3 > > bounds_min_max(bool use_radius=true) const
void blend_read(BlendDataReader &reader)
void remove_points(const IndexMask &points_to_delete, const AttributeFilter &attribute_filter)
void transform(const float4x4 &matrix)
std::optional< Span< float3 > > handle_positions_right() const
MutableSpan< int8_t > normal_mode_for_write()
void resize(int points_num, int curves_num)
MutableSpan< float > tilt_for_write()
VArray< bool > cyclic() const
OffsetIndices< int > nurbs_custom_knots_by_curve() const
AttributeAccessor attributes() const
MutableSpan< float > nurbs_custom_knots_for_write()
Span< float3 > positions() const
bool is_single_type(CurveType type) const
void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const
MutableSpan< float3 > handle_positions_right_for_write()
MutableSpan< float2 > surface_uv_coords_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
std::optional< Span< float2 > > surface_uv_coords() const
Span< MDeformVert > deform_verts() const
MutableSpan< int > resolution_for_write()
void blend_write_prepare(BlendWriteData &write_data, bool use_5_0_compatibility)
VArray< int8_t > normal_mode() const
IndexMask nurbs_custom_knot_curves(IndexMaskMemory &memory) const
VArray< int8_t > nurbs_knots_modes() const
MutableSpan< int8_t > curve_types_for_write()
IndexMask indices_for_curve_type(CurveType type, IndexMaskMemory &memory) const
CurvesGeometry & operator=(const CurvesGeometry &other)
MutableSpan< int8_t > nurbs_knots_modes_for_write()
VArray< int8_t > handle_types_left() const
Span< float > evaluated_lengths_for_curve(int curve_index, bool cyclic) 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()
IndexRange points_range() const
void fill_curve_types(CurveType type)
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts() const
Span< float3 > evaluated_positions() const
VArray< int > resolution() const
MutableSpan< float > radius_for_write()
float evaluated_length_total_for_curve(int curve_index, bool cyclic) const
VArray< T > adapt_domain(const VArray< T > &varray, AttrDomain from, AttrDomain to) const
MutableSpan< float > nurbs_weights_for_write()
VArray< int8_t > handle_types_right() const
VArray< float > tilt() const
VArray< float > radius() const
GVArray adapt_domain(const GVArray &varray, AttrDomain from, AttrDomain to) const
MutableSpan< bool > cyclic_for_write()
void count_memory(MemoryCounter &memory) const
void nurbs_custom_knots_resize(int knots_num)
void remove_curves(const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter)
OffsetIndices< int > points_by_curve() const
Span< float3 > evaluated_normals() const
Array< int > point_to_curve_map() const
MutableAttributeAccessor attributes_for_write()
void reverse_curves(const IndexMask &curves_to_reverse)
void translate(const float3 &translation)
#define position
#define T
T mix4(const float4 &weights, const T &v0, const T &v1, const T &v2, const T &v3)
Insertion insert(const float3 &point_prev, const float3 &handle_prev, const float3 &handle_next, const float3 &point_next, float parameter)
void calculate_aligned_handles(const IndexMask &selection, Span< float3 > positions, Span< float3 > handles_left, Span< float3 > handles_right, MutableSpan< float3 > align_handles_left, MutableSpan< float3 > align_handles_right)
bool segment_is_vector(const HandleType left, const HandleType right)
bool point_is_sharp(Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, int index)
void calculate_auto_handles(bool cyclic, Span< int8_t > types_left, Span< int8_t > types_right, Span< float3 > positions, MutableSpan< float3 > positions_left, MutableSpan< float3 > positions_right)
void calculate_evaluated_offsets(Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, bool cyclic, int resolution, MutableSpan< int > evaluated_offsets)
float3 calculate_vector_handle(const float3 &point, const float3 &next_point)
bool has_vector_handles(int num_curve_points, int64_t evaluated_size, bool cyclic, int resolution)
bool last_cyclic_segment_is_vector(Span< int8_t > handle_types_left, Span< int8_t > handle_types_right)
void evaluate_segment(const T &point_0, const T &point_1, const T &point_2, const T &point_3, MutableSpan< T > result)
void calculate_single_aligned_handles(const IndexMask &selection, Span< float3 > positions, Span< float3 > align_with, MutableSpan< float3 > align_handles)
void calculate_evaluated_positions(Span< float3 > positions, Span< float3 > handles_left, Span< float3 > handles_right, OffsetIndices< int > evaluated_offsets, MutableSpan< float3 > evaluated_positions)
void interpolate_to_evaluated(GSpan src, OffsetIndices< int > evaluated_offsets, GMutableSpan dst)
void set_handle_position(const float3 &position, HandleType type, HandleType type_other, const float3 &new_handle, float3 &handle, float3 &handle_other)
T interpolate(const T &a, const T &b, const T &c, const T &d, const float parameter)
int calculate_evaluated_num(int points_num, bool cyclic, int resolution)
float4 calculate_basis(const float parameter)
void interpolate_to_evaluated(GSpan src, bool cyclic, int resolution, GMutableSpan dst)
Vector< int > calculate_multiplicity_sequence(Span< float > knots)
int calculate_evaluated_num(int points_num, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode, Span< float > knots)
void calculate_knots(int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan< float > knots)
void calculate_basis_cache(int points_num, int evaluated_num, int8_t order, int resolution, bool cyclic, KnotsMode knots_mode, Span< float > knots, BasisCache &basis_cache)
bool check_valid_eval_params(int points_num, int8_t order, bool cyclic, KnotsMode knots_mode, int resolution)
int knots_num(int points_num, int8_t order, bool cyclic)
void load_curve_knots(KnotsMode mode, int points_num, int8_t order, bool cyclic, IndexRange curve_knots, Span< float > custom_knots, MutableSpan< float > knots)
int control_points_num(int points_num, int8_t order, bool cyclic)
void interpolate_to_evaluated(const BasisCache &basis_cache, int8_t order, Span< float > control_weights, GSpan src, GMutableSpan dst)
void calculate_normals_z_up(Span< float3 > tangents, MutableSpan< float3 > normals)
void calculate_normals_minimum(Span< float3 > tangents, bool cyclic, MutableSpan< float3 > normals)
void calculate_tangents(Span< float3 > positions, bool is_cyclic, MutableSpan< float3 > tangents)
Definition curve_poly.cc:74
IndexRange per_curve_point_offsets_range(const IndexRange points, const int curve_index)
float3 decode_surface_bary_coord(const float2 &v)
int segments_num(const int points_num, const bool cyclic)
float2 encode_surface_bary_coord(const float3 &v)
const AttributeAccessorFunctions & get_attribute_accessor_functions()
CurvesGeometry curves_copy_curve_selection(const CurvesGeometry &curves, const IndexMask &curves_to_copy, const AttributeFilter &attribute_filter)
CurvesGeometry curves_copy_point_selection(const CurvesGeometry &curves, const IndexMask &points_to_copy, const AttributeFilter &attribute_filter)
void curves_copy_parameters(const Curves &src, Curves &dst)
CurvesGeometry curves_new_no_attributes(int point_num, int curve_num)
void curves_store_surface_in_geometry_bundle(const Depsgraph &depsgraph, const Curves &curves, GeometrySet &geometry)
std::array< int, CURVE_TYPES_NUM > calculate_type_counts(const VArray< int8_t > &types)
Curves * curves_new_nomain_single(int points_num, CurveType type)
Curves * curves_new_nomain(int points_num, int curves_num)
void curves_normals_point_domain_calc(const CurvesGeometry &curves, MutableSpan< float3 > normals)
T interpolate(const T &a, const T &b, const FactorT &t)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
constexpr bool is_same_any_v
ATTR_WARN_UNUSED_RESULT const BMVert * v
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< float, 3 > float3
signed char int8_t
Definition BKE_text.h:76
static unordered_map< ustring, NodeType > & types()
bke::CurvesGeometryRuntime * runtime
Vector< CustomDataLayer, 16 > & curve_layers
BlendWriteData(BlendWriter *writer, ResourceScope &scope)
Vector< CustomDataLayer, 16 > & point_layers
AttributeStorage::BlendWriteData attribute_data