38const MultiValueMap<bke::GeometryComponent::Type, bke::AttrDomain> &
47 {AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face});
51 return supported_types_and_domains;
53 return supported_types_and_domains;
65 if (iter.
domain != domain) {
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]));
105 for (const int64_t i : range) {
106 data[permutation[i]] = i;
156 src_mesh.edges().cast<
int>(),
157 dst_mesh.edges_for_write().cast<
int>());
161 new_by_old_map.as_span(), src_mesh.corner_verts(), dst_mesh.corner_verts_for_write());
208 new_by_old_map.as_span(), src_mesh.corner_edges(), dst_mesh.corner_edges_for_write());
238 const Span<int> old_offsets = src_mesh.face_offsets();
270 dst_mesh.tag_positions_changed();
271 dst_mesh.tag_topology_changed();
284 dst_pointcloud.attributes_for_write());
285 dst_pointcloud.tag_positions_changed();
286 dst_pointcloud.tag_radii_changed();
365 return dst_pointcloud;
386 src_curve_geometry, old_by_new_map, attribute_filter);
396 return dst_instances;
410 *src_mesh_component->get(), old_by_new_map, domain, attribute_filter);
417 *src_points_component->get(), old_by_new_map, attribute_filter);
424 *src_curves_component->get(), old_by_new_map, attribute_filter);
431 *src_instances_component->get(), old_by_new_map, attribute_filter);
439template<
typename T,
typename Func>
443 MutableSpan<T> values_range = values.slice(range);
444 std::transform(values_range.begin(), values_range.end(), values_range.begin(), func);
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;
458 return weight_a < weight_b;
462 for (const int group_index : range) {
463 MutableSpan<int> group = indices.slice(offsets[group_index]);
464 parallel_sort(group.begin(), group.end(), comparator);
479 const VectorSet<int> deduplicated_identifiers(r_identifiers_to_indices);
481 return deduplicated_identifiers.
index_of(identifier);
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];
491 r_identifiers_to_indices, 4096, [&](
const int index) {
return permutation[
index]; });
492 return deduplicated_identifiers.
size();
503 if (
mask.is_empty()) {
510 mask.to_indices<
int>(gathered_indices);
519 Array<int> offsets_to_sort(total_groups + 1, 0);
533 if (
mask.size() == domain_size) {
534 return gathered_indices;
Low-level operations for curves.
Low-level operations for curves.
General operations for point clouds.
#define BLI_assert_unreachable()
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
IndexRange index_range() const
CommonVArrayInfo common_info() const
const CPPType & type() 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
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() 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
void tag_topology_changed()
bool nurbs_has_custom_knots() const
Span< int > offsets() const
MutableSpan< int > offsets_for_write()
MutableAttributeAccessor attributes_for_write()
void nurbs_custom_knots_update_size()
virtual bool is_empty() const
int add_reference(const InstanceReference &reference)
Span< float4x4 > transforms() const
Span< InstanceReference > references() const
bke::MutableAttributeAccessor attributes_for_write()
bke::AttributeAccessor attributes() const
int instances_num() const
MutableSpan< float4x4 > transforms_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)
IndexRange index_range() const
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)
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)
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)
static Array< int > invert_permutation(const Span< int > permutation)
Mesh * reorder_mesh(const Mesh &src_mesh, Span< int > old_by_new_map, bke::AttrDomain domain, const bke::AttributeFilter &attribute_filter)
std::optional< Array< int > > sort_indices_by_weights(int domain_size, const IndexMask &mask, const VArray< int > &group_id, const VArray< float > &weight)
static int identifiers_to_indices(MutableSpan< int > r_identifiers_to_indices)
PointCloud * reorder_points(const PointCloud &src_pointcloud, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
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)
static void parallel_transform(MutableSpan< T > values, const int64_t grain_size, const Func &func)
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)
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)
bke::CurvesGeometry reorder_curves_geometry(const bke::CurvesGeometry &src_curves, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
const MultiValueMap< bke::GeometryComponent::Type, bke::AttrDomain > & components_supported_reordering()
static void grouped_sort(const OffsetIndices< int > offsets, const Span< float > weights, MutableSpan< int > indices)
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)
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)
bke::GeometryComponentPtr reordered_component(const bke::GeometryComponent &src_component, Span< int > old_by_new_map, bke::AttrDomain domain, const bke::AttributeFilter &attribute_filter)
bke::Instances * reorder_instaces(const bke::Instances &src_instances, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
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)
Curves * reorder_curves(const Curves &src_curves, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
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))
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
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)
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