forked from bartvdbraak/blender
Fix T50920: Adds missing edges on return of bisect operator
This commit is contained in:
parent
f169ff8b88
commit
2b3cc24388
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user