diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-29 16:33:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-29 16:33:56 +0400 |
commit | 04d8ef3c476bf75d7790741b559cb4b6e075917b (patch) | |
tree | 05c17d62f77ab20d4289ff96c8fe4b5bc6092507 | |
parent | c27c87dde4f627565df7cb000b7eba45c2604ce4 (diff) |
wireframe option to crase edges at the hub, much nicer subsurf
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_wireframe.c | 43 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 2 |
4 files changed, 48 insertions, 12 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 8ffaf1875cf..af083fc30a6 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1119,6 +1119,7 @@ static BMOpDefine bmo_wireframe_def = { {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_BOOL, "use_boundary"}, {BMO_OP_SLOT_BOOL, "use_even_offset"}, + {BMO_OP_SLOT_BOOL, "use_crease"}, {BMO_OP_SLOT_FLT, "thickness"}, {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "depth"}, diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index 49aff164b7d..7cb8ac0b66d 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -28,6 +28,8 @@ #include "BLI_math.h" +#include "BKE_customdata.h" + #include "bmesh.h" #include "intern/bmesh_operators_private.h" /* own include */ @@ -132,9 +134,11 @@ extern float BM_vert_calc_mean_tagged_edge_length(BMVert *v); void bmo_wireframe_exec(BMesh *bm, BMOperator *op) { - const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); - const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); - const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); + const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); + const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); + const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); + const int use_crease = (BMO_slot_bool_get(op, "use_crease") && + CustomData_has_layer(&bm->edata, CD_CREASE)); const float depth = BMO_slot_float_get(op, "thickness"); const float inset = depth; @@ -323,8 +327,6 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) BM_elem_attrs_copy(bm, bm, l, l_new->next); BM_elem_attrs_copy(bm, bm, l, l_new->next->next); - - if (use_boundary) { if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) { /* we know its a boundary and this is the only face user (which is being wire'd) */ @@ -349,8 +351,39 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) BM_elem_attrs_copy(bm, bm, l, l_new->prev); BM_elem_attrs_copy(bm, bm, l_next, l_new->next); BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next); + + if (use_crease) { + BMEdge *e_new; + e_new = BM_edge_exists(v_pos1, v_b1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_pos2, v_b2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg1, v_b1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg2, v_b2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + } } } + + if (use_crease) { + BMEdge *e_new; + e_new = BM_edge_exists(v_pos1, v_l1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_pos2, v_l2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg1, v_l1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg2, v_l2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + } + } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a5053978186..b650a361369 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4271,16 +4271,17 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); - const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); + const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); const int use_replace = RNA_boolean_get(op->ptr, "use_replace"); - const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); - const float thickness = RNA_float_get(op->ptr, "thickness"); + const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); + const int use_crease = RNA_boolean_get(op->ptr, "use_crease"); + const float thickness = RNA_float_get(op->ptr, "thickness"); EDBM_op_init(em, &bmop, op, - "wireframe faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b " + "wireframe faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b use_crease=%b " "thickness=%f", - BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, + BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, use_crease, thickness); BMO_op_exec(em->bm, &bmop); @@ -4324,6 +4325,7 @@ void MESH_OT_wireframe(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundaries"); RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness"); RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry"); + RNA_def_boolean(ot->srna, "use_crease", FALSE, "Crease", "Crease hub edges for improved subsurf"); prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f); /* use 1 rather then 10 for max else dragging the button moves too far */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 78ad364b8e8..9ff71c72e7e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -746,7 +746,7 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event) } } -#if 0 /* disabling for 2.63 release, since we keep getting reports some menu items are leaving props undefined */ +#if 1 /* disabling for 2.63 release, since we keep getting reports some menu items are leaving props undefined */ int WM_operator_last_properties_init(wmOperator *op) { int change = FALSE; |