edge rotate now keeps edge properties (like seam, crease, bevel weight.. etc)

This commit is contained in:
Campbell Barton
2012-03-05 01:53:30 +00:00
parent 4d84e869a0
commit 4b940364a1
9 changed files with 50 additions and 41 deletions

View File

@@ -858,6 +858,8 @@ static int disk_is_flagged(BMVert *v, int flag)
* Joins a collected group of faces into one. Only restriction on
* the input data is that the faces must be connected to each other.
*
* \param do_clear Remove the edges and verts shared by faces when joining.
*
* \return The newly created combine BMFace.
*
* \note If a pair of faces share multiple edges,
@@ -866,7 +868,8 @@ static int disk_is_flagged(BMVert *v, int flag)
* \note this is a generic, flexible join faces function,
* almost everything uses this, including #BM_faces_join_pair
*/
BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface,
const short do_del)
{
BMFace *f, *newf;
#ifdef USE_BMESH_HOLES
@@ -955,7 +958,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
}
/* create region fac */
/* create region face */
newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE);
if (!newf || BMO_error_occurred(bm)) {
if (!BMO_error_occurred(bm))
@@ -1020,12 +1023,14 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
}
/* delete old geometr */
for (i = 0; i < BLI_array_count(deledges); i++) {
BM_edge_kill(bm, deledges[i]);
}
if (do_del) {
for (i = 0; i < BLI_array_count(deledges); i++) {
BM_edge_kill(bm, deledges[i]);
}
for (i = 0; i < BLI_array_count(delverts); i++) {
BM_vert_kill(bm, delverts[i]);
for (i = 0; i < BLI_array_count(delverts); i++) {
BM_vert_kill(bm, delverts[i]);
}
}
BLI_array_free(edges);
@@ -1034,6 +1039,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
BM_CHECK_ELEMENT(bm, newf);
return newf;
error:
bm_elements_systag_disable(bm, faces, totface, _FLAG_JF);
BLI_array_free(edges);

View File

@@ -44,7 +44,8 @@ int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget);
int bmesh_loop_reverse(BMesh *bm, BMFace *f);
BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface);
BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface,
const short do_del);
/* EULER API - For modifying structure */
BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1,

View File

@@ -147,7 +147,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
f = e->l->f;
f2 = e->l->radial_next->f;
if (f != f2 && !BM_faces_join_pair(bm, f, f2, e)) {
if (f != f2 && !BM_faces_join_pair(bm, f, f2, e, TRUE)) {
return FALSE;
}
@@ -164,7 +164,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
f = NULL;
len = bmesh_radial_length(e->l);
if (len == 2 && (e != baseedge) && (e != keepedge)) {
f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e);
f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE);
/* return if couldn't join faces in manifold
* conditions */
//!disabled for testing why bad things happen
@@ -194,7 +194,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
if (f != f2) {
/* join two remaining face */
if (!BM_faces_join_pair(bm, f, f2, e)) {
if (!BM_faces_join_pair(bm, f, f2, e, TRUE)) {
return FALSE;
}
}
@@ -219,7 +219,8 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
* \return pointer to the combined face
*/
BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e,
const short do_del)
{
BMLoop *l1, *l2;
BMEdge *jed = NULL;
@@ -255,7 +256,7 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
bmesh_loop_reverse(bm, f2);
}
f1 = BM_faces_join(bm, faces, 2);
f1 = BM_faces_join(bm, faces, 2, do_del);
return f1;
}
@@ -448,7 +449,7 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
}
if (BLI_array_count(faces) >= 2) {
BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces));
BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces), TRUE);
if (f2) {
BMLoop *nl = NULL;
if (BM_face_split(bm, f2, tv, tv2, &nl, NULL)) {
@@ -961,8 +962,11 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_
/* rotate the edge */
f = BM_faces_join_pair(bm, l1->f, l2->f, e);
/* --------------- */
/* Rotate The Edge */
/* don't delete the edge, manually remove the egde after so we can copy its attributes */
f = BM_faces_join_pair(bm, l1->f, l2->f, e, FALSE);
if (f == NULL) {
return NULL;
@@ -972,9 +976,12 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_
* the #BM_edge_rotate_check will ensure this, but its possibly corrupt state or future edits
* break this */
if (!BM_face_split(bm, f, v1, v2, &nl, NULL))
if (!BM_face_split(bm, f, v1, v2, &nl, e))
return NULL;
/* edge has done its job as an example, now remove */
BM_edge_kill(bm, e);
/* replace existing edge (kill e_splice) */
if (e_splice) {
BM_edge_splice(bm, e_splice, nl->e);

View File

@@ -33,7 +33,8 @@ int BM_vert_dissolve(BMesh *bm, BMVert *v);
int BM_disk_dissolve(BMesh *bm, BMVert *v);
BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e);
BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e,
const short do_del);
BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f);

View File

@@ -144,7 +144,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
while (faces[tot])
tot++;
f = BM_faces_join(bm, faces, tot);
f = BM_faces_join(bm, faces, tot, TRUE);
if (!f) {
BMO_error_raise(bm, op, BMERR_DISSOLVEFACES_FAILED,
"Could not create merged face");
@@ -198,17 +198,16 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op)
BMVert *v, **verts = NULL;
BLI_array_declare(verts);
BMEdge *e;
/* BMFace *f; */
BMFace *fa, *fb;
int i;
BMO_ITER(e, &oiter, bm, op, "edges", BM_EDGE) {
if (BM_edge_face_count(e) == 2) {
if (BM_edge_face_pair(e, &fa, &fb)) {
BMO_elem_flag_enable(bm, e->v1, VERT_MARK);
BMO_elem_flag_enable(bm, e->v2, VERT_MARK);
BM_faces_join_pair(bm, e->l->f,
e->l->radial_next->f,
e);
BM_faces_join_pair(bm, fa, fb, e, TRUE);
}
}
@@ -256,13 +255,12 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
}
BMO_ITER(e, &eiter, bm, op, "edges", BM_EDGE) {
const int edge_face_count = BM_edge_face_count(e);
if (edge_face_count == 2) {
BMFace *fa, *fb;
if (BM_edge_face_pair(e, &fa, &fb)) {
/* join faces */
BM_faces_join_pair(bm, e->l->f,
e->l->radial_next->f,
e);
BM_faces_join_pair(bm, fa, fb, e, TRUE);
}
}
@@ -517,7 +515,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
if (BM_edge_face_angle(bm, e) < angle_limit) {
BMFace *nf = BM_faces_join_pair(bm, e->l->f,
e->l->radial_next->f,
e); /* join faces */
e, TRUE); /* join faces */
/* there may be some errors, we dont mind, just move on */
if (nf == NULL) {

View File

@@ -251,14 +251,11 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
continue;
if (BM_edge_face_count(e) != 2) {
if (!BM_edge_face_pair(e, &f1, &f2)) {
BMO_elem_flag_disable(bm, e, EDGE_MARK);
continue;
}
f1 = e->l->f;
f2 = e->l->radial_next->f;
if (f1->len != 3 || f2->len != 3) {
BMO_elem_flag_disable(bm, e, EDGE_MARK);
continue;
@@ -332,10 +329,9 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
if (!BMO_elem_flag_test(bm, e, EDGE_CHOSEN))
continue;
f1 = e->l->f;
f2 = e->l->radial_next->f;
BM_faces_join_pair(bm, f1, f2, e);
BM_edge_face_pair(e, &f1, &f2); /* checked above */
BM_faces_join_pair(bm, f1, f2, e, TRUE);
}
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
@@ -367,7 +363,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
continue;
}
BM_faces_join_pair(bm, f1, f2, e);
BM_faces_join_pair(bm, f1, f2, e, TRUE);
}
}

View File

@@ -965,7 +965,7 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option
/* get rid of beveled edge */
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
if(BMO_elem_flag_test(bm, e, BME_BEVEL_BEVEL) && BMO_elem_flag_test(bm, e, BME_BEVEL_ORIG)) {
BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e);
BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE);
}
}

View File

@@ -1671,7 +1671,7 @@ static void remerge_faces(knifetool_opdata *kcd)
if (BLI_array_count(faces) > 0) {
idx = BM_elem_index_get(faces[0]);
f2 = BM_faces_join(bm, faces, BLI_array_count(faces));
f2 = BM_faces_join(bm, faces, BLI_array_count(faces), TRUE);
if (f2) {
BMO_elem_flag_enable(bm, f2, FACE_NEW);
BM_elem_index_set(f2, idx); /* set_dirty! */ /* BMESH_TODO, check if this is valid or not */

View File

@@ -406,7 +406,7 @@ static PyObject *bpy_bm_utils_face_join(PyObject *UNUSED(self), PyObject *value)
/* Go ahead and join the face!
* --------------------------- */
f_new = BM_faces_join(bm, face_array, (int)face_seq_len);
f_new = BM_faces_join(bm, face_array, (int)face_seq_len, TRUE); /* BMESH_TODO, make optional */
if (f_new) {
return BPy_BMFace_CreatePyObject(bm, f_new);