diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-07-02 12:11:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-07-02 12:12:54 +0300 |
commit | 945d0269e32efa1e5fd4091ae0f6366031f5ed04 (patch) | |
tree | e7b9d1b8c6ff3d2896af5c3c535025e7dcc6d60f | |
parent | 22197d7f8a26fb1284435f554fbc8bb4a1735f16 (diff) |
Fix crash calculating vertex parent in edit-mode
Regression in deaff945d0b96.
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2ddbdd02883..5dc7a06cd6b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2486,9 +2486,10 @@ static void give_parvert(Object *par, int nr, float vec[3]) if (me_eval) { int count = 0; - const int numVerts = me_eval->totvert; + int numVerts = me_eval->totvert; - if (em && me_eval->runtime.is_original) { + if (em && me_eval->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH) { + numVerts = em->bm->totvert; if (em->bm->elem_table_dirty & BM_VERT) { #ifdef VPARENT_THREADING_HACK BLI_mutex_lock(&vparent_lock); @@ -2501,10 +2502,18 @@ static void give_parvert(Object *par, int nr, float vec[3]) BM_mesh_elem_table_ensure(em->bm, BM_VERT); #endif } + if (nr < numVerts) { + if (me_eval && me_eval->runtime.edit_data && me_eval->runtime.edit_data->vertexCos) { + add_v3_v3(vec, me_eval->runtime.edit_data->vertexCos[nr]); + } + else { + const BMVert *v = BM_vert_at_index(em->bm, nr); + add_v3_v3(vec, v->co); + } + count++; + } } - - if (CustomData_has_layer(&me_eval->vdata, CD_ORIGINDEX) && - !(em && me_eval->runtime.is_original)) { + else if (CustomData_has_layer(&me_eval->vdata, CD_ORIGINDEX)) { const int *index = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); /* Get the average of all verts with (original index == nr). */ for (int i = 0; i < numVerts; i++) { |