BMesh: remove BMEditMesh.ob use for vert coord access, projection
authorCampbell Barton <ideasman42@gmail.com>
Tue, 7 Jan 2020 02:49:10 +0000 (13:49 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 7 Jan 2020 02:53:03 +0000 (13:53 +1100)
source/blender/blenkernel/BKE_editmesh.h
source/blender/blenkernel/intern/editmesh.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/mesh/editmesh_extrude.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_tools.c

index 7c27362e24447a2c7b72a90b5cbafe2c1fbc8e49..3f9206ac9f81051709e1280dec2a9f3d1727831c 100644 (file)
@@ -92,8 +92,11 @@ BMEditMesh *BKE_editmesh_from_object(struct Object *ob);
 void BKE_editmesh_free_derivedmesh(BMEditMesh *em);
 void BKE_editmesh_free(BMEditMesh *em);
 
-float (*BKE_editmesh_vert_coords_alloc(
-    struct Depsgraph *depsgraph, struct BMEditMesh *em, struct Scene *scene, int *r_vert_len))[3];
+float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph,
+                                       struct BMEditMesh *em,
+                                       struct Scene *scene,
+                                       struct Object *ob,
+                                       int *r_vert_len))[3];
 float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3];
 void BKE_editmesh_lnorspace_update(BMEditMesh *em);
 void BKE_editmesh_ensure_autosmooth(BMEditMesh *em);
index 1065f11a52143e4c0b6ebd5a6701706bd4ea2cc8..d7c52fc16aeba3ddf104a4b29fdc47224daa8332 100644 (file)
@@ -188,15 +188,18 @@ static void cage_mapped_verts_callback(void *userData,
   }
 }
 
-float (*BKE_editmesh_vert_coords_alloc(
-    struct Depsgraph *depsgraph, BMEditMesh *em, struct Scene *scene, int *r_vert_len))[3]
+float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph,
+                                       BMEditMesh *em,
+                                       struct Scene *scene,
+                                       Object *ob,
+                                       int *r_vert_len))[3]
 {
   Mesh *cage;
   BLI_bitmap *visit_bitmap;
   struct CageUserData data;
   float(*cos_cage)[3];
 
-  cage = editbmesh_get_eval_cage(depsgraph, scene, em->ob, em, &CD_MASK_BAREMESH);
+  cage = editbmesh_get_eval_cage(depsgraph, scene, ob, em, &CD_MASK_BAREMESH);
   cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
 
   /* when initializing cage verts, we only want the first cage coordinate for each vertex,
index 246dba57bb510d56f26e32df423b9b49ae6b281f..e398e5def9e80fe876205446ef0bc76706ae8fb9 100644 (file)
@@ -295,6 +295,7 @@ void ED_keymap_mesh(struct wmKeyConfig *keyconf);
 void EDBM_project_snap_verts(struct bContext *C,
                              struct Depsgraph *depsgraph,
                              struct ARegion *ar,
+                             struct Object *obedit,
                              struct BMEditMesh *em);
 
 /* editface.c */
index c1c8a20847117fa40ec9642c9de9fcfcc4d394c3..5496362024d1a8c032b51bb8fd5f25daf5ab7d26 100644 (file)
@@ -820,7 +820,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
 
         /* also project the source, for retopo workflow */
         if (use_proj) {
-          EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em);
+          EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.obedit, vc.em);
         }
       }
 
@@ -853,7 +853,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
     }
 
     if (use_proj) {
-      EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em);
+      EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.obedit, vc.em);
     }
 
     /* This normally happens when pushing undo but modal operators
index 4c4aa4214b26a713ccc0c178c6c4c712369c6181..1b6827dac872567c1283cef449e191678094bccb 100644 (file)
@@ -2658,11 +2658,11 @@ static void knifetool_init_bmbvh(KnifeTool_OpData *kcd)
   BM_mesh_elem_index_ensure(kcd->em->bm, BM_VERT);
 
   Scene *scene_eval = (Scene *)DEG_get_evaluated_id(kcd->vc.depsgraph, &kcd->scene->id);
-  Object *obedit_eval = (Object *)DEG_get_evaluated_id(kcd->vc.depsgraph, &kcd->em->ob->id);
+  Object *obedit_eval = (Object *)DEG_get_evaluated_id(kcd->vc.depsgraph, &kcd->ob->id);
   BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
 
   kcd->cagecos = (const float(*)[3])BKE_editmesh_vert_coords_alloc(
-      kcd->vc.depsgraph, em_eval, scene_eval, NULL);
+      kcd->vc.depsgraph, em_eval, scene_eval, obedit_eval, NULL);
 
   kcd->bmbvh = BKE_bmbvh_new_from_editmesh(
       kcd->em,
index abc0d258e551df73646f6363ac4413283ddb28a0..a795966693f8b06382ae5afcb4b806662c3255f0 100644 (file)
@@ -411,10 +411,10 @@ void MESH_OT_unsubdivide(wmOperatorType *ot)
       ot->srna, "iterations", 2, 1, 1000, "Iterations", "Number of times to unsubdivide", 1, 100);
 }
 
-void EDBM_project_snap_verts(bContext *C, Depsgraph *depsgraph, ARegion *ar, BMEditMesh *em)
+void EDBM_project_snap_verts(
+    bContext *C, Depsgraph *depsgraph, ARegion *ar, Object *obedit, BMEditMesh *em)
 {
   Main *bmain = CTX_data_main(C);
-  Object *obedit = em->ob;
   BMIter iter;
   BMVert *eve;