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 | |
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')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 10 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operator_api.h | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.h | 9 | ||||
-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 | ||||
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 13 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 9 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 23 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 2 |
10 files changed, 71 insertions, 65 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index f850f6aa46a..4b5c67c8671 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -694,10 +694,9 @@ static BMOpDefine bmo_triangulate_def = { static BMOpDefine bmo_esubd_def = { "esubd", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {BMO_OP_SLOT_INT, "numcuts"}, {BMO_OP_SLOT_FLT, "smooth"}, {BMO_OP_SLOT_FLT, "fractal"}, - {BMO_OP_SLOT_INT, "beauty"}, + {BMO_OP_SLOT_INT, "numcuts"}, {BMO_OP_SLOT_INT, "seed"}, {BMO_OP_SLOT_MAPPING, "custompatterns"}, {BMO_OP_SLOT_MAPPING, "edgepercents"}, @@ -707,9 +706,10 @@ static BMOpDefine bmo_esubd_def = { {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* contains all output geometr */ - {BMO_OP_SLOT_INT, "quadcornertype"}, //quad corner type, see bmesh_operators.h - {BMO_OP_SLOT_BOOL, "gridfill"}, //fill in fully-selected faces with a grid - {BMO_OP_SLOT_BOOL, "singleedge"}, //tessellate the case of one edge selected in a quad or triangle + {BMO_OP_SLOT_INT, "quadcornertype"}, /* quad corner type, see bmesh_operators.h */ + {BMO_OP_SLOT_BOOL, "use_gridfill"}, /* fill in fully-selected faces with a grid */ + {BMO_OP_SLOT_BOOL, "use_singleedge"}, /* tessellate the case of one edge selected in a quad or triangle */ + {BMO_OP_SLOT_BOOL, "use_sphere"}, /* for making new primitives only */ {0} /* null-terminating sentinel */, }, diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index bf66388fb9e..b5e6534de3e 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -242,7 +242,7 @@ int BMO_op_callf(BMesh *bm, const char *fmt, ...); int BMO_op_initf(BMesh *bm, BMOperator *op, const char *fmt, ...); /* va_list version, used to implement the above two functions, - * plus EDBM_op_callf in bmeshutils.c. */ + * plus EDBM_op_callf in editmesh_utils.c. */ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *fmt, va_list vlist); /* test whether a named slot exists */ diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index af62e4d2b29..52e2018eeef 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -90,9 +90,12 @@ extern int bmesh_total_ops; struct Object; -void BM_mesh_esubdivideflag(struct Object *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); #include "intern/bmesh_operator_api_inline.h" 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; diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 06e837b37bd..6a6da0cfa26 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -71,16 +71,10 @@ struct Material; struct Object; struct rcti; -/* editbutflag */ -#define B_SMOOTH 8 -#define B_FRACTAL 0x2000 -#define B_SPHERE 0x4000 - intptr_t mesh_octree_table(struct Object *ob, struct BMEditMesh *em, float *co, char mode); int mesh_mirrtopo_table(struct Object *ob, char mode); -/* bmeshutils.c */ - +/* editmesh_utils.c */ /* retrieves mirrored cache vert, or NULL if there isn't one. * note: calling this without ensuring the mirror cache state @@ -282,11 +276,6 @@ void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); #define SUBDIV_SELECT_INNER_SEL 2 #define SUBDIV_SELECT_LOOPCUT 3 -/* edge subdivide corner cut types */ -#define SUBDIV_CORNER_PATH 0 -#define SUBDIV_CORNER_INNERVERT 1 -#define SUBDIV_CORNER_FAN 2 - #ifdef __cplusplus } #endif diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 45a975e5d52..d7201394855 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -313,10 +313,11 @@ static void ringsel_finish(bContext *C, wmOperator *op) edgering_sel(lcd, cuts, 1); if (lcd->do_cut) { - BM_mesh_esubdivideflag(lcd->ob, em->bm, BM_ELEM_SELECT, 0.0f, - 0.0f, 0, cuts, SUBDIV_SELECT_LOOPCUT, - SUBD_PATH, 0, FALSE, 0); - + BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, + 0.0f, 0.0f, + cuts, + SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, FALSE, 0); + /* force edge slide to edge select mode in in face select mode */ if (em->selectmode & SCE_SELECT_FACE) { if (em->selectmode == SCE_SELECT_FACE) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index da475f9bdf4..67f387946d5 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -87,25 +87,19 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) int cuts = RNA_int_get(op->ptr, "number_cuts"); float smooth = 0.292f * RNA_float_get(op->ptr, "smoothness"); float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f; - int flag = 0; - if (smooth != 0.0f) - flag |= B_SMOOTH; - if (fractal != 0.0f) - flag |= B_FRACTAL; - if (RNA_boolean_get(op->ptr, "quadtri") && RNA_enum_get(op->ptr, "quadcorner") == SUBD_STRAIGHT_CUT) { RNA_enum_set(op->ptr, "quadcorner", SUBD_INNERVERT); } - BM_mesh_esubdivideflag(obedit, em->bm, BM_ELEM_SELECT, - smooth, fractal, - flag, - cuts, 0, RNA_enum_get(op->ptr, "quadcorner"), - RNA_boolean_get(op->ptr, "quadtri"), - TRUE, RNA_int_get(op->ptr, "seed")); + BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, + smooth, fractal, + cuts, + SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"), + RNA_boolean_get(op->ptr, "quadtri"), TRUE, + RNA_int_get(op->ptr, "seed")); EDBM_update_generic(C, em, TRUE); @@ -2741,10 +2735,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) if (mode == KNIFE_MIDPOINT) numcuts = 1; BMO_slot_int_set(&bmop, "numcuts", numcuts); - BMO_slot_int_set(&bmop, "flag", 0); BMO_slot_int_set(&bmop, "quadcornertype", SUBD_STRAIGHT_CUT); - BMO_slot_bool_set(&bmop, "singleedge", FALSE); - BMO_slot_bool_set(&bmop, "gridfill", FALSE); + BMO_slot_bool_set(&bmop, "use_singleedge", FALSE); + BMO_slot_bool_set(&bmop, "use_gridfill", FALSE); BMO_slot_float_set(&bmop, "radius", 0); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 772e80fff69..27b1cb6ad54 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -49,7 +49,7 @@ struct wmKeyMap; struct wmOperator; struct wmOperatorType; -/* ******************** bmeshutils.c */ +/* ******************** editmesh_utils.c */ /* * ok: the EDBM module is for editmode bmesh stuff. in contrast, the |