diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-15 07:31:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-15 07:31:17 +0300 |
commit | 62a3dfec78ca9691b6f93a0017171045440c40a7 (patch) | |
tree | 47ba937ed98400c8ea26de6508576d794a1bda65 /source/blender | |
parent | 5b86899f21d61197acbc4e25ee54e03688803093 (diff) |
Mesh: mostly remove DerivedMesh for vertex parent
The exception is for subdivision surface which still uses derived mesh.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index cd564238a20..1ff15ed19d5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2050,22 +2050,23 @@ static void give_parvert(Object *par, int nr, float vec[3]) if (par->type == OB_MESH) { Mesh *me = par->data; BMEditMesh *em = me->edit_btmesh; - DerivedMesh *dm; + DerivedMesh *dm = NULL; + Mesh *me_eval = (em) ? em->mesh_eval_final : par->runtime.mesh_eval; -#if 0 /* FIXME(campbell): use mesh for both. */ - dm = (em) ? em->derivedFinal : par->derivedFinal; -#else + /* Keep this until subsurf code ported away from derived mesh - campbell. */ dm = par->derivedFinal; -#endif + if (dm && dm->type != DM_TYPE_CCGDM) { + dm = NULL; + } - if (dm) { + if (me_eval) { int count = 0; - int numVerts = dm->getNumVerts(dm); + const int numVerts = me_eval->totvert; if (nr < numVerts) { bool use_special_ss_case = false; - if (dm->type == DM_TYPE_CCGDM) { + if (dm && dm->type == DM_TYPE_CCGDM) { ModifierData *md; VirtualModifierData virtualModifierData; use_special_ss_case = true; @@ -2084,7 +2085,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) if (!use_special_ss_case) { /* avoid dm->getVertDataArray() since it allocates arrays in the dm (not thread safe) */ - if (em && dm->type == DM_TYPE_EDITBMESH) { + if (em && me_eval->runtime.is_original) { if (em->bm->elem_table_dirty & BM_VERT) { #ifdef VPARENT_THREADING_HACK BLI_mutex_lock(&vparent_lock); @@ -2111,27 +2112,21 @@ static void give_parvert(Object *par, int nr, float vec[3]) count++; } } - else if (CustomData_has_layer(&dm->vertData, CD_ORIGINDEX) && - !(em && dm->type == DM_TYPE_EDITBMESH)) + else if (CustomData_has_layer(&me_eval->vdata, CD_ORIGINDEX) && + !(em && me_eval->runtime.is_original)) { - int i; - + const int *index = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); /* Get the average of all verts with (original index == nr). */ - for (i = 0; i < numVerts; i++) { - const int *index = dm->getVertData(dm, i, CD_ORIGINDEX); - if (*index == nr) { - float co[3]; - dm->getVertCo(dm, i, co); - add_v3_v3(vec, co); + for (int i = 0; i < numVerts; i++) { + if (index[i] == nr) { + add_v3_v3(vec, me_eval->mvert[i].co); count++; } } } else { if (nr < numVerts) { - float co[3]; - dm->getVertCo(dm, nr, co); - add_v3_v3(vec, co); + add_v3_v3(vec, me_eval->mvert[nr].co); count++; } } @@ -2145,7 +2140,9 @@ static void give_parvert(Object *par, int nr, float vec[3]) } else { /* use first index if its out of range */ - dm->getVertCo(dm, 0, vec); + if (me_eval->totvert) { + copy_v3_v3(vec, me_eval->mvert[0].co); + } } } else { |