diff options
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_bisect_plane.c | 7 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bisect_plane.c | 39 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bisect_plane.h | 2 |
4 files changed, 30 insertions, 20 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 0d0fdda2c4c..6b388a75436 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1284,7 +1284,7 @@ static BMOpDefine bmo_bisect_plane_def = { {"clear_inner", BMO_OP_SLOT_BOOL}, /* when enabled. remove all geometry on the negative side of the plane */ {{'\0'}}, }, - {{"geom_cut.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE}}, /* output new geometry from the cut */ + {{"geom_cut.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE}}, /* output geometry aligned with the plane (new and existing) */ {"geom.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input and output geometry (result of cut) */ {{'\0'}}}, bmo_bisect_plane_exec, diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c index bed1ea5cb94..2c80ff651b8 100644 --- a/source/blender/bmesh/operators/bmo_bisect_plane.c +++ b/source/blender/bmesh/operators/bmo_bisect_plane.c @@ -38,7 +38,8 @@ #include "intern/bmesh_operators_private.h" /* own include */ #define ELE_NEW 1 -#define ELE_INPUT 2 +#define ELE_CUT 2 +#define ELE_INPUT 4 void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op) { @@ -69,7 +70,7 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op) BM_mesh_bisect_plane(bm, plane, use_snap_center, true, - ELE_NEW, dist); + ELE_CUT, ELE_NEW, dist); if (clear_outer || clear_inner) { @@ -108,5 +109,5 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op) } BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL_NOLOOP, ELE_NEW | ELE_INPUT); - BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_cut.out", BM_VERT | BM_EDGE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_cut.out", BM_VERT | BM_EDGE, ELE_CUT); } diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index 51b92a3c45e..828c50c39fd 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -110,7 +110,7 @@ static int bm_vert_sortval_cb(const void *v_a_v, const void *v_b_v) } -static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], const short oflag_center) +static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], const short oflag_center, const short oflag_new) { /* unlikely more than 2 verts are needed */ const unsigned int f_len_orig = (unsigned int)f->len; @@ -154,10 +154,11 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con /* common case, just cut the face once */ BM_face_split(bm, f, l_a, l_b, &l_new, NULL, true); if (l_new) { - if (oflag_center) { - BMO_edge_flag_enable(bm, l_new->e, oflag_center); - BMO_face_flag_enable(bm, l_new->f, oflag_center); - BMO_face_flag_enable(bm, f, oflag_center); + if (oflag_center | oflag_new) { + BMO_edge_flag_enable(bm, l_new->e, oflag_center | oflag_new); + } + if (oflag_new) { + BMO_face_flag_enable(bm, l_new->f, oflag_new); } } } @@ -269,10 +270,11 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con f_tmp = BM_face_split(bm, face_split_arr[j], l_a, l_b, &l_new, NULL, true); if (l_new) { - if (oflag_center) { - BMO_edge_flag_enable(bm, l_new->e, oflag_center); - BMO_face_flag_enable(bm, l_new->f, oflag_center); - BMO_face_flag_enable(bm, face_split_arr[j], oflag_center); + if (oflag_center | oflag_new) { + BMO_edge_flag_enable(bm, l_new->e, oflag_center | oflag_new); + } + if (oflag_new) { + BMO_face_flag_enable(bm, l_new->f, oflag_new); } } @@ -307,7 +309,7 @@ finally: void BM_mesh_bisect_plane( BMesh *bm, const float plane[4], const bool use_snap_center, const bool use_tag, - const short oflag_center, const float eps) + const short oflag_center, const short oflag_new, const float eps) { unsigned int einput_len; unsigned int i; @@ -390,7 +392,7 @@ void BM_mesh_bisect_plane( const float dist[2] = {BM_VERT_DIST(e->v1), BM_VERT_DIST(e->v2)}; if (side[0] && side[1] && (side[0] != side[1])) { - const float e_fac = fabsf(dist[0]) / fabsf(dist[0] - dist[1]); + const float e_fac = dist[0] / (dist[0] - dist[1]); BMVert *v_new; if (e->l) { @@ -404,10 +406,17 @@ void BM_mesh_bisect_plane( } while ((l_iter = l_iter->radial_next) != l_first); } - v_new = BM_edge_split(bm, e, e->v1, NULL, e_fac); + { + BMEdge *e_new; + v_new = BM_edge_split(bm, e, e->v1, &e_new, e_fac); + if (oflag_new) { + BMO_edge_flag_enable(bm, e_new, oflag_new); + } + } + vert_is_center_enable(v_new); - if (oflag_center) { - BMO_vert_flag_enable(bm, v_new, oflag_center); + if (oflag_new | oflag_center) { + BMO_vert_flag_enable(bm, v_new, oflag_new | oflag_center); } BM_VERT_DIR(v_new) = 0; @@ -448,7 +457,7 @@ void BM_mesh_bisect_plane( MEM_freeN(edges_arr); while ((f = BLI_LINKSTACK_POP(face_stack))) { - bm_face_bisect_verts(bm, f, plane, oflag_center); + bm_face_bisect_verts(bm, f, plane, oflag_center, oflag_new); } /* now we have all faces to split in the stack */ diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.h b/source/blender/bmesh/tools/bmesh_bisect_plane.h index 7f3a97c4c79..fb99a1c8214 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.h +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.h @@ -30,6 +30,6 @@ void BM_mesh_bisect_plane( BMesh *bm, const float plane[4], const bool use_snap_center, const bool use_tag, - const short oflag_center, const float eps); + const short oflag_center, const short oflag_new, const float eps); #endif /* __BMESH_BISECT_PLANE_H__ */ |