diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-07 06:20:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-07 06:27:59 +0300 |
commit | e95c0fba095dfac38b33b5ad7db36316093e2acf (patch) | |
tree | 37e8171c9d4999054bea91658966941b4b22f78b /source/blender | |
parent | 6e39aeb2cd805cdc9ddd838b8b27a4287800236b (diff) |
BMesh: remove BMEditMesh.ob use BKE_editmesh_lnorspace_* API
Note that this is a bit clumsy having both edit-mesh and mesh,
BKE_editmesh_ensure_autosmooth & BKE_editmesh_lnorspace_update
are often called together, these could be made into a single functions.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_editmesh.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editmesh.c | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 26 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 6 |
4 files changed, 21 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h index 3f9206ac9f8..7c44428dac8 100644 --- a/source/blender/blenkernel/BKE_editmesh.h +++ b/source/blender/blenkernel/BKE_editmesh.h @@ -98,8 +98,8 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph, 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); +void BKE_editmesh_lnorspace_update(BMEditMesh *em, struct Mesh *me); +void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, struct Mesh *me); struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em); #endif /* __BKE_EDITMESH_H__ */ diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index d7c52fc16ae..9b67a4fb925 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -226,7 +226,7 @@ float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3] return BM_mesh_vert_coords_alloc(em->bm, r_vert_len); } -void BKE_editmesh_lnorspace_update(BMEditMesh *em) +void BKE_editmesh_lnorspace_update(BMEditMesh *em, Mesh *me) { BMesh *bm = em->bm; @@ -238,7 +238,6 @@ void BKE_editmesh_lnorspace_update(BMEditMesh *em) * with related sharp edges (and hence autosmooth is 'lost'). * Not sure how critical this is, and how to fix that issue? */ if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL)) { - Mesh *me = em->ob->data; if (me->flag & ME_AUTOSMOOTH) { BM_edges_sharp_from_angle_set(bm, me->smoothresh); } @@ -248,12 +247,11 @@ void BKE_editmesh_lnorspace_update(BMEditMesh *em) } /* If autosmooth not already set, set it */ -void BKE_editmesh_ensure_autosmooth(BMEditMesh *em) +void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, Mesh *me) { - Mesh *me = em->ob->data; if (!(me->flag & ME_AUTOSMOOTH)) { me->flag |= ME_AUTOSMOOTH; - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_lnorspace_update(em, me); } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a795966693f..54605f4cb68 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -7726,8 +7726,8 @@ static int point_normals_init(bContext *C, wmOperator *op, const wmEvent *UNUSED BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; - BKE_editmesh_ensure_autosmooth(em); - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_ensure_autosmooth(em, obedit->data); + BKE_editmesh_lnorspace_update(em, obedit->data); BMLoopNorEditDataArray *lnors_ed_arr = BM_loop_normal_editdata_array_init(bm, false); op->customdata = lnors_ed_arr; @@ -8293,8 +8293,8 @@ static int normals_split_merge(bContext *C, const bool do_merge) BMEdge *e; BMIter eiter; - BKE_editmesh_ensure_autosmooth(em); - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_ensure_autosmooth(em, obedit->data); + BKE_editmesh_lnorspace_update(em, obedit->data); /* Note that we need temp lnor editing data for all loops of all affected vertices, since by * setting some faces/edges as smooth we are going to change clnors spaces... See also T65809. @@ -8312,7 +8312,7 @@ static int normals_split_merge(bContext *C, const bool do_merge) } bm->spacearr_dirty |= BM_SPACEARR_DIRTY_ALL; - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_lnorspace_update(em, obedit->data); if (do_merge) { normals_merge(bm, lnors_ed_arr); @@ -8417,9 +8417,9 @@ static int edbm_average_normals_exec(bContext *C, wmOperator *op) BMLoop *l, *l_curr, *l_first; BMIter fiter; - BKE_editmesh_ensure_autosmooth(em); + BKE_editmesh_ensure_autosmooth(em, obedit->data); bm->spacearr_dirty |= BM_SPACEARR_DIRTY_ALL; - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_lnorspace_update(em, obedit->data); const int cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL); @@ -8656,8 +8656,8 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op) continue; } - BKE_editmesh_ensure_autosmooth(em); - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_ensure_autosmooth(em, obedit->data); + BKE_editmesh_lnorspace_update(em, obedit->data); BMLoopNorEditDataArray *lnors_ed_arr = BM_loop_normal_editdata_array_init(bm, false); BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata; @@ -8862,8 +8862,8 @@ static int edbm_set_normals_from_faces_exec(bContext *C, wmOperator *op) const bool keep_sharp = RNA_boolean_get(op->ptr, "keep_sharp"); - BKE_editmesh_ensure_autosmooth(em); - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_ensure_autosmooth(em, obedit->data); + BKE_editmesh_lnorspace_update(em, obedit->data); float(*vnors)[3] = MEM_callocN(sizeof(*vnors) * bm->totvert, __func__); BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { @@ -8965,8 +8965,8 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op) BMLoop *l; BMIter fiter, liter; - BKE_editmesh_ensure_autosmooth(em); - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_ensure_autosmooth(em, obedit->data); + BKE_editmesh_lnorspace_update(em, obedit->data); BMLoopNorEditDataArray *lnors_ed_arr = BM_loop_normal_editdata_array_init(bm, false); float(*smooth_normal)[3] = MEM_callocN(sizeof(*smooth_normal) * lnors_ed_arr->totloop, diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7112444655b..9a98a2b8a00 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2479,7 +2479,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve else if (!do_skip) { const bool preserve_clnor = RNA_property_boolean_get(op->ptr, prop); if (preserve_clnor) { - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_lnorspace_update(em, tc->obedit->data); t->flag |= T_CLNOR_REBUILD; } BM_lnorspace_invalidate(em->bm, true); @@ -4657,8 +4657,8 @@ static void initNormalRotation(TransInfo *t) BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); BMesh *bm = em->bm; - BKE_editmesh_ensure_autosmooth(em); - BKE_editmesh_lnorspace_update(em); + BKE_editmesh_ensure_autosmooth(em, tc->obedit->data); + BKE_editmesh_lnorspace_update(em, tc->obedit->data); storeCustomLNorValue(tc, bm); } |