Blender V5.3
reorder.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BKE_attribute.hh"
11#include "BKE_attribute_math.hh"
12#include "BKE_curves.hh"
13#include "BKE_curves_utils.hh"
14#include "BKE_deform.hh"
15#include "BKE_geometry_set.hh"
16#include "BKE_instances.hh"
17#include "BKE_mesh.hh"
18#include "BKE_pointcloud.hh"
19
20#include "BLI_array.hh"
21#include "BLI_array_utils.hh"
22#include "BLI_index_mask.hh"
24#include "BLI_offset_indices.hh"
25#include "BLI_sort.hh"
26#include "BLI_task.hh"
27#include "BLI_vector_set.hh"
28#include "BLI_virtual_array.hh"
29
30#include "DNA_curves_types.h"
31#include "DNA_mesh_types.h"
33
34#include "GEO_reorder.hh"
35
36namespace blender::geometry {
37
38const MultiValueMap<bke::GeometryComponent::Type, bke::AttrDomain> &
40{
41 using namespace bke;
42 const static MultiValueMap<GeometryComponent::Type, AttrDomain> supported_types_and_domains =
43 []() {
45 supported_types_and_domains.add_multiple(
47 {AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face});
48 supported_types_and_domains.add(GeometryComponent::Type::Curve, AttrDomain::Curve);
49 supported_types_and_domains.add(GeometryComponent::Type::PointCloud, AttrDomain::Point);
50 supported_types_and_domains.add(GeometryComponent::Type::Instance, AttrDomain::Instance);
51 return supported_types_and_domains;
52 }();
53 return supported_types_and_domains;
54}
55
57 const bke::AttrDomain domain,
58 const OffsetIndices<int> src_offsets,
59 const OffsetIndices<int> dst_offsets,
60 const Span<int> old_by_new_map,
61 const bke::AttributeFilter &attribute_filter,
62 bke::MutableAttributeAccessor dst_attributes)
63{
64 src_attributes.foreach_attribute([&](const bke::AttributeIter &iter) {
65 if (iter.domain != domain) {
66 return;
67 }
68 if (iter.data_type == bke::AttrType::String) {
69 return;
70 }
71 if (attribute_filter.allow_skip(iter.name)) {
72 return;
73 }
74 const GVArray src = *iter.get(domain);
75
76 const CommonVArrayInfo info = src.common_info();
78 const GPointer value(src.type(), info.data);
79 if (dst_attributes.add(iter.name, domain, iter.data_type, bke::AttributeInitValue(value))) {
80 return;
81 }
82 }
83
85 iter.name, domain, iter.data_type);
86 if (!dst) {
87 return;
88 }
89
90 threading::parallel_for(old_by_new_map.index_range(), 1024, [&](const IndexRange range) {
91 for (const int new_i : range) {
92 const int old_i = old_by_new_map[new_i];
93 array_utils::copy(src.slice(src_offsets[old_i]), dst.span.slice(dst_offsets[new_i]));
94 }
95 });
96
97 dst.finish();
98 });
99}
100
101static Array<int> invert_permutation(const Span<int> permutation)
102{
103 Array<int> data(permutation.size());
104 threading::parallel_for(permutation.index_range(), 2048, [&](const IndexRange range) {
105 for (const int64_t i : range) {
106 data[permutation[i]] = i;
107 }
108 });
109 return data;
110}
111
112static void copy_and_reorder_mesh_verts(const Mesh &src_mesh,
113 const Span<int> old_by_new_map,
114 const bke::AttributeFilter &attribute_filter,
115 Mesh &dst_mesh)
116{
117 const bke::AttributeAccessor src_attributes = src_mesh.attributes();
118 bke::MutableAttributeAccessor dst_attributes = dst_mesh.attributes_for_write();
119
120 bke::gather_attributes(src_attributes,
123 attribute_filter,
124 old_by_new_map,
125 dst_attributes);
126
127 bke::copy_attributes(src_attributes,
130 bke::attribute_filter_with_skip_ref(attribute_filter, {".edge_verts"}),
131 dst_attributes);
132
133 bke::copy_attributes(src_attributes,
136 attribute_filter,
137 dst_attributes);
138
143 &dst_mesh.face_offset_indices,
145
146 bke::copy_attributes(src_attributes,
149 bke::attribute_filter_with_skip_ref(attribute_filter, {".corner_vert"}),
150 dst_attributes);
151
152 const Array<int> new_by_old_map = invert_permutation(old_by_new_map);
153
154 dst_attributes.add<int2>(".edge_verts", bke::AttrDomain::Edge, bke::AttributeInitConstruct());
155 array_utils::gather(new_by_old_map.as_span(),
156 src_mesh.edges().cast<int>(),
157 dst_mesh.edges_for_write().cast<int>());
158
159 dst_attributes.add<int>(".corner_vert", bke::AttrDomain::Corner, bke::AttributeInitConstruct());
161 new_by_old_map.as_span(), src_mesh.corner_verts(), dst_mesh.corner_verts_for_write());
162}
163
164static void copy_and_reorder_mesh_edges(const Mesh &src_mesh,
165 const Span<int> old_by_new_map,
166 const bke::AttributeFilter &attribute_filter,
167 Mesh &dst_mesh)
168{
169 const bke::AttributeAccessor src_attributes = src_mesh.attributes();
170 bke::MutableAttributeAccessor dst_attributes = dst_mesh.attributes_for_write();
171
172 bke::copy_attributes(src_attributes,
175 attribute_filter,
176 dst_attributes);
177
178 bke::gather_attributes(src_attributes,
181 attribute_filter,
182 old_by_new_map,
183 dst_attributes);
184
185 bke::copy_attributes(src_attributes,
188 attribute_filter,
189 dst_attributes);
190
195 &dst_mesh.face_offset_indices,
197
198 bke::copy_attributes(src_attributes,
201 bke::attribute_filter_with_skip_ref(attribute_filter, {".corner_edge"}),
202 dst_attributes);
203
204 const Array<int> new_by_old_map = invert_permutation(old_by_new_map);
205
206 dst_attributes.add<int>(".corner_edge", bke::AttrDomain::Corner, bke::AttributeInitConstruct());
208 new_by_old_map.as_span(), src_mesh.corner_edges(), dst_mesh.corner_edges_for_write());
209}
210
211static void copy_and_reorder_mesh_faces(const Mesh &src_mesh,
212 const Span<int> old_by_new_map,
213 const bke::AttributeFilter &attribute_filter,
214 Mesh &dst_mesh)
215{
216 const bke::AttributeAccessor src_attributes = src_mesh.attributes();
217 bke::MutableAttributeAccessor dst_attributes = dst_mesh.attributes_for_write();
218
219 bke::copy_attributes(src_attributes,
222 attribute_filter,
223 dst_attributes);
224
225 bke::copy_attributes(src_attributes,
228 attribute_filter,
229 dst_attributes);
230
231 bke::gather_attributes(src_attributes,
234 attribute_filter,
235 old_by_new_map,
236 dst_attributes);
237
238 const Span<int> old_offsets = src_mesh.face_offsets();
239 MutableSpan<int> new_offsets = dst_mesh.face_offsets_for_write();
240 offset_indices::gather_group_sizes(old_offsets, old_by_new_map, new_offsets);
244 old_offsets,
245 new_offsets.as_span(),
246 old_by_new_map,
247 attribute_filter,
248 dst_attributes);
249}
250
251static void copy_and_reorder_mesh(const Mesh &src_mesh,
252 const Span<int> old_by_new_map,
253 const bke::AttrDomain domain,
254 const bke::AttributeFilter &attribute_filter,
255 Mesh &dst_mesh)
256{
257 switch (domain) {
259 copy_and_reorder_mesh_verts(src_mesh, old_by_new_map, attribute_filter, dst_mesh);
260 break;
262 copy_and_reorder_mesh_edges(src_mesh, old_by_new_map, attribute_filter, dst_mesh);
263 break;
265 copy_and_reorder_mesh_faces(src_mesh, old_by_new_map, attribute_filter, dst_mesh);
266 break;
267 default:
268 break;
269 }
270 dst_mesh.tag_positions_changed();
271 dst_mesh.tag_topology_changed();
272}
273
274static void copy_and_reorder_points(const PointCloud &src_pointcloud,
275 const Span<int> old_by_new_map,
276 const bke::AttributeFilter &attribute_filter,
277 PointCloud &dst_pointcloud)
278{
279 bke::gather_attributes(src_pointcloud.attributes(),
282 attribute_filter,
283 old_by_new_map,
284 dst_pointcloud.attributes_for_write());
285 dst_pointcloud.tag_positions_changed();
286 dst_pointcloud.tag_radii_changed();
287}
288
289static void copy_and_reorder_curves(const bke::CurvesGeometry &src_curves,
290 const Span<int> old_by_new_map,
291 const bke::AttributeFilter &attribute_filter,
292 bke::CurvesGeometry &dst_curves)
293{
297 attribute_filter,
298 old_by_new_map,
299 dst_curves.attributes_for_write());
300
301 const Span<int> old_offsets = src_curves.offsets();
302 MutableSpan<int> new_offsets = dst_curves.offsets_for_write();
303 offset_indices::gather_group_sizes(old_offsets, old_by_new_map, new_offsets);
305
308 old_offsets,
309 new_offsets.as_span(),
310 old_by_new_map,
311 attribute_filter,
312 dst_curves.attributes_for_write());
313 dst_curves.tag_topology_changed();
314 if (src_curves.nurbs_has_custom_knots()) {
316 IndexMaskMemory memory;
318 src_curves, IndexMask::from_indices(old_by_new_map, memory), 0, dst_curves);
319 }
320}
321
322static void copy_and_reorder_instaces(const bke::Instances &src_instances,
323 const Span<int> old_by_new_map,
324 const bke::AttributeFilter &attribute_filter,
325 bke::Instances &dst_instances)
326{
327 dst_instances.resize(src_instances.instances_num());
328
329 bke::gather_attributes(src_instances.attributes(),
332 attribute_filter,
333 old_by_new_map,
334 dst_instances.attributes_for_write());
335
336 for (const bke::InstanceReference &reference : src_instances.references()) {
337 dst_instances.add_reference(reference);
338 }
339 BLI_assert(src_instances.references() == dst_instances.references());
340
341 const Span<float4x4> old_transforms = src_instances.transforms();
342 MutableSpan<float4x4> new_transforms = dst_instances.transforms_for_write();
343 array_utils::gather(old_transforms, old_by_new_map, new_transforms);
344}
345
346Mesh *reorder_mesh(const Mesh &src_mesh,
347 Span<int> old_by_new_map,
348 bke::AttrDomain domain,
349 const bke::AttributeFilter &attribute_filter)
350{
352 src_mesh.verts_num, src_mesh.edges_num, src_mesh.faces_num, src_mesh.corners_num);
353 BKE_mesh_copy_parameters_for_eval(dst_mesh, &src_mesh);
354 copy_and_reorder_mesh(src_mesh, old_by_new_map, domain, attribute_filter, *dst_mesh);
355 return dst_mesh;
356}
357
358PointCloud *reorder_points(const PointCloud &src_pointcloud,
359 Span<int> old_by_new_map,
360 const bke::AttributeFilter &attribute_filter)
361{
362 PointCloud *dst_pointcloud = bke::pointcloud_new_no_attributes(src_pointcloud.type,
363 src_pointcloud.totpoint);
364 copy_and_reorder_points(src_pointcloud, old_by_new_map, attribute_filter, *dst_pointcloud);
365 return dst_pointcloud;
366}
367
369 Span<int> old_by_new_map,
370 const bke::AttributeFilter &attribute_filter)
371{
373 src_curves.curves_num());
375 copy_and_reorder_curves(src_curves, old_by_new_map, attribute_filter, dst_curves);
376 return dst_curves;
377}
378
379Curves *reorder_curves(const Curves &src_curves,
380 Span<int> old_by_new_map,
381 const bke::AttributeFilter &attribute_filter)
382{
383 const bke::CurvesGeometry src_curve_geometry = src_curves.geometry.wrap();
384 Curves *dst_curves = bke::curves_new_nomain(0, 0);
385 dst_curves->geometry.wrap() = reorder_curves_geometry(
386 src_curve_geometry, old_by_new_map, attribute_filter);
387 return dst_curves;
388}
389
391 Span<int> old_by_new_map,
392 const bke::AttributeFilter &attribute_filter)
393{
394 bke::Instances *dst_instances = new bke::Instances(src_instances);
395 copy_and_reorder_instaces(src_instances, old_by_new_map, attribute_filter, *dst_instances);
396 return dst_instances;
397}
398
400 const Span<int> old_by_new_map,
401 const bke::AttrDomain domain,
402 const bke::AttributeFilter &attribute_filter)
403{
404 BLI_assert(!src_component.is_empty());
405
406 if (const bke::MeshComponent *src_mesh_component = dynamic_cast<const bke::MeshComponent *>(
407 &src_component))
408 {
409 Mesh *result_mesh = reorder_mesh(
410 *src_mesh_component->get(), old_by_new_map, domain, attribute_filter);
411 return bke::GeometryComponentPtr(new bke::MeshComponent(result_mesh));
412 }
413 if (const bke::PointCloudComponent *src_points_component =
414 dynamic_cast<const bke::PointCloudComponent *>(&src_component))
415 {
416 PointCloud *result_pointcloud = reorder_points(
417 *src_points_component->get(), old_by_new_map, attribute_filter);
418 return bke::GeometryComponentPtr(new bke::PointCloudComponent(result_pointcloud));
419 }
420 if (const bke::CurveComponent *src_curves_component = dynamic_cast<const bke::CurveComponent *>(
421 &src_component))
422 {
423 Curves *result_curves = reorder_curves(
424 *src_curves_component->get(), old_by_new_map, attribute_filter);
425 return bke::GeometryComponentPtr(new bke::CurveComponent(result_curves));
426 }
427 if (const bke::InstancesComponent *src_instances_component =
428 dynamic_cast<const bke::InstancesComponent *>(&src_component))
429 {
430 bke::Instances *result_instances = reorder_instaces(
431 *src_instances_component->get(), old_by_new_map, attribute_filter);
432 return bke::GeometryComponentPtr(new bke::InstancesComponent(result_instances));
433 }
434
436 return {};
437}
438
439template<typename T, typename Func>
440static void parallel_transform(MutableSpan<T> values, const int64_t grain_size, const Func &func)
441{
442 threading::parallel_for(values.index_range(), grain_size, [&](const IndexRange range) {
443 MutableSpan<T> values_range = values.slice(range);
444 std::transform(values_range.begin(), values_range.end(), values_range.begin(), func);
445 });
446}
447
448static void grouped_sort(const OffsetIndices<int> offsets,
449 const Span<float> weights,
450 MutableSpan<int> indices)
451{
452 const auto comparator = [&](const int index_a, const int index_b) {
453 const float weight_a = weights[index_a];
454 const float weight_b = weights[index_b];
455 if (weight_a == weight_b) [[unlikely]] {
456 return index_a < index_b;
457 }
458 return weight_a < weight_b;
459 };
460
461 threading::parallel_for(offsets.index_range(), 250, [&](const IndexRange range) {
462 for (const int group_index : range) {
463 MutableSpan<int> group = indices.slice(offsets[group_index]);
464 parallel_sort(group.begin(), group.end(), comparator);
465 }
466 });
467}
468
469static void find_points_by_group_index(const Span<int> indices,
470 MutableSpan<int> r_offsets,
471 MutableSpan<int> r_indices)
472{
473 const OffsetIndices offsets = offset_indices::build_reverse_offsets(indices, r_offsets);
474 offset_indices::reverse_indices_in_groups(indices, offsets, r_indices, false);
475}
476
477static int identifiers_to_indices(MutableSpan<int> r_identifiers_to_indices)
478{
479 const VectorSet<int> deduplicated_identifiers(r_identifiers_to_indices);
480 parallel_transform(r_identifiers_to_indices, 2048, [&](const int identifier) {
481 return deduplicated_identifiers.index_of(identifier);
482 });
483
484 Array<int> indices(deduplicated_identifiers.size());
486 parallel_sort(indices.begin(), indices.end(), [&](const int index_a, const int index_b) {
487 return deduplicated_identifiers[index_a] < deduplicated_identifiers[index_b];
488 });
489 Array<int> permutation = invert_permutation(indices);
491 r_identifiers_to_indices, 4096, [&](const int index) { return permutation[index]; });
492 return deduplicated_identifiers.size();
493}
494
495std::optional<Array<int>> sort_indices_by_weights(const int domain_size,
496 const IndexMask &mask,
497 const VArray<int> &group_id,
498 const VArray<float> &weight)
499{
500 if (group_id.is_single() && weight.is_single()) {
501 return std::nullopt;
502 }
503 if (mask.is_empty()) {
504 return std::nullopt;
505 }
506
507 Array<int> gathered_indices(mask.size());
508
509 if (group_id.is_single()) {
510 mask.to_indices<int>(gathered_indices);
511 Array<float> weight_values(domain_size);
512 array_utils::copy(weight, mask, weight_values.as_mutable_span());
513 grouped_sort(Span({0, int(mask.size())}), weight_values, gathered_indices);
514 }
515 else {
516 Array<int> gathered_group_id(mask.size());
517 array_utils::gather(group_id, mask, gathered_group_id.as_mutable_span());
518 const int total_groups = identifiers_to_indices(gathered_group_id);
519 Array<int> offsets_to_sort(total_groups + 1, 0);
520 find_points_by_group_index(gathered_group_id, offsets_to_sort, gathered_indices);
521 if (!weight.is_single()) {
522 Array<float> weight_values(mask.size());
523 array_utils::gather(weight, mask, weight_values.as_mutable_span());
524 grouped_sort(offsets_to_sort.as_span(), weight_values, gathered_indices);
525 }
526 parallel_transform<int>(gathered_indices, 2048, [&](const int pos) { return mask[pos]; });
527 }
528
529 if (array_utils::indices_are_range(gathered_indices, IndexRange(domain_size))) {
530 return std::nullopt;
531 }
532
533 if (mask.size() == domain_size) {
534 return gathered_indices;
535 }
536
537 IndexMaskMemory memory;
538 const IndexMask unselected = mask.complement(IndexRange(domain_size), memory);
539 Array<int> indices(domain_size);
540 array_utils::scatter<int>(gathered_indices, mask, indices);
541 array_utils::fill_index_range<int>(unselected, indices);
542
543 if (array_utils::indices_are_range(indices, indices.index_range())) {
544 return std::nullopt;
545 }
546
547 return indices;
548}
549
550} // namespace blender::geometry
Low-level operations for curves.
Low-level operations for curves.
support for deformation groups and hooks.
General operations for point clouds.
#define BLI_assert_unreachable()
constexpr Span()=default
Span< T > as_span() const
Definition BLI_array.hh:254
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:259
IndexRange index_range() const
Definition BLI_array.hh:371
CommonVArrayInfo common_info() const
static IndexMask from_indices(Span< T > indices, LinearAllocator<> &memory)
void add_multiple(const Key &key, Span< Value > values)
void add(const Key &key, const Value &value)
constexpr Span< T > as_span() const
Definition BLI_span.hh:667
constexpr IndexRange index_range() const
Definition BLI_span.hh:676
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
int64_t size() const
int64_t index_of(const Key &key) const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader get() const
AttributeAccessor attributes() const
MutableSpan< int > offsets_for_write()
MutableAttributeAccessor attributes_for_write()
virtual bool is_empty() const
int add_reference(const InstanceReference &reference)
Definition instances.cc:268
Span< float4x4 > transforms() const
Definition instances.cc:235
Span< InstanceReference > references() const
Definition instances.cc:290
bke::MutableAttributeAccessor attributes_for_write()
Definition instances.cc:73
bke::AttributeAccessor attributes() const
Definition instances.cc:68
int instances_num() const
Definition instances.cc:408
void resize(int size)
Definition instances.cc:216
MutableSpan< float4x4 > transforms_for_write()
Definition instances.cc:242
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)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
bool indices_are_range(Span< int > indices, IndexRange range)
void scatter(const Span< T > src, const Span< IndexT > indices, MutableSpan< T > dst, const Mode mode={})
void copy(const GVArray &src, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
void fill_index_range(MutableSpan< T > span, const T start=0)
void gather_custom_knots(const bke::CurvesGeometry &src, const IndexMask &src_curves, int dst_curve_offset, bke::CurvesGeometry &dst)
auto attribute_filter_with_skip_ref(const AttributeFilter &filter, const Span< StringRef > skip)
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr
PointCloud * pointcloud_new_no_attributes(PointCloudType type, int totpoint)
void copy_attributes(const AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, MutableAttributeAccessor dst_attributes)
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)
Mesh * mesh_new_no_attributes(int verts_num, int edges_num, int faces_num, int corners_num)
Curves * curves_new_nomain(int points_num, int curves_num)
static void find_points_by_group_index(const Span< int > indices, MutableSpan< int > r_offsets, MutableSpan< int > r_indices)
Definition reorder.cc:469
static void reorder_attributes_group_to_group(const bke::AttributeAccessor src_attributes, const bke::AttrDomain domain, const OffsetIndices< int > src_offsets, const OffsetIndices< int > dst_offsets, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, bke::MutableAttributeAccessor dst_attributes)
Definition reorder.cc:56
static void copy_and_reorder_instaces(const bke::Instances &src_instances, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, bke::Instances &dst_instances)
Definition reorder.cc:322
static Array< int > invert_permutation(const Span< int > permutation)
Definition randomize.cc:39
Mesh * reorder_mesh(const Mesh &src_mesh, Span< int > old_by_new_map, bke::AttrDomain domain, const bke::AttributeFilter &attribute_filter)
Definition reorder.cc:346
std::optional< Array< int > > sort_indices_by_weights(int domain_size, const IndexMask &mask, const VArray< int > &group_id, const VArray< float > &weight)
Definition reorder.cc:495
static int identifiers_to_indices(MutableSpan< int > r_identifiers_to_indices)
Definition reorder.cc:477
PointCloud * reorder_points(const PointCloud &src_pointcloud, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
Definition reorder.cc:358
static void copy_and_reorder_points(const PointCloud &src_pointcloud, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, PointCloud &dst_pointcloud)
Definition reorder.cc:274
static void parallel_transform(MutableSpan< T > values, const int64_t grain_size, const Func &func)
Definition reorder.cc:440
static void copy_and_reorder_curves(const bke::CurvesGeometry &src_curves, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, bke::CurvesGeometry &dst_curves)
Definition reorder.cc:289
static void copy_and_reorder_mesh_verts(const Mesh &src_mesh, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, Mesh &dst_mesh)
Definition reorder.cc:112
bke::CurvesGeometry reorder_curves_geometry(const bke::CurvesGeometry &src_curves, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
Definition reorder.cc:368
const MultiValueMap< bke::GeometryComponent::Type, bke::AttrDomain > & components_supported_reordering()
Definition reorder.cc:39
static void grouped_sort(const OffsetIndices< int > offsets, const Span< float > weights, MutableSpan< int > indices)
Definition reorder.cc:448
static void copy_and_reorder_mesh_faces(const Mesh &src_mesh, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, Mesh &dst_mesh)
Definition reorder.cc:211
static void copy_and_reorder_mesh_edges(const Mesh &src_mesh, const Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter, Mesh &dst_mesh)
Definition reorder.cc:164
bke::GeometryComponentPtr reordered_component(const bke::GeometryComponent &src_component, Span< int > old_by_new_map, bke::AttrDomain domain, const bke::AttributeFilter &attribute_filter)
Definition reorder.cc:399
bke::Instances * reorder_instaces(const bke::Instances &src_instances, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
Definition reorder.cc:390
static void copy_and_reorder_mesh(const Mesh &src_mesh, const Span< int > old_by_new_map, const bke::AttrDomain domain, const bke::AttributeFilter &attribute_filter, Mesh &dst_mesh)
Definition reorder.cc:251
Curves * reorder_curves(const Curves &src_curves, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
Definition reorder.cc:379
void copy_shared_pointer(T *src_ptr, const ImplicitSharingInfo *src_sharing_info, T **r_dst_ptr, const ImplicitSharingInfo **r_dst_sharing_info)
void free_shared_data(T **data, const ImplicitSharingInfo **sharing_info)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void gather_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
OffsetIndices< int > build_reverse_offsets(Span< int > indices, MutableSpan< int > offsets)
void reverse_indices_in_groups(Span< int > group_indices, OffsetIndices< int > offsets, MutableSpan< int > results, bool sort=true)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
Definition BLI_sort.hh:37
void BKE_mesh_copy_parameters_for_eval(Mesh *me_dst, const Mesh *me_src)
VecBase< int32_t, 2 > int2
BMesh const char void * data
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
Definition deform.cc:75
ListBaseT< struct bDeformGroup > vertex_group_names
bke::MeshRuntime * runtime
int * face_offset_indices
bool allow_skip(const StringRef name) const
const ImplicitSharingInfo * face_offsets_sharing_info