143 const bool exclude_names,
161 bool transfer_by_index =
false;
170 patterns, iter.
domain, iter.
name, exclude_names, r_found_attribute_using_pattern))
178 for (
const auto &[domain, ids] : ids_by_domain.
items()) {
179 const Field<int> &src_id_field = src_id_fields.lookup(domain);
180 const Field<int> &dst_id_field = dst_id_fields.lookup(domain);
184 ids.transfer_by_index =
true;
188 const int src_size = src_attributes.
domain_size(domain);
189 const int dst_size = dst_attributes.
domain_size(domain);
193 src_evaluator.
add(src_id_field);
199 dst_evaluator.
add(dst_id_field);
205 const int id = src_ids[i];
206 src_index_by_id.add(
id, i);
208 ids.src_by_dst_index.reinitialize(dst_size);
210 for (
const int dst_i : range) {
211 const int dst_id = dst_ids[dst_i];
212 const int src_i = src_index_by_id.lookup_default(dst_id, -1);
213 ids.src_by_dst_index[dst_i] = src_i;
218 ids.default_mask = ids.gather_mask.complement(
IndexMask(dst_size), scope.
allocator());
221 for (
const AttrItem &item : items) {
224 const IDs &ids = ids_by_domain.
lookup(item.domain);
228 const int dst_size = dst_attributes.
domain_size(item.domain);
230 const std::optional<bke::AttributeMetaData> old_dst_meta = dst_attributes.
lookup_meta_data(
232 const bool has_matching_existing_attribute = old_dst_meta.has_value() &&
233 old_dst_meta->domain == item.domain &&
234 old_dst_meta->data_type == item.type;
244 if (ids.transfer_by_index) {
247 if (src_size >= dst_size) {
251 r_transferred_names.
add(item.name);
259 src_size == dst_size)
267 r_transferred_names.
add(item.name);
272 const int copy_num = std::min(src_size, dst_size);
276 if (old_dst_meta.has_value()) {
277 if (has_matching_existing_attribute) {
284 r_transferred_names.
add(item.name);
290 item.name, item.domain, item.type);
291 if (!adapted_old_dst) {
299 dst_attributes, item.name, item.domain, item.type, std::move(dst_data),
true))
301 r_transferred_names.
add(item.name);
313 dst_attributes, item.name, item.domain, item.type, std::move(dst_data),
false))
315 r_transferred_names.
add(item.name);
321 if (ids.gather_mask.size() == dst_size) {
328 r_transferred_names.
add(item.name);
333 if (has_matching_existing_attribute) {
335 item.name, item.domain, item.type);
339 r_transferred_names.
add(item.name);
346 dst_attributes, item.name, item.domain, item.type, std::move(dst_data),
true))
348 r_transferred_names.
add(item.name);
354 if (has_matching_existing_attribute) {
356 item.name, item.domain, item.type);
360 r_transferred_names.
add(item.name);
366 *src_attr, ids.src_by_dst_index, ids.gather_mask, dst_data.
as_mutable_span());
369 dst_attributes, item.name, item.domain, item.type, std::move(dst_data),
false))
371 r_transferred_names.
add(item.name);
376 item.name, item.domain, item.type);
377 if (!adapted_old_dst) {
385 dst_attributes, item.name, item.domain, item.type, std::move(dst_data),
true))
387 r_transferred_names.
add(item.name);
397 "Pattern Mode"_ustr);
399 const bool exclude_names = params.
extract_input<
bool>(
"Exclude Names"_ustr);
420 bool has_error =
false;
421 if (attribute_patterns_list) {
422 if (attribute_patterns_list->cpp_type().is<std::string>()) {
423 attribute_patterns_list.typed<std::string>()->
foreach([&](
const std::string &pattern) {
426 pattern_mode, pattern, error))
428 patterns.
append(std::move(*pattern_fn));
438 if (has_error || (patterns.
is_empty() && !exclude_names)) {
439 params.
set_output(
"Target"_ustr, std::move(dst_geo));
451 if (!dst_geo.
has(type)) {
454 if (!src_geo.has(type)) {
475 found_attribute_using_pattern);
480 const GreasePencil &src_grease_pencil = *src_geo.get_grease_pencil();
482 const int src_layer_num = src_grease_pencil.layers().size();
483 const int dst_layer_num = dst_grease_pencil.layers().size();
485 const int common_layer_num = std::min(src_layer_num, dst_layer_num);
486 for (
const int layer_i :
IndexRange(common_layer_num)) {
487 const Layer &src_layer = src_grease_pencil.layer(layer_i);
488 const Drawing *src_drawing = src_grease_pencil.get_eval_drawing(src_layer);
492 Layer &dst_layer = dst_grease_pencil.layer(layer_i);
493 Drawing *dst_drawing = dst_grease_pencil.get_eval_drawing(dst_layer);
510 src_grease_pencil, domain, layer_i);
514 dst_grease_pencil, domain, layer_i);
517 found_attribute_using_pattern);
523 if (!exclude_names) {
524 for (
const int pattern_i : patterns.
index_range()) {
525 const StringRef full_pattern = patterns[pattern_i].full_pattern();
529 if (found_attribute_using_pattern[pattern_i]) {
533 fmt::format(
"{} \"{}\"",
534 TIP_(
"No attribute found matching"),
535 patterns[pattern_i].full_pattern()));
539 params.
set_output(
"Target"_ustr, std::move(dst_geo));