diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-23 07:43:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-23 07:43:02 +0400 |
commit | b51590d55df4b013a0becf9977eddb33206276ba (patch) | |
tree | 03decdf489f9e7acf1ccfd2be3b9aab709b5cba3 /source/blender/bmesh/operators | |
parent | 4c4389f6a42ebfe0140de8d1892d9990aa592980 (diff) |
code cleanup: bmesh subdivide code - BM_mesh_esubdivideflag() & "esubd" bmesh operator was passing a flag about in a fairly confusing way.
since we will eventually have python bmesh operator access better expose this as multiple booleans.
remove remaining editbutflag's
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r-- | source/blender/bmesh/operators/bmo_primitive.c | 9 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 54 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.h | 5 |
3 files changed, 44 insertions, 24 deletions
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index e526e2eaca0..fc0e34cf2f6 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -428,8 +428,13 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) BMOperator bmop; BMO_op_initf(bm, &bmop, - "esubd edges=%fe smooth=%f numcuts=%i gridfill=%b beauty=%i", - EDGE_MARK, dia, (1 << (subdiv-1)) - 1, TRUE, B_SPHERE); + "esubd edges=%fe " + "smooth=%f " + "numcuts=%i " + "use_gridfill=%b use_sphere=%b", + EDGE_MARK, dia, (1 << (subdiv-1)) - 1, + TRUE, TRUE); + BMO_op_exec(bm, &bmop); BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK); BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_EDGE, EDGE_MARK); diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index e2f00e3187f..2f198992eb6 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -111,7 +111,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar copy_v3_v3(co, v->co); copy_v3_v3(prev_co, co); - if (params->beauty & B_SMOOTH) { + if (params->use_smooth) { /* we calculate an offset vector vec1[], to be added to *co */ float len, nor[3], nor1[3], nor2[3], smooth = params->smooth; @@ -136,12 +136,12 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar add_v3_v3(co, tvec); } - else if (params->beauty & B_SPHERE) { /* subdivide sphere */ + else if (params->use_sphere) { /* subdivide sphere */ normalize_v3(co); mul_v3_fl(co, params->smooth); } - if (params->beauty & B_FRACTAL) { + if (params->use_fractal) { float len = len_v3v3(vsta->co, vend->co); float vec2[3] = {0.0f, 0.0f, 0.0f}, co2[3]; @@ -690,7 +690,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) BLI_array_declare(edges); BLI_array_declare(verts); float smooth, fractal; - int beauty, cornertype, singleedge, gridfill; + int use_sphere, cornertype, use_singleedge, use_gridfill; int skey, seed, i, j, matched, a, b, numcuts, totesel; BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, SUBD_SPLIT); @@ -699,10 +699,11 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) seed = BMO_slot_int_get(op, "seed"); smooth = BMO_slot_float_get(op, "smooth"); fractal = BMO_slot_float_get(op, "fractal"); - beauty = BMO_slot_int_get(op, "beauty"); cornertype = BMO_slot_int_get(op, "quadcornertype"); - singleedge = BMO_slot_bool_get(op, "singleedge"); - gridfill = BMO_slot_bool_get(op, "gridfill"); + + use_singleedge = BMO_slot_bool_get(op, "use_singleedge"); + use_gridfill = BMO_slot_bool_get(op, "use_gridfill"); + use_sphere = BMO_slot_bool_get(op, "use_sphere"); BLI_srandom(seed); @@ -720,7 +721,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) break; } - if (singleedge) { + if (use_singleedge) { patterns[0] = &quad_1edge; patterns[2] = &tri_1edge; } @@ -729,7 +730,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) patterns[2] = NULL; } - if (gridfill) { + if (use_gridfill) { patterns[3] = &quad_4edge; patterns[5] = &tri_3edge; } @@ -755,7 +756,9 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) params.smooth = smooth; params.seed = seed; params.fractal = fractal; - params.beauty = beauty; + params.use_smooth = (smooth != 0.0f); + params.use_fractal = (fractal != 0.0f); + params.use_sphere = use_sphere; params.origkey = skey; params.off[0] = (float)BLI_drand() * 200.0f; params.off[1] = (float)BLI_drand() * 200.0f; @@ -1023,25 +1026,35 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) } /* 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, - int gridfill, int seed) +void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, + float smooth, float fractal, + int numcuts, + int seltype, int cornertype, + const short use_singleedge, const short use_gridfill, + int seed) { BMOperator op; - BMO_op_initf(bm, &op, "esubd edges=%he smooth=%f fractal=%f " - "beauty=%i numcuts=%i quadcornertype=%i singleedge=%b " - "gridfill=%b seed=%i", - flag, smooth, fractal, beauty, numcuts, - cornertype, singleedge, gridfill, seed); + /* use_sphere isnt exposed here since its only used for new primitives */ + BMO_op_initf(bm, &op, + "esubd edges=%he " + "smooth=%f fractal=%f " + "numcuts=%i " + "quadcornertype=%i " + "use_singleedge=%b use_gridfill=%b " + "seed=%i", + edge_hflag, + smooth, fractal, + numcuts, + cornertype, + use_singleedge, use_gridfill, + seed); BMO_op_exec(bm, &op); if (seltype == SUBDIV_SELECT_INNER) { BMOIter iter; BMElem *ele; - // int i; for (ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) { BM_elem_select_set(bm, ele, TRUE); @@ -1050,7 +1063,6 @@ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float s else if (seltype == SUBDIV_SELECT_LOOPCUT) { BMOIter iter; BMElem *ele; - // int i; /* deselect input */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); diff --git a/source/blender/bmesh/operators/bmo_subdivide.h b/source/blender/bmesh/operators/bmo_subdivide.h index 1d9021d9756..cc6ced8bfaa 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.h +++ b/source/blender/bmesh/operators/bmo_subdivide.h @@ -31,7 +31,10 @@ typedef struct SubDParams { int numcuts; float smooth; float fractal; - int beauty; + //int beauty; + short use_smooth; + short use_sphere; + short use_fractal; int seed; int origkey; /* shapekey holding displaced vertex coordinates for current geometry */ BMOperator *op; |