From 23b7f351aaf077cc4464429a3879fe13809b4a74 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 31 Oct 2014 20:15:32 +0100 Subject: Optimize vertex parent for edit mode without modifiers No need to run lookup on the origindex in this case at all. --- source/blender/blenkernel/intern/object.c | 41 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 82bcbaff31a..72f7d54b555 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2154,25 +2154,8 @@ static void give_parvert(Object *par, int nr, float vec[3]) int numVerts = dm->getNumVerts(dm); if (nr < numVerts) { - /* avoid dm->getVertDataArray() since it allocates arrays in the dm (not thread safe) */ - int i; bool use_special_ss_case = false; - if (em && dm->type == DM_TYPE_EDITBMESH) { - if (em->bm->elem_table_dirty & BM_VERT) { -#ifdef VPARENT_THREADING_HACK - BLI_mutex_lock(&vparent_lock); - if (em->bm->elem_table_dirty & BM_VERT) { - BM_mesh_elem_table_ensure(em->bm, BM_VERT); - } - BLI_mutex_unlock(&vparent_lock); -#else - BLI_assert(!"Not safe for threading"); - BM_mesh_elem_table_ensure(em->bm, BM_VERT); -#endif - } - } - if (dm->type == DM_TYPE_CCGDM) { ModifierData *md; VirtualModifierData virtualModifierData; @@ -2190,6 +2173,24 @@ 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->bm->elem_table_dirty & BM_VERT) { +#ifdef VPARENT_THREADING_HACK + BLI_mutex_lock(&vparent_lock); + if (em->bm->elem_table_dirty & BM_VERT) { + BM_mesh_elem_table_ensure(em->bm, BM_VERT); + } + BLI_mutex_unlock(&vparent_lock); +#else + BLI_assert(!"Not safe for threading"); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); +#endif + } + } + } + if (use_special_ss_case) { /* Special case if the last modifier is SS and no constructive modifier * are in front of it. @@ -2200,7 +2201,11 @@ static void give_parvert(Object *par, int nr, float vec[3]) add_v3_v3(vec, co); count++; } - else if (CustomData_has_layer(&dm->vertData, CD_ORIGINDEX)) { + else if (CustomData_has_layer(&dm->vertData, CD_ORIGINDEX) && + !(em && dm->type == DM_TYPE_EDITBMESH)) + { + int i; + /* 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); -- cgit v1.2.3