diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-06 01:57:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-06 01:57:41 +0300 |
commit | d9d3ed16a8c61bb1c780d81a2cf398be92cd16c1 (patch) | |
tree | 90d340013de712b868905d8d751977a8fe76e7de /source/blender/editors/mesh/meshtools.c | |
parent | df267bd4c48a3b73ad959951419161ae8f9ed126 (diff) |
Fix T53206: Array modifier doesn't merge vgroups
Vertex group remapping utility function,
now shared between object join and array modifier cap-ends.
Weights which don't exist are removed.
D3092 by @Foaly
Diffstat (limited to 'source/blender/editors/mesh/meshtools.c')
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index c900373a59c..fa1c935e2ff 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -58,6 +58,7 @@ #include "BKE_mesh.h" #include "BKE_material.h" #include "BKE_object.h" +#include "BKE_object_deform.h" #include "BKE_report.h" #include "BKE_editmesh.h" #include "BKE_multires.h" @@ -111,21 +112,12 @@ static void join_mesh_single( BLI_assert(dvert != NULL); /* Build src to merged mapping of vgroup indices. */ - bDeformGroup *dg_src; - int *vgroup_index_map = alloca(sizeof(*vgroup_index_map) * BLI_listbase_count(&ob_src->defbase)); - bool is_vgroup_remap_needed = false; - - for (dg_src = ob_src->defbase.first, b = 0; dg_src; dg_src = dg_src->next, b++) { - vgroup_index_map[b] = defgroup_name_index(ob_dst, dg_src->name); - is_vgroup_remap_needed = is_vgroup_remap_needed || (vgroup_index_map[b] != b); - } - - if (is_vgroup_remap_needed) { - for (a = 0; a < me->totvert; a++) { - for (b = 0; b < dvert[a].totweight; b++) { - dvert[a].dw[b].def_nr = vgroup_index_map[dvert_src[a].dw[b].def_nr]; - } - } + int *vgroup_index_map; + int vgroup_index_map_len; + vgroup_index_map = BKE_object_defgroup_index_map_create(ob_src, ob_dst, &vgroup_index_map_len); + BKE_object_defgroup_index_map_apply(dvert, me->totvert, vgroup_index_map, vgroup_index_map_len); + if (vgroup_index_map != NULL) { + MEM_freeN(vgroup_index_map); } } |