wireframe option to crase edges at the hub, much nicer subsurf

This commit is contained in:
Campbell Barton 2012-04-29 12:33:56 +00:00
parent c27c87dde4
commit 04d8ef3c47
4 changed files with 48 additions and 12 deletions

View File

@ -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"},

View File

@ -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);
}
}
}

View File

@ -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 */

View File

@ -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;