[Bf-blender-cvs] [5168408ae50] blender-v2.82-release: Fix T72459: Mask Modifier breaks Vertex Parenting

Sybren A. Stüvel noreply at git.blender.org
Tue Jan 21 17:58:02 CET 2020


Commit: 5168408ae50a052d2a9fa795ebdb18820d5b1d67
Author: Sybren A. Stüvel
Date:   Tue Jan 21 17:52:44 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB5168408ae50a052d2a9fa795ebdb18820d5b1d67

Fix T72459: Mask Modifier breaks Vertex Parenting

The `give_parvert()` function was only considering the mesh's original
vertex indices when the parent vertex index was valid for the evaluated
mesh. However, when using the Mask modifier the evaluated mesh can have
less vertices but still have the parent vertex.

Since the `if (nr < numVertex)` condition wasn't used to prevent any
out-of-bounds access, and seems just an incorrect optimisation, it could
be removed.

===================================================================

M	source/blender/blenkernel/intern/object.c

===================================================================

diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1378e862034..da3986d33df 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2330,40 +2330,38 @@ static void give_parvert(Object *par, int nr, float vec[3])
       int count = 0;
       const int numVerts = me_eval->totvert;
 
-      if (nr < numVerts) {
-        if (em && me_eval->runtime.is_original) {
-          if (em->bm->elem_table_dirty & BM_VERT) {
+      if (em && me_eval->runtime.is_original) {
+        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");
+          BLI_mutex_lock(&vparent_lock);
+          if (em->bm->elem_table_dirty & BM_VERT) {
             BM_mesh_elem_table_ensure(em->bm, BM_VERT);
-#endif
           }
+          BLI_mutex_unlock(&vparent_lock);
+#else
+          BLI_assert(!"Not safe for threading");
+          BM_mesh_elem_table_ensure(em->bm, BM_VERT);
+#endif
         }
+      }
 
-        if (CustomData_has_layer(&me_eval->vdata, CD_ORIGINDEX) &&
-            !(em && me_eval->runtime.is_original)) {
-          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++) {
-            if (index[i] == nr) {
-              add_v3_v3(vec, me_eval->mvert[i].co);
-              count++;
-            }
-          }
-        }
-        else {
-          if (nr < numVerts) {
-            add_v3_v3(vec, me_eval->mvert[nr].co);
+      if (CustomData_has_layer(&me_eval->vdata, CD_ORIGINDEX) &&
+          !(em && me_eval->runtime.is_original)) {
+        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++) {
+          if (index[i] == nr) {
+            add_v3_v3(vec, me_eval->mvert[i].co);
             count++;
           }
         }
       }
+      else {
+        if (nr < numVerts) {
+          add_v3_v3(vec, me_eval->mvert[nr].co);
+          count++;
+        }
+      }
 
       if (count == 0) {
         /* keep as 0, 0, 0 */



More information about the Bf-blender-cvs mailing list