fix [#31049] New Faces (F) always solid shaded
This commit is contained in:
parent
1615b46963
commit
1c54eaecd8
@ -404,8 +404,9 @@ static BMOpDefine bmo_join_triangles_def = {
|
||||
static BMOpDefine bmo_contextual_create_def = {
|
||||
"contextual_create",
|
||||
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry.
|
||||
{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //newly-made face(s)
|
||||
{BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
|
||||
{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */
|
||||
{BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
|
||||
{BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */
|
||||
{0, /* null-terminating sentinel */}},
|
||||
bmo_contextual_create_exec,
|
||||
BMO_OP_FLAG_UNTAN_MULTIRES,
|
||||
@ -431,8 +432,9 @@ static BMOpDefine bmo_edgenet_fill_def = {
|
||||
{BMO_OP_SLOT_BOOL, "use_fill_check"},
|
||||
{BMO_OP_SLOT_ELEMENT_BUF, "excludefaces"}, /* list of faces to ignore for manifold check */
|
||||
{BMO_OP_SLOT_MAPPING, "faceout_groupmap"}, /* maps new faces to the group numbers they came fro */
|
||||
{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */
|
||||
{BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
|
||||
{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */
|
||||
{BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
|
||||
{BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */
|
||||
{0, /* null-terminating sentinel */}},
|
||||
bmo_edgenet_fill_exec,
|
||||
0,
|
||||
|
@ -896,9 +896,10 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
|
||||
BMEdge **edges = NULL;
|
||||
PathBase *pathbase;
|
||||
BLI_array_declare(edges);
|
||||
int use_restrict = BMO_slot_bool_get(op, "use_restrict");
|
||||
int use_fill_check = BMO_slot_bool_get(op, "use_fill_check");
|
||||
const short mat_nr = BMO_slot_int_get(op, "mat_nr");
|
||||
int use_restrict = BMO_slot_bool_get(op, "use_restrict");
|
||||
int use_fill_check = BMO_slot_bool_get(op, "use_fill_check");
|
||||
const short mat_nr = BMO_slot_int_get(op, "mat_nr");
|
||||
const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
|
||||
int i, j, group = 0;
|
||||
unsigned int winding[2]; /* accumulte winding directions for each edge which has a face */
|
||||
|
||||
@ -1049,6 +1050,9 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
|
||||
if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
|
||||
BMO_elem_flag_enable(bm, f, FACE_NEW);
|
||||
f->mat_nr = mat_nr;
|
||||
if (use_smooth) {
|
||||
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
|
||||
}
|
||||
}
|
||||
|
||||
if (use_restrict) {
|
||||
@ -1278,6 +1282,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
|
||||
BMFace *f;
|
||||
int totv = 0, tote = 0, totf = 0, amount;
|
||||
const short mat_nr = BMO_slot_int_get(op, "mat_nr");
|
||||
const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
|
||||
|
||||
/* count number of each element type we were passe */
|
||||
BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) {
|
||||
@ -1365,7 +1370,10 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
|
||||
BMO_slot_buffer_flag_enable(bm, &op2, "edgeout", BM_EDGE, ELE_NEW);
|
||||
BMO_op_finish(bm, &op2);
|
||||
|
||||
BMO_op_initf(bm, &op2, "edgenet_fill edges=%fe use_fill_check=%b mat_nr=%i", ELE_NEW, TRUE, mat_nr);
|
||||
BMO_op_initf(bm, &op2,
|
||||
"edgenet_fill edges=%fe use_fill_check=%b mat_nr=%i use_smooth=%b",
|
||||
ELE_NEW, TRUE, mat_nr, use_smooth);
|
||||
|
||||
BMO_op_exec(bm, &op2);
|
||||
|
||||
/* return if edge net create did something */
|
||||
@ -1469,6 +1477,9 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
|
||||
if (f) {
|
||||
BMO_elem_flag_enable(bm, f, ELE_OUT);
|
||||
f->mat_nr = mat_nr;
|
||||
if (use_smooth) {
|
||||
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(vert_arr);
|
||||
|
@ -1020,14 +1020,37 @@ void MESH_OT_edge_collapse_loop(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int edbm_add_edge_face__smooth_get(BMesh *bm)
|
||||
{
|
||||
BMEdge *e;
|
||||
BMIter iter;
|
||||
|
||||
unsigned int vote_on_smooth[2] = {0, 0};
|
||||
|
||||
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
|
||||
if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l)
|
||||
{
|
||||
vote_on_smooth[BM_elem_flag_test_bool(e->l->f, BM_ELEM_SMOOTH)]++;
|
||||
}
|
||||
}
|
||||
|
||||
return (vote_on_smooth[0] < vote_on_smooth[1]);
|
||||
}
|
||||
|
||||
static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
BMOperator bmop;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
|
||||
if (!EDBM_op_init(em, &bmop, op, "contextual_create geom=%hfev mat_nr=%i", BM_ELEM_SELECT, em->mat_nr))
|
||||
const short use_smooth = edbm_add_edge_face__smooth_get(em->bm);
|
||||
/* when this is used to dissolve we could avoid this, but checking isnt too slow */
|
||||
|
||||
if (!EDBM_op_init(em, &bmop, op,
|
||||
"contextual_create geom=%hfev mat_nr=%i use_smooth=%b",
|
||||
BM_ELEM_SELECT, em->mat_nr, use_smooth))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
BMO_op_exec(em->bm, &bmop);
|
||||
BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user