From b5ce2bbef7a91f81c3556f2ddf6dd5f21161bc91 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Apr 2016 21:47:05 +1000 Subject: [PATCH] BMesh: when multiple vertices have the same key-index, use the first Simple error case where many vertices share an original index, now use the first match instead of the last. --- source/blender/bmesh/intern/bmesh_mesh_conv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 587ca16ba9d..fc26d04690d 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -509,7 +509,12 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert) if (cd_shape_keyindex_offset != -1) { BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset); - if ((keyi != ORIGINDEX_NONE) && (keyi < ototvert)) { + if ((keyi != ORIGINDEX_NONE) && + (keyi < ototvert) && + /* not fool-proof, but chances are if we have many verts with the same index, + * we will want to use the first one, since the second is more likely to be a duplicate. */ + (vertMap[keyi] == NULL)) + { vertMap[keyi] = eve; } }