diff options
Diffstat (limited to 'source/blender/bmesh/operators/bmo_subdivide.c')
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index f97f5225169..03f9fe04394 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -104,6 +104,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar BM_vert_normal_update_all(bm, v); co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, params->origkey); + copy_v3_v3(co, v->co); copy_v3_v3(prev_co, co); if (params->beauty & B_SMOOTH) { @@ -153,7 +154,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar mul_v3_v3(vec2, tvec); - /* add displacemen */ + /* add displacement */ add_v3_v3v3(co, co, vec2); } @@ -205,6 +206,9 @@ static BMVert *bm_subdivide_edge_addvert(BMesh *bm, BMEdge *edge, BMEdge *oedge, } #endif + interp_v3_v3v3(ev->no, vsta->no, vend->no, percent2); + normalize_v3(ev->no); + return ev; } @@ -276,7 +280,7 @@ static void quad_1edge_split(BMesh *bm, BMFace *UNUSED(face), BMFace *nf; int i, add, numcuts = params->numcuts; - /* if it's odd, the middle face is a quad, otherwise it's a triangl */ + /* if it's odd, the middle face is a quad, otherwise it's a triangle */ if ((numcuts % 2) == 0) { add = 2; for (i = 0; i < numcuts; i++) { @@ -730,7 +734,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) patterns[5] = NULL; } - /* add a temporary shapekey layer to store displacements on current geometr */ + /* add a temporary shapekey layer to store displacements on current geometry */ BM_data_layer_add(bmesh, &bmesh->vdata, CD_SHAPEKEY); skey = CustomData_number_of_layers(&bmesh->vdata, CD_SHAPEKEY) - 1; @@ -739,8 +743,8 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) copy_v3_v3(co, v->co); } - /* first go through and tag edge */ - BMO_slot_buffer_from_flag(bmesh, op, "edges", BM_EDGE, SUBD_SPLIT); + /* first go through and tag edges */ + BMO_slot_buffer_from_enabled_flag(bmesh, op, "edges", BM_EDGE, SUBD_SPLIT); params.numcuts = numcuts; params.op = op; @@ -766,7 +770,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) BMEdge *e1 = NULL, *e2 = NULL; float vec1[3], vec2[3]; - /* figure out which pattern to us */ + /* figure out which pattern to use */ BLI_array_empty(edges); BLI_array_empty(verts); @@ -790,7 +794,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) i++; } - /* make sure the two edges have a valid angle to each othe */ + /* make sure the two edges have a valid angle to each other */ if (totesel == 2 && BM_edge_share_vert_count(e1, e2)) { float angle; @@ -830,7 +834,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) } } - /* obvously don't test for other patterns matchin */ + /* obvously don't test for other patterns matching */ continue; } @@ -882,17 +886,23 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) einput = BMO_slot_get(op, "edges"); - /* go through and split edge */ + /* go through and split edges */ for (i = 0; i < einput->len; i++) { edge = ((BMEdge **)einput->data.p)[i]; bm_subdivide_multicut(bmesh, edge, ¶ms, edge->v1, edge->v2); } + /* copy original-geometry displacements to current coordinates */ + BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) { + float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey); + copy_v3_v3(v->co, co); + } + i = 0; for (i = 0; i < BLI_array_count(facedata); i++) { face = facedata[i].face; - /* figure out which pattern to us */ + /* figure out which pattern to use */ BLI_array_empty(verts); pat = facedata[i].pat; @@ -904,7 +914,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) BLI_array_empty(loops); BLI_array_empty(splits); - /* for case of two edges, connecting them shouldn't be too har */ + /* for case of two edges, connecting them shouldn't be too hard */ BM_ITER(l, &liter, bmesh, BM_LOOPS_OF_FACE, face) { BLI_array_growone(loops); loops[BLI_array_count(loops) - 1] = l; @@ -912,7 +922,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) vlen = BLI_array_count(loops); - /* find the boundary of one of the split edge */ + /* find the boundary of one of the split edges */ for (a = 1; a < vlen; a++) { if (!BMO_elem_flag_test(bmesh, loops[a - 1]->v, ELE_INNER) && BMO_elem_flag_test(bmesh, loops[a]->v, ELE_INNER)) @@ -991,7 +1001,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) pat->connectexec(bmesh, face, verts, ¶ms); } - /* copy original-geometry displacements to current coordinate */ + /* copy original-geometry displacements to current coordinates */ BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) { float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey); copy_v3_v3(v->co, co); @@ -1005,13 +1015,13 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) BLI_array_free(splits); BLI_array_free(loops); - BMO_slot_buffer_from_flag(bmesh, op, "outinner", BM_ALL, ELE_INNER); - BMO_slot_buffer_from_flag(bmesh, op, "outsplit", BM_ALL, ELE_SPLIT); + BMO_slot_buffer_from_enabled_flag(bmesh, op, "outinner", BM_ALL, ELE_INNER); + BMO_slot_buffer_from_enabled_flag(bmesh, op, "outsplit", BM_ALL, ELE_SPLIT); - BMO_slot_buffer_from_flag(bmesh, op, "geomout", BM_ALL, ELE_INNER|ELE_SPLIT|SUBD_SPLIT); + BMO_slot_buffer_from_enabled_flag(bmesh, op, "geomout", BM_ALL, ELE_INNER|ELE_SPLIT|SUBD_SPLIT); } -/* editmesh-emulating functio */ +/* editmesh-emulating function */ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth, float fractal, int beauty, int numcuts, int seltype, int cornertype, int singleedge, @@ -1091,12 +1101,12 @@ void bmo_edgebisect_exec(BMesh *bm, BMOperator *op) params.origkey = skey; - /* go through and split edge */ + /* go through and split edges */ BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { bm_subdivide_multicut(bm, e, ¶ms, e->v1, e->v2); } - BMO_slot_buffer_from_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT); + BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT); BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, skey); } |