From 0e3475b00d44bc0220cee84d28daacaa6735f62f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 8 Feb 2019 10:12:31 +0100 Subject: 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. --- source/blender/blenkernel/intern/deform.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern/deform.c') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index c3f3516c714..a6c5ddf0285 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -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! -- cgit v1.2.3