67CurvesGeometry::CurvesGeometry(
const int point_num,
const int curve_num)
69 this->
runtime = MEM_new<CurvesGeometryRuntime>(__func__);
106 if (other.
runtime->curve_offsets_sharing_info) {
107 other.
runtime->curve_offsets_sharing_info->add_user();
112 if (other.
runtime->custom_knots_sharing_info) {
113 other.
runtime->custom_knots_sharing_info->add_user();
129 this->
runtime = MEM_new<CurvesGeometryRuntime>(
132 other.
runtime->custom_knots_sharing_info,
134 other.
runtime->evaluated_offsets_cache,
135 other.
runtime->nurbs_basis_cache,
136 other.
runtime->evaluated_position_cache,
138 other.
runtime->bounds_with_radius_cache,
139 other.
runtime->evaluated_length_cache,
140 other.
runtime->evaluated_tangent_cache,
141 other.
runtime->evaluated_normal_cache,
142 other.
runtime->max_material_index_cache,
143 other.
runtime->custom_knot_offsets_cache,
147 if (other.
runtime->bake_materials) {
148 this->
runtime->bake_materials = std::make_unique<bake::BakeMaterialsList>(
149 *other.
runtime->bake_materials);
155 if (
this == &other) {
158 std::destroy_at(
this);
166 other.curve_offsets =
nullptr;
169 other.custom_knots =
nullptr;
172 other.custom_knot_num = 0;
193 other.vertex_group_active_index = 0;
196 other.attributes_active_index = 0;
199 other.runtime =
nullptr;
204 if (
this == &other) {
207 std::destroy_at(
this);
212CurvesGeometry::~CurvesGeometry()
220 &this->
runtime->curve_offsets_sharing_info);
222 &this->
runtime->custom_knots_sharing_info);
252 const T default_value)
259 if (
data !=
nullptr) {
275 if (
data ==
nullptr) {
285 const T default_value =
T())
295 if (
data !=
nullptr) {
300 if (
num > 0 && span.
first() != default_value) {
301 span.
fill(default_value);
317void CurvesGeometry::fill_curve_types(
const CurveType type)
327 this->
runtime->type_counts.fill(0);
334 if (selection.
size() ==
this->curves_num()) {
338 if (std::optional<int8_t> single_type = this->
curve_types().get_if_single()) {
339 if (single_type == type) {
358 if (
const std::optional<int8_t> single =
types.get_if_single()) {
370 for (
const int64_t curve_index : curves_range) {
377 [](
const bool &a,
const bool &
b) {
return a &&
b; });
392 using CountsType = std::array<int, CURVE_TYPES_NUM>;
396 if (
types.is_single()) {
397 counts[
types.get_internal_single()] =
types.size();
407 CountsType result = init;
408 for (const int curve_index : curves_range) {
409 result[types_span[curve_index]]++;
413 [](
const CountsType &a,
const CountsType &
b) {
422void CurvesGeometry::update_curve_types()
447 if (this->curve_num == 0) {
450 return {this->curve_offsets, this->curve_num + 1};
454 if (this->curve_num == 0) {
458 &this->curve_offsets, &this->runtime->curve_offsets_sharing_info,
this->curve_num + 1);
459 return {this->curve_offsets, this->curve_num + 1};
573 if (this->custom_knot_num == 0) {
576 return {this->custom_knots, this->custom_knot_num};
581 if (this->custom_knot_num == 0) {
585 &this->custom_knots, &this->runtime->custom_knots_sharing_info,
this->custom_knot_num);
586 return {this->custom_knots, this->custom_knot_num};
603 if (this->is_empty()) {
607 r_data.
resize(this->curve_num + 1, 0);
609 const OffsetIndices points_by_curve = this->points_by_curve();
614 for (
const int curve : this->curves_range()) {
618 r_data[
curve + 1] = knot_count;
624void CurvesGeometry::nurbs_custom_knots_update_size()
626 this->runtime->custom_knot_offsets_cache.tag_dirty();
628 const int knots_num = knots_by_curve.
total_size();
629 if (this->custom_knot_num != knots_num) {
631 &this->runtime->custom_knots_sharing_info,
632 this->custom_knot_num,
634 this->custom_knot_num = knots_num;
638void CurvesGeometry::nurbs_custom_knots_resize(
int knots_num)
641 &this->runtime->custom_knots_sharing_info,
642 this->custom_knot_num,
644 this->custom_knot_num = knots_num;
645 this->runtime->custom_knot_offsets_cache.tag_dirty();
652 if (dverts ==
nullptr) {
655 return {dverts, this->point_num};
662 if (dvert !=
nullptr) {
663 return {dvert, this->point_num};
681 offset += count_fn(i);
683 offsets.
last() = offset;
706 const IndexRange points = points_by_curve[curve_index];
707 switch (
types[curve_index]) {
709 return curves::catmull_rom::calculate_evaluated_num(
710 points.
size(), cyclic[curve_index], resolution[curve_index]);
712 return points.
size();
714 const IndexRange offsets = curves::per_curve_point_offsets_range(points, curve_index);
715 curves::bezier::calculate_evaluated_offsets(handle_types_left.
slice(points),
716 handle_types_right.
slice(points),
718 resolution[curve_index],
719 all_bezier_offsets.
slice(offsets));
720 return all_bezier_offsets[offsets.
last()];
723 return curves::nurbs::calculate_evaluated_num(points.
size(),
724 nurbs_orders[curve_index],
726 resolution[curve_index],
727 KnotsMode(nurbs_knots_modes[curve_index]));
744 return this->points_by_curve();
766 return this->indices_for_curve_type(type, this->curves_range(), memory);
773 return curves::indices_for_type(
774 this->curve_types(), this->curve_type_counts(), type, selection, memory);
784void CurvesGeometry::ensure_nurbs_basis_cache()
const
795 r_data.
resize(this->curves_num());
798 const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();
803 const Span<float> custom_knots = this->nurbs_custom_knots();
807 for (
const int curve_index : segment) {
808 const IndexRange points = points_by_curve[curve_index];
809 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
811 const int8_t order = orders[curve_index];
812 const bool is_cyclic = cyclic[curve_index];
815 if (!curves::nurbs::check_valid_num_and_order(points.
size(), order,
is_cyclic, mode)) {
816 r_data[curve_index].invalid =
true;
819 const int knots_num = curves::nurbs::knots_num(points.
size(), order,
is_cyclic);
821 curves::nurbs::load_curve_knots(mode,
825 custom_knots_by_curve[curve_index],
829 curves::nurbs::calculate_basis_cache(
830 points.
size(), evaluated_points.
size(), order,
is_cyclic, knots, r_data[curve_index]);
842 return this->positions();
844 this->ensure_nurbs_basis_cache();
846 r_data.
resize(this->evaluated_points_num());
850 const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();
853 auto evaluate_catmull = [&](
const IndexMask &selection) {
856 selection.foreach_index(
GrainSize(128), [&](
const int curve_index) {
857 const IndexRange points = points_by_curve[curve_index];
858 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
859 curves::catmull_rom::interpolate_to_evaluated(positions.
slice(points),
861 resolution[curve_index],
862 evaluated_positions.
slice(evaluated_points));
865 auto evaluate_poly = [&](
const IndexMask &selection) {
867 points_by_curve, evaluated_points_by_curve, selection, positions, evaluated_positions);
869 auto evaluate_bezier = [&](
const IndexMask &selection) {
870 const Span<float3> handle_positions_left = this->handle_positions_left();
871 const Span<float3> handle_positions_right = this->handle_positions_right();
872 if (handle_positions_left.
is_empty() || handle_positions_right.
is_empty()) {
873 curves::fill_points(evaluated_points_by_curve, selection,
float3(0), evaluated_positions);
878 selection.foreach_index(
GrainSize(128), [&](
const int curve_index) {
879 const IndexRange points = points_by_curve[curve_index];
880 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
881 const IndexRange offsets = curves::per_curve_point_offsets_range(points, curve_index);
882 curves::bezier::calculate_evaluated_positions(positions.
slice(points),
883 handle_positions_left.
slice(points),
884 handle_positions_right.
slice(points),
885 all_bezier_offsets.
slice(offsets),
886 evaluated_positions.
slice(evaluated_points));
889 auto evaluate_nurbs = [&](
const IndexMask &selection) {
890 this->ensure_nurbs_basis_cache();
892 const Span<float> nurbs_weights = this->nurbs_weights();
894 selection.foreach_index(
GrainSize(128), [&](
const int curve_index) {
895 const IndexRange points = points_by_curve[curve_index];
896 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
897 curves::nurbs::interpolate_to_evaluated(nurbs_basis_cache[curve_index],
898 nurbs_orders[curve_index],
900 positions.
slice(points),
901 evaluated_positions.
slice(evaluated_points));
904 curves::foreach_curve_by_type(this->curve_types(),
905 this->curve_type_counts(),
906 this->curves_range(),
919 const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();
920 const Span<float3> evaluated_positions = this->evaluated_positions();
923 r_data.
resize(this->evaluated_points_num());
927 for (
const int curve_index : curves_range) {
928 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
929 curves::poly::calculate_tangents(evaluated_positions.
slice(evaluated_points),
931 tangents.
slice(evaluated_points));
943 const Span<float3> handles_left = this->handle_positions_left();
944 const Span<float3> handles_right = this->handle_positions_right();
947 if (cyclic[curve_index]) {
950 const IndexRange points = points_by_curve[curve_index];
951 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
953 const float epsilon = 1e-6f;
955 handles_right[points.
first()], positions[points.
first()], epsilon))
957 tangents[evaluated_points.first()] = math::normalize(handles_right[points.first()] -
958 positions[points.first()]);
961 handles_left[points.
last()], positions[points.
last()], epsilon))
963 tangents[evaluated_points.last()] = math::normalize(positions[points.last()] -
964 handles_left[points.last()]);
977 const float3 axis = axes[i];
987 for (
const int i :
data.index_range()) {
1005 const int curve_index,
1010 switch (eval_data.
types[curve_index]) {
1012 curves::catmull_rom::interpolate_to_evaluated(
1013 src, eval_data.
cyclic[curve_index], eval_data.
resolution[curve_index], dst);
1019 const IndexRange offsets = curves::per_curve_point_offsets_range(points, curve_index);
1020 curves::bezier::interpolate_to_evaluated(
1025 curves::nurbs::interpolate_to_evaluated(eval_data.
nurbs_basis_cache[curve_index],
1037 this->ensure_nurbs_basis_cache();
1040 const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();
1044 const Span<float3> evaluated_tangents = this->evaluated_tangents();
1053 this->nurbs_orders(),
1054 this->nurbs_weights(),
1066 custom_normal_span = custom_normal;
1069 r_data.
resize(this->evaluated_points_num());
1076 for (
const int curve_index : curves_range) {
1077 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
1078 switch (
NormalMode(normal_mode[curve_index])) {
1080 curves::poly::calculate_normals_z_up(evaluated_tangents.
slice(evaluated_points),
1081 evaluated_normals.
slice(evaluated_points));
1084 curves::poly::calculate_normals_minimum(evaluated_tangents.
slice(evaluated_points),
1085 cyclic[curve_index],
1086 evaluated_normals.
slice(evaluated_points));
1089 if (custom_normal_span.
is_empty()) {
1090 curves::poly::calculate_normals_z_up(evaluated_tangents.
slice(evaluated_points),
1091 evaluated_normals.
slice(evaluated_points));
1094 const Span<float3> src = custom_normal_span.
slice(points_by_curve[curve_index]);
1096 evaluated_points_by_curve[curve_index]);
1106 const IndexRange points = points_by_curve[curve_index];
1109 evaluated_tangents.
slice(evaluated_points),
1110 tilt_span.
slice(points));
1116 tilt_span.
slice(points),
1119 evaluated_tangents.
slice(evaluated_points),
1129void CurvesGeometry::interpolate_to_evaluated(
const int curve_index,
1135 this->points_by_curve(),
1136 this->curve_types(),
1141 this->nurbs_orders(),
1142 this->nurbs_weights(),
1152 const OffsetIndices points_by_curve = this->points_by_curve();
1155 this->curve_types(),
1160 this->nurbs_orders(),
1161 this->nurbs_weights(),
1163 const OffsetIndices evaluated_points_by_curve = this->evaluated_points_by_curve();
1166 for (
const int curve_index : curves_range) {
1167 const IndexRange points = points_by_curve[curve_index];
1168 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
1170 eval_data, curve_index, src.
slice(points), dst.
slice(evaluated_points));
1175void CurvesGeometry::ensure_evaluated_lengths()
const
1181 const int total_num = this->evaluated_points_num() + this->curves_num();
1182 r_data.
resize(total_num);
1185 const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();
1186 const Span<float3> evaluated_positions = this->evaluated_positions();
1190 for (
const int curve_index : curves_range) {
1191 const bool cyclic = curves_cyclic[curve_index];
1192 const IndexRange evaluated_points = evaluated_points_by_curve[curve_index];
1193 const IndexRange lengths_range = this->lengths_range_for_curve(curve_index, cyclic);
1196 evaluated_lengths.
slice(lengths_range));
1202void CurvesGeometry::ensure_can_interpolate_to_evaluated()
const
1204 this->evaluated_points_by_curve();
1205 this->ensure_nurbs_basis_cache();
1214void CurvesGeometry::resize(
const int points_num,
const int curves_num)
1216 BLI_assert(curves_num >= 0 && points_num >= 0);
1217 if (points_num != this->point_num) {
1219 this->point_num = points_num;
1221 if (curves_num != this->curve_num) {
1225 this->curve_num == 0 ? 0 : (this->curve_num + 1),
1226 curves_num == 0 ? 0 : (curves_num + 1));
1227 if (curves_num > 0) {
1229 this->curve_offsets[0] = 0;
1230 this->curve_offsets[curves_num] = this->point_num;
1232 this->curve_num = curves_num;
1234 this->tag_topology_changed();
1237void CurvesGeometry::tag_positions_changed()
1246void CurvesGeometry::tag_topology_changed()
1249 this->tag_positions_changed();
1255void CurvesGeometry::tag_normals_changed()
1259void CurvesGeometry::tag_radii_changed()
1263void CurvesGeometry::tag_material_index_changed()
1271 for (float3 &position : positions.slice(range)) {
1272 position += translation;
1280 for (float3 &position : positions.slice(range)) {
1281 position = math::transform_point(matrix, position);
1286void CurvesGeometry::calculate_bezier_auto_handles()
1291 if (this->handle_positions_left().is_empty() || this->handle_positions_right().is_empty()) {
1294 const OffsetIndices points_by_curve = this->points_by_curve();
1304 for (
const int i_curve :
range) {
1306 const IndexRange points = points_by_curve[i_curve];
1307 curves::bezier::calculate_auto_handles(cyclic[i_curve],
1308 types_left.slice(points),
1309 types_right.slice(points),
1310 positions.
slice(points),
1311 positions_left.
slice(points),
1312 positions_right.
slice(points));
1318void CurvesGeometry::translate(
const float3 &translation)
1324 std::optional<Bounds<float3>> bounds;
1330 if (!this->handle_positions_left().is_empty()) {
1333 if (!this->handle_positions_right().is_empty()) {
1336 this->tag_positions_changed();
1339 bounds->min += translation;
1340 bounds->max += translation;
1348 if (!this->handle_positions_left().is_empty()) {
1351 if (!this->handle_positions_right().is_empty()) {
1356 this->tag_positions_changed();
1359std::optional<Bounds<float3>> CurvesGeometry::bounds_min_max(
const bool use_radius)
const
1361 if (this->is_empty()) {
1362 return std::nullopt;
1367 if (
const std::optional radius_single = radius.
get_if_single()) {
1368 r_bounds = *this->bounds_min_max(
false);
1369 r_bounds.
pad(*radius_single);
1378 this->ensure_can_interpolate_to_evaluated();
1379 this->interpolate_to_evaluated(radius_span, radii_eval.
as_mutable_span());
1392std::optional<int> CurvesGeometry::material_index_max()
const
1399 if (r_max_material_index.has_value()) {
1400 r_max_material_index = std::clamp(*r_max_material_index, 0,
MAXMAT);
1410 this->nurbs_custom_knots().size_in_bytes());
1427 points_by_curve, custom_knot_curves, memory);
1429 points_to_copy, custom_knot_points, memory);
1431 int dst_knot_count = 0;
1433 dst_knot_count += curves::nurbs::knots_num(
1440 new_knots.
reserve(dst_knot_count);
1442 curves::foreach_selected_point_ranges_per_curve(
1443 custom_knot_points_to_copy,
1447 const int order = orders[
curve];
1448 const int leading_spans = order / 2;
1449 const int point_to_knot = -points.
start() + src_range.
start();
1450 const int point_to_span = point_to_knot + leading_spans;
1452 const int first_knot = ranges_to_copy.
first().start() + point_to_knot;
1455 float last_knot = new_knots.
last();
1457 for (
const int spans_left_knot :
range.
shift(point_to_span)) {
1458 last_knot += src_knots[spans_left_knot + 1] - src_knots[spans_left_knot];
1459 new_knots.
append(last_knot);
1462 const int last_spans_left_knot = ranges_to_copy.
last().last() + point_to_span + 1;
1463 last_knot += src_knots[last_spans_left_knot + 1] - src_knots[last_spans_left_knot];
1464 new_knots.
append(last_knot);
1477 [&](
const int64_t point_i) { curve_point_counts[point_to_curve_map[point_i]]++; });
1482 return curve_point_counts[i] > 0;
1490 dst_curves.curves_num() > 1024,
1492 if (curves_to_copy.is_empty()) {
1497 curve_point_counts.
as_span(), curves_to_copy, new_curve_offsets.drop_back(1));
1501 gather_attributes(curves.attributes(),
1506 dst_curves.attributes_for_write());
1507 gather_attributes(curves.attributes(),
1512 dst_curves.attributes_for_write());
1515 if (curves.nurbs_has_custom_knots()) {
1516 copy_point_selection_custom_knots(curves, points_to_copy, curve_point_counts, dst_curves);
1519 if (dst_curves.curves_num() == curves.curves_num()) {
1520 dst_curves.runtime->type_counts = curves.runtime->type_counts;
1523 dst_curves.remove_attributes_based_on_types();
1529void CurvesGeometry::remove_points(
const IndexMask &points_to_delete,
1535 if (points_to_delete.
size() ==
this->points_num()) {
1537 this->update_curve_types();
1541 const IndexMask points_to_copy = points_to_delete.
complement(this->points_range(), memory);
1552 curves_to_copy, custom_knot_curves, memory);
1554 Array<int> dst_knot_offsets_data(custom_knot_curves_to_copy.
size() + 1, 0);
1558 src_knots_by_curve, custom_knot_curves_to_copy, dst_knot_offsets_data);
1563 custom_knot_curves_to_copy,
1588 dst_points_by_curve,
1609void CurvesGeometry::remove_curves(
const IndexMask &curves_to_delete,
1615 if (curves_to_delete.
size() ==
this->curves_num()) {
1617 this->update_curve_types();
1621 const IndexMask curves_to_copy = curves_to_delete.
complement(this->curves_range(), memory);
1627 const float last = custom_knots.
last();
1629 for (
float &knot_value : custom_knots) {
1630 knot_value = last - knot_value;
1641 GrainSize(256), [&](
const int curve_i) {
data.slice(points_by_curve[curve_i]).reverse(); });
1652 const IndexRange points = points_by_curve[curve_i];
1656 const int end_index = points.
size() - 1 - i;
1657 std::swap(a[end_index],
b[i]);
1658 std::swap(
b[end_index], a[i]);
1660 if (points.
size() % 2) {
1662 std::swap(a[middle_index],
b[middle_index]);
1667void CurvesGeometry::reverse_curves(
const IndexMask &curves_to_reverse)
1677 if (iter.
domain != AttrDomain::Point) {
1683 if (bezier_handle_names.contains(iter.
name)) {
1688 attribute_math::convert_to_static_type(attribute.span.type(), [&](
auto dummy) {
1689 using T = decltype(dummy);
1690 reverse_curve_point_data<T>(*this, curves_to_reverse, attribute.span.typed<T>());
1696 if (this->nurbs_has_custom_knots()) {
1697 const OffsetIndices custom_knots_by_curve = this->nurbs_custom_knots_by_curve();
1702 reverse_custom_knots(custom_knots.slice(curve_knots));
1717 this->handle_positions_left_for_write(),
1718 this->handle_positions_right_for_write());
1723 this->handle_types_left_for_write(),
1724 this->handle_types_right_for_write());
1727 this->tag_topology_changed();
1730void CurvesGeometry::remove_attributes_based_on_types()
1779 for (const int i_curve : range) {
1780 for (const int i_point : points_by_curve[i_curve]) {
1781 mixer.mix_in(i_curve, old_values[i_point]);
1784 mixer.finalize(
range);
1801 r_values.
fill(
true);
1803 for (
const int i_point : points_by_curve[i_curve]) {
1804 if (!old_values[i_point]) {
1805 r_values[i_curve] =
false;
1816 attribute_math::convert_to_static_type(varray.
type(), [&](
auto dummy) {
1817 using T = decltype(dummy);
1818 if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
1819 Array<T> values(curves.curves_num());
1820 adapt_curve_domain_point_to_curve_impl<T>(curves, varray.typed<T>(), values);
1821 new_varray = VArray<T>::ForContainer(std::move(values));
1841 r_values.
slice(points_by_curve[i_curve]).
fill(old_values[i_curve]);
1849 attribute_math::convert_to_static_type(varray.
type(), [&](
auto dummy) {
1850 using T = decltype(dummy);
1851 Array<T> values(curves.points_num());
1852 adapt_curve_domain_curve_to_point_impl<T>(curves, varray.typed<T>(), values);
1853 new_varray = VArray<T>::ForContainer(std::move(values));
1877 if (
from == AttrDomain::Point && to == AttrDomain::Curve) {
1880 if (
from == AttrDomain::Curve && to == AttrDomain::Point) {
1906 this->runtime = MEM_new<blender::bke::CurvesGeometryRuntime>(__func__);
1910 this->attribute_storage.wrap().blend_read(reader);
1912 if (this->curve_offsets) {
1914 &reader, &this->curve_offsets, [&]() {
1925 if (this->custom_knot_num) {
1927 &reader, &this->custom_knots, [&]() {
1943 bool any_invalid =
false;
1946 if (this->curve_num > 0) {
1960 this->update_curve_types();
1967 attribute_data(scope)
1971void CurvesGeometry::blend_write_prepare(CurvesGeometry::BlendWriteData &write_data)
1974 {{AttrDomain::Point, &write_data.point_layers},
1975 {AttrDomain::Curve, &write_data.curve_layers}},
1976 write_data.attribute_data);
1980 write_data.point_layers,
1981 write_data.attribute_data);
1985 write_data.curve_layers,
1986 write_data.attribute_data);
1987 if (write_data.attribute_data.attributes.is_empty()) {
1999 const CurvesGeometry::BlendWriteData &write_data)
2013 [&]() { BLO_write_int32_array(&writer, this->curve_num + 1, this->curve_offsets); });
2024 [&]() { BLO_write_float_array(&writer, this->custom_knot_num, this->custom_knots); });
Low-level operations for curves.
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
void CustomData_blend_write_prepare(CustomData &data, blender::bke::AttrDomain domain, int domain_size, blender::Vector< CustomDataLayer, 16 > &layers_to_write, blender::bke::AttributeStorage::BlendWriteData &write_data)
void CustomData_count_memory(const CustomData &data, int totelem, blender::MemoryCounter &memory)
void CustomData_realloc(CustomData *data, int old_size, int new_size, eCDAllocType alloctype=CD_CONSTRUCT)
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, blender::StringRef name, int totelem)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, blender::StringRef name)
void CustomData_reset(CustomData *data)
void CustomData_blend_write(BlendWriter *writer, CustomData *data, blender::Span< CustomDataLayer > layers_to_write, int count, eCustomDataMask cddata_mask, ID *id)
void CustomData_free(CustomData *data)
void CustomData_init_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
void CustomData_blend_read(BlendDataReader *reader, CustomData *data, int count)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
bool CustomData_free_layer_named(CustomData *data, blender::StringRef name)
#define BLI_assert_unreachable()
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const size_t num
BlendFileReadReport * BLO_read_data_reports(BlendDataReader *reader)
void BLO_read_float_array(BlendDataReader *reader, int64_t array_size, float **ptr_p)
void BLO_read_int32_array(BlendDataReader *reader, int64_t array_size, int32_t **ptr_p)
void BLO_read_data_invalidate(BlendDataReader *reader, const char *message)
#define BLO_read_struct_list(reader, struct_name, list)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BLO_write_shared(BlendWriter *writer, const void *data, size_t approximate_size_in_bytes, const blender::ImplicitSharingInfo *sharing_info, blender::FunctionRef< void()> write_fn)
const blender::ImplicitSharingInfo * BLO_read_shared(BlendDataReader *reader, T **data_ptr, blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn)
@ NORMAL_MODE_MINIMUM_TWIST
Read Guarded memory(de)allocation.
static const char * ATTR_POSITION
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
static const CPPType & get()
void copy_from(GSpan values)
GMutableSpan slice(const int64_t start, int64_t size) const
GSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
void get_internal_single(void *r_value) const
static GVArray ForSingle(const CPPType &type, int64_t size, const void *value)
constexpr int64_t first() const
constexpr IndexRange shift(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
static constexpr IndexRange from_begin_size(const int64_t begin, const int64_t size)
constexpr int64_t start() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr bool is_empty() const
constexpr MutableSpan drop_back(const int64_t n) const
constexpr void fill(const T &value) const
constexpr void reverse() const
constexpr T & first() const
constexpr IndexRange index_range() const
constexpr void copy_from(Span< T > values) const
constexpr T & last(const int64_t n=0) const
void ensure(FunctionRef< void(T &data)> compute_cache)
constexpr Span slice_safe(const int64_t start, const int64_t size) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr const T & first() const
constexpr const T & last(const int64_t n=0) const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
std::optional< T > get_if_single() const
T get_internal_single() const
Span< T > get_internal_span() const
static VArray ForSingle(T value, const int64_t size)
static VArray ForSpan(Span< T > values)
void append(const T &value)
const T & last(const int64_t n=0) const
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
void reserve(const int64_t min_capacity)
void extend(Span< T > array)
void reinitialize(const int64_t new_size)
Span< T > as_span() const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
bool contains(StringRef attribute_id) const
GAttributeReader lookup(const StringRef attribute_id) const
eCustomDataType data_type
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
SharedCache< Vector< float3 > > evaluated_normal_cache
const ImplicitSharingInfo * custom_knots_sharing_info
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
VArray< int8_t > handle_types_left() const
void remove_attributes_based_on_types()
Array< int > point_to_curve_map() const
MutableSpan< float > nurbs_custom_knots_for_write()
OffsetIndices< int > points_by_curve() const
VArray< int8_t > handle_types_right() const
IndexRange curves_range() const
void update_curve_types()
MutableSpan< int8_t > curve_types_for_write()
MutableAttributeAccessor attributes_for_write()
void nurbs_custom_knots_update_size()
Span< float > nurbs_custom_knots() const
VArray< int > resolution() const
VArray< int8_t > nurbs_knots_modes() const
bool has_curve_with_type(CurveType type) const
void tag_topology_changed()
void resize(int points_num, int curves_num)
void fill_curve_types(CurveType type)
AttributeAccessor attributes() const
IndexMask nurbs_custom_knot_curves(IndexMaskMemory &memory) const
MutableSpan< int > offsets_for_write()
bool nurbs_has_custom_knots() const
OffsetIndices< int > nurbs_custom_knots_by_curve() const
VArray< int8_t > curve_types() const
VArray< bool > cyclic() const
VArray< int8_t > nurbs_orders() const
bool remove(const StringRef attribute_id)
bool add(const StringRef attribute_id, const AttrDomain domain, const eCustomDataType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
static IndexMask from_intersection(const IndexMask &mask_a, const IndexMask &mask_b, IndexMaskMemory &memory)
IndexMask complement(const IndexMask &universe, IndexMaskMemory &memory) const
void foreach_index(Fn &&fn) const
void foreach_segment(Fn &&fn) const
void add_shared(const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
static bool is_cyclic(const Nurb *nu)
static void transform_positions(const Span< blender::float3 > src, const blender::float4x4 &transform, blender::MutableSpan< blender::float3 > dst)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void copy_group_to_group(OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, GSpan src, GMutableSpan dst)
void gather_group_to_group(const OffsetIndices< int > src_offsets, const OffsetIndices< int > dst_offsets, const IndexMask &selection, const Span< T > src, MutableSpan< T > dst)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
typename DefaultMixerStruct< T >::type DefaultMixer
IndexMask curve_to_point_selection(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, IndexMaskMemory &memory)
static void normalize_span(MutableSpan< float3 > data)
static CustomData & domain_custom_data(CurvesGeometry &curves, const AttrDomain domain)
static void translate_positions(MutableSpan< float3 > positions, const float3 &translation)
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)
constexpr StringRef ATTR_RADIUS
constexpr StringRef ATTR_RESOLUTION
static MutableSpan< T > get_mutable_attribute(CurvesGeometry &curves, const AttrDomain domain, const StringRef name, const T default_value=T())
static void copy_point_selection_custom_knots(const CurvesGeometry &curves, const IndexMask &points_to_copy, const Span< int > curve_point_counts, CurvesGeometry &dst_curves)
static VArray< T > get_varray_attribute(const CurvesGeometry &curves, const AttrDomain domain, const StringRef name, const T default_value)
constexpr StringRef ATTR_CURVE_TYPE
static bool is_valid_curve_type(const int8_t type)
eCustomDataType cpp_type_to_custom_data_type(const CPPType &type)
static GVArray adapt_curve_domain_point_to_curve(const CurvesGeometry &curves, const GVArray &varray)
constexpr StringRef ATTR_CYCLIC
void gather_attributes(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
CurvesGeometry curves_new_no_attributes(int point_num, int curve_num)
constexpr StringRef ATTR_SURFACE_UV_COORDINATE
constexpr StringRef ATTR_HANDLE_POSITION_RIGHT
std::array< int, CURVE_TYPES_NUM > calculate_type_counts(const VArray< int8_t > &types)
static void evaluate_generic_data_for_curve(const EvalData &eval_data, const int curve_index, const GSpan src, GMutableSpan dst)
static void reverse_custom_knots(MutableSpan< float > custom_knots)
constexpr StringRef ATTR_NORMAL_MODE
constexpr StringRef ATTR_TILT
constexpr StringRef ATTR_HANDLE_POSITION_LEFT
void transform_custom_normal_attribute(const float4x4 &transform, MutableAttributeAccessor &attributes)
static Span< T > get_span_attribute(const CurvesGeometry &curves, const AttrDomain domain, const StringRef name)
void build_offsets(MutableSpan< int > offsets, const CountFn &count_fn)
static void reverse_curve_point_data(const CurvesGeometry &curves, const IndexMask &curve_selection, MutableSpan< T > data)
constexpr StringRef ATTR_HANDLE_TYPE_LEFT
void gather_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)
static int domain_num(const CurvesGeometry &curves, const AttrDomain domain)
static void reverse_swap_curve_point_data(const CurvesGeometry &curves, const IndexMask &curve_selection, MutableSpan< T > data_a, MutableSpan< T > data_b)
constexpr StringRef ATTR_NURBS_KNOTS_MODE
static bool curve_types_are_valid(const VArray< int8_t > &types)
constexpr StringRef ATTR_POSITION
static GVArray adapt_curve_domain_curve_to_point(const CurvesGeometry &curves, const GVArray &varray)
static void adapt_curve_domain_curve_to_point_impl(const CurvesGeometry &curves, const VArray< T > &old_values, MutableSpan< T > r_values)
constexpr StringRef ATTR_NURBS_ORDER
static void sanitize_curve_types(MutableSpan< int8_t > types)
constexpr StringRef ATTR_NURBS_WEIGHT
constexpr StringRef ATTR_HANDLE_TYPE_RIGHT
void curves_convert_storage_to_customdata(CurvesGeometry &curves)
static void rotate_directions_around_axes(MutableSpan< float3 > directions, const Span< float3 > axes, const Span< float > angles)
static void copy_curve_selection_custom_knots(const CurvesGeometry &curves, const IndexMask &curves_to_copy, CurvesGeometry &dst_curves)
static void adapt_curve_domain_point_to_curve_impl(const CurvesGeometry &curves, const VArray< T > &old_values, MutableSpan< T > r_values)
void attribute_storage_blend_write_prepare(AttributeStorage &data, const Map< AttrDomain, Vector< CustomDataLayer, 16 > * > &layers_to_write, AttributeStorage::BlendWriteData &write_data)
std::optional< Bounds< T > > min_max_with_radii(const Span< T > values, const Span< RadiusT > radii)
std::optional< Bounds< T > > min_max(const std::optional< Bounds< T > > &a, const T &b)
std::optional< T > max(const VArray< T > &values)
void resize_trivial_array(T **data, const ImplicitSharingInfo **sharing_info, int64_t old_size, int64_t new_size)
const ImplicitSharingInfo * info_for_mem_free(void *data)
void free_shared_data(T **data, const ImplicitSharingInfo **sharing_info)
void make_trivial_data_mutable(T **data, const ImplicitSharingInfo **sharing_info, const int64_t size)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
void accumulate_lengths(const Span< T > values, const bool cyclic, MutableSpan< float > lengths)
float3 rotate_direction_around_axis(const float3 &direction, const float3 &axis, float angle)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
bool almost_equal_relative(const VecBase< T, Size > &a, const VecBase< T, Size > &b, const T &epsilon_factor)
void build_reverse_map(OffsetIndices< int > offsets, MutableSpan< int > r_map)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
OffsetIndices< int > gather_selected_offsets(OffsetIndices< int > src_offsets, const IndexMask &selection, int start_offset, MutableSpan< int > dst_offsets)
void parallel_invoke(Functions &&...functions)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
VecBase< float, 3 > float3
static Span< T > get_span_attribute(const PointCloud &pointcloud, const StringRef name)
static VArray< T > get_varray_attribute(const PointCloud &pointcloud, const StringRef name, const T default_value)
static MutableSpan< T > get_mutable_attribute(PointCloud &pointcloud, const StringRef name, const T default_value=T())
struct Attribute * dna_attributes
int vertex_group_active_index
CurvesGeometryRuntimeHandle * runtime
ListBase vertex_group_names
int attributes_active_index
struct AttributeStorage attribute_storage
void pad(const PaddingT &padding)
Vector< int > all_bezier_offsets
Vector< int > evaluated_offsets
const VArray< bool > & cyclic
const Span< float > nurbs_weights
const Span< int > all_bezier_evaluated_offsets
const VArray< int > & resolution
const Span< curves::nurbs::BasisCache > nurbs_basis_cache
const VArray< int8_t > & nurbs_orders
const VArray< int8_t > & types
const OffsetIndices< int > points_by_curve