[Bf-blender-cvs] [8004214356a] blender-v3.3-release: Fix T99141: Crash with edit mode and copy location constraint

Sonny Campbell noreply at git.blender.org
Wed Sep 21 14:27:08 CEST 2022


Commit: 8004214356a4882606d92758f33954e5973fc591
Author: Sonny Campbell
Date:   Tue Sep 6 13:09:01 2022 -0500
Branches: blender-v3.3-release
https://developer.blender.org/rB8004214356a4882606d92758f33954e5973fc591

Fix T99141: Crash with edit mode and copy location constraint

The constraint attempted to access mesh normals on a mesh with
wrapper type ME_WRAPPER_TYPE_BMESH. This commit reverses the if
statements so that If there is an editmesh then we use that as the
source of truth - otherwise use the evaluated mesh.

Differential Revision: https://developer.blender.org/D15809

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

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

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

diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 9f1d2d7bbb2..e2874f1a1c6 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -528,7 +528,24 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
   float vec[3] = {0.0f, 0.0f, 0.0f};
   float normal[3] = {0.0f, 0.0f, 0.0f};
   float weightsum = 0.0f;
-  if (me_eval) {
+  if (em) {
+    if (CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
+      BMVert *v;
+      BMIter iter;
+
+      BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+        MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, v->head.data, CD_MDEFORMVERT);
+        MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
+
+        if (dw && dw->weight > 0.0f) {
+          madd_v3_v3fl(vec, v->co, dw->weight);
+          madd_v3_v3fl(normal, v->no, dw->weight);
+          weightsum += dw->weight;
+        }
+      }
+    }
+  }
+  else if (me_eval) {
     const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(me_eval);
     const MDeformVert *dvert = CustomData_get_layer(&me_eval->vdata, CD_MDEFORMVERT);
     int numVerts = me_eval->totvert;
@@ -550,23 +567,6 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
       }
     }
   }
-  else if (em) {
-    if (CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
-      BMVert *v;
-      BMIter iter;
-
-      BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
-        MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, v->head.data, CD_MDEFORMVERT);
-        MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
-
-        if (dw && dw->weight > 0.0f) {
-          madd_v3_v3fl(vec, v->co, dw->weight);
-          madd_v3_v3fl(normal, v->no, dw->weight);
-          weightsum += dw->weight;
-        }
-      }
-    }
-  }
   else {
     /* No valid edit or evaluated mesh, just abort. */
     return;



More information about the Bf-blender-cvs mailing list