Fix T61255: Mesh Data Transfer: Do not abort when destination has not all source data layers.

Originally, when transferring all source data layers to destination
meshes, code would abort in case destination did not have all needed
layers, and creating them was not allowed.

Now, it will instead transfer data to layers that exists, merely
skipping source ones for which it cannot find a matching destination.
This commit is contained in:
2019-02-08 10:12:31 +01:00
parent 351b24ac14
commit 0e3475b00d
2 changed files with 30 additions and 24 deletions

View File

@@ -501,12 +501,15 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
idx_src++;
if (idx_dst < idx_src) {
if (!use_create) {
return true;
if (use_create) {
/* Create as much data layers as necessary! */
for (; idx_dst < idx_src; idx_dst++) {
CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
}
/* Create as much data layers as necessary! */
for (; idx_dst < idx_src; idx_dst++) {
CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
else {
/* Otherwise, just try to map what we can with existing dst data layers. */
idx_src = idx_dst;
}
}
else if (use_delete && idx_dst > idx_src) {
@@ -551,14 +554,14 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(
data_src = CustomData_get_layer_n(cd_src, cddata_type, idx_src);
if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
if (!use_create) {
if (r_map) {
BLI_freelistN(r_map);
}
return true;
if (use_create) {
CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
else {
/* If we are not allowed to create missing dst data layers, just skip matching src one. */
continue;
}
CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
else if (data_dst_to_delete) {
data_dst_to_delete[idx_dst] = false;

View File

@@ -1060,12 +1060,15 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(
idx_src++;
if (idx_dst < idx_src) {
if (!use_create) {
return false;
if (use_create) {
/* Create as much vgroups as necessary! */
for (; idx_dst < idx_src; idx_dst++) {
BKE_object_defgroup_add(ob_dst);
}
}
/* Create as much vgroups as necessary! */
for (; idx_dst < idx_src; idx_dst++) {
BKE_object_defgroup_add(ob_dst);
else {
/* Otherwise, just try to map what we can with existing dst vgroups. */
idx_src = idx_dst;
}
}
else if (use_delete && idx_dst > idx_src) {
@@ -1115,14 +1118,14 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(
}
if ((idx_dst = defgroup_name_index(ob_dst, dg_src->name)) == -1) {
if (!use_create) {
if (r_map) {
BLI_freelistN(r_map);
}
return false;
if (use_create) {
BKE_object_defgroup_add_name(ob_dst, dg_src->name);
idx_dst = ob_dst->actdef - 1;
}
else {
/* If we are not allowed to create missing dst vgroups, just skip matching src one. */
continue;
}
BKE_object_defgroup_add_name(ob_dst, dg_src->name);
idx_dst = ob_dst->actdef - 1;
}
if (r_map) {
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!