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.
This commit is contained in:
@@ -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__ */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user