diff options
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_extrude.c | 24 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_extrude_spin.c | 49 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 16 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_mirror.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 6 |
8 files changed, 70 insertions, 39 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 7ea89c56432..1e5e279ef35 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -161,15 +161,15 @@ static bool edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const ch } /* extrudes individual edges */ -static bool edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag) +static bool edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag, const bool use_normal_flip) { BMesh *bm = em->bm; BMOperator bmop; EDBM_op_init( em, &bmop, op, - "extrude_edge_only edges=%he use_select_history=%b", - hflag, true); + "extrude_edge_only edges=%he use_normal_flip=%b use_select_history=%b", + hflag, use_normal_flip, true); /* deselect original verts */ BM_SELECT_HISTORY_BACKUP(bm); @@ -236,6 +236,7 @@ static char edbm_extrude_htype_from_em_select(BMEditMesh *em) static bool edbm_extrude_ex( Object *obedit, BMEditMesh *em, char htype, const char hflag, + const bool use_normal_flip, const bool use_mirror, const bool use_select_history) { @@ -250,6 +251,7 @@ static bool edbm_extrude_ex( } BMO_op_init(bm, &extop, BMO_FLAG_DEFAULTS, "extrude_face_region"); + BMO_slot_bool_set(extop.slots_in, "use_normal_flip", use_normal_flip); BMO_slot_bool_set(extop.slots_in, "use_select_history", use_select_history); BMO_slot_buffer_from_enabled_hflag(bm, &extop, extop.slots_in, "geom", htype, hflag); @@ -302,7 +304,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) mul_m3_v3(tmat, dvec); for (a = 0; a < steps; a++) { - edbm_extrude_ex(obedit, em, BM_ALL_NOLOOP, BM_ELEM_SELECT, false, false); + edbm_extrude_ex(obedit, em, BM_ALL_NOLOOP, BM_ELEM_SELECT, false, false, false); BMO_op_callf( em->bm, BMO_FLAG_DEFAULTS, @@ -345,9 +347,10 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) /* generic extern called extruder */ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op) { - bool changed = false; + const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip"); const char htype = edbm_extrude_htype_from_em_select(em); enum {NONE = 0, ELEM_FLAG, VERT_ONLY, EDGE_ONLY} nr; + bool changed = false; if (em->selectmode & SCE_SELECT_VERTEX) { if (em->bm->totvertsel == 0) nr = NONE; @@ -369,13 +372,13 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op) case NONE: return false; case ELEM_FLAG: - changed = edbm_extrude_ex(obedit, em, htype, BM_ELEM_SELECT, true, true); + changed = edbm_extrude_ex(obedit, em, htype, BM_ELEM_SELECT, use_normal_flip, true, true); break; case VERT_ONLY: changed = edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT); break; case EDGE_ONLY: - changed = edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT); + changed = edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, use_normal_flip); break; } @@ -421,6 +424,7 @@ void MESH_OT_extrude_region(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + RNA_def_boolean(ot->srna, "use_normal_flip", false, "Flip Normals", ""); Transform_Properties(ot, P_NO_DEFAULTS | P_MIRROR_DUMMY); } @@ -470,8 +474,9 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); + const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip"); - edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT); + edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, use_normal_flip); EDBM_update_generic(em, true, true); @@ -493,6 +498,7 @@ void MESH_OT_extrude_edges_indiv(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ + RNA_def_boolean(ot->srna, "use_normal_flip", false, "Flip Normals", ""); Transform_Properties(ot, P_NO_DEFAULTS | P_MIRROR_DUMMY); } @@ -664,7 +670,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w EDBM_project_snap_verts(C, vc.ar, vc.em); } - edbm_extrude_ex(vc.obedit, vc.em, extrude_htype, BM_ELEM_SELECT, true, true); + edbm_extrude_ex(vc.obedit, vc.em, extrude_htype, BM_ELEM_SELECT, false, true, true); EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3", BM_ELEM_SELECT, center, mat); EDBM_op_callf(vc.em, op, "translate verts=%hv vec=%v", diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 5f1670bf57d..a9e78f74012 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -61,16 +61,18 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) BMOperator spinop; float cent[3], axis[3]; float d[3] = {0.0f, 0.0f, 0.0f}; - int steps, dupli; - float angle; RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); - steps = RNA_int_get(op->ptr, "steps"); - angle = RNA_float_get(op->ptr, "angle"); - //if (ts->editbutflag & B_CLOCKWISE) - angle = -angle; - dupli = RNA_boolean_get(op->ptr, "dupli"); + const int steps = RNA_int_get(op->ptr, "steps"); + const float angle = RNA_float_get(op->ptr, "angle"); + const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip") ^ (angle < 0.0f); + const bool dupli = RNA_boolean_get(op->ptr, "dupli"); + const bool use_auto_merge = ( + RNA_boolean_get(op->ptr, "use_auto_merge") && + (dupli == false) && + (steps >= 3) && + fabsf((fabsf(angle) - (M_PI * 2))) <= 1e-6f); if (is_zero_v3(axis)) { BKE_report(op->reports, RPT_ERROR, "Invalid/unset axis"); @@ -78,15 +80,20 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) } /* keep the values in worldspace since we're passing the obmat */ - if (!EDBM_op_init(em, &spinop, op, - "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 use_duplicate=%b", - BM_ELEM_SELECT, cent, axis, d, steps, angle, obedit->obmat, dupli)) + if (!EDBM_op_init( + em, &spinop, op, + "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 " + "use_normal_flip=%b use_duplicate=%b use_merge=%b", + BM_ELEM_SELECT, cent, axis, d, steps, -angle, obedit->obmat, + use_normal_flip, dupli, use_auto_merge)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &spinop); - EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + if (use_auto_merge == false) { + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + } if (!EDBM_op_finish(em, &spinop, op, true)) { return OPERATOR_CANCELLED; } @@ -118,6 +125,21 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e return edbm_spin_exec(C, op); } +static bool edbm_spin_poll_property(const bContext *UNUSED(C), wmOperator *op, const PropertyRNA *prop) +{ + const char *prop_id = RNA_property_identifier(prop); + const bool dupli = RNA_boolean_get(op->ptr, "dupli"); + + if (dupli) { + if (STREQ(prop_id, "use_auto_merge") || + STREQ(prop_id, "use_normal_flip")) + { + return false; + } + } + return true; +} + void MESH_OT_spin(wmOperatorType *ot) { PropertyRNA *prop; @@ -131,6 +153,7 @@ void MESH_OT_spin(wmOperatorType *ot) ot->invoke = edbm_spin_invoke; ot->exec = edbm_spin_exec; ot->poll = ED_operator_editmesh; + ot->poll_property = edbm_spin_poll_property; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -141,6 +164,8 @@ void MESH_OT_spin(wmOperatorType *ot) prop = RNA_def_float(ot->srna, "angle", DEG2RADF(90.0f), -1e12f, 1e12f, "Angle", "Rotation for each step", DEG2RADF(-360.0f), DEG2RADF(360.0f)); RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_boolean(ot->srna, "use_auto_merge", true, "Auto Merge", "Merge first/last when the angle is a full revolution"); + RNA_def_boolean(ot->srna, "use_normal_flip", 0, "Flip Normals", ""); RNA_def_float_vector(ot->srna, "center", 3, NULL, -1e12f, 1e12f, "Center", "Center in global view space", -1e4f, 1e4f); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 8eb3ad84919..9cc19d5194e 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -479,7 +479,7 @@ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e) /* Record the index in kcd->em->looptris of first looptri triple for a given face, * given an index for some triple in that array. * This assumes that all of the triangles for a given face are contiguous - * in that array (as they are by the current tesselation routines). + * in that array (as they are by the current tessellation routines). * Actually store index + 1 in the hash, because 0 looks like "no entry" * to hash lookup routine; will reverse this in the get routine. * Doing this lazily rather than all at once for all faces. @@ -502,7 +502,7 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index) if (i == -1) i++; - BLI_ghash_insert(kcd->facetrimap, f, SET_INT_IN_POINTER(i + 1)); + BLI_ghash_insert(kcd->facetrimap, f, POINTER_FROM_INT(i + 1)); } /* This should only be called for faces that have had a lowest face tri set by previous function */ @@ -510,7 +510,7 @@ static int get_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f) { int ans; - ans = GET_INT_FROM_POINTER(BLI_ghash_lookup(kcd->facetrimap, f)); + ans = POINTER_AS_INT(BLI_ghash_lookup(kcd->facetrimap, f)); BLI_assert(ans != 0); return ans - 1; } @@ -1217,7 +1217,7 @@ static bool knife_ray_intersect_face( lv2 = kcd->cagecos[BM_elem_index_get(tri[1]->v)]; lv3 = kcd->cagecos[BM_elem_index_get(tri[2]->v)]; /* using epsilon test in case ray is directly through an internal - * tesselation edge and might not hit either tesselation tri with + * tessellation edge and might not hit either tessellation tri with * an exact test; * we will exclude hits near real edges by a later test */ if (isect_ray_tri_epsilon_v3(v1, raydir, lv1, lv2, lv3, &lambda, ray_tri_uv, KNIFE_FLT_EPS)) { @@ -1542,8 +1542,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) } /* unproject screen line */ - ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s1, v1, v3, true); - ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s2, v2, v4, true); + ED_view3d_win_to_segment_clipped(kcd->ar, kcd->vc.v3d, s1, v1, v3, true); + ED_view3d_win_to_segment_clipped(kcd->ar, kcd->vc.v3d, s2, v2, v4, true); mul_m4_v3(kcd->ob->imat, v1); mul_m4_v3(kcd->ob->imat, v2); @@ -1551,7 +1551,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) mul_m4_v3(kcd->ob->imat, v4); /* numeric error, 'v1' -> 'v2', 'v2' -> 'v4' can end up being ~2000 units apart in otho mode - * (from ED_view3d_win_to_segment_clip() above) + * (from ED_view3d_win_to_segment_clipped() above) * this gives precision error; rather then solving properly * (which may involve using doubles everywhere!), * limit the distance between these points */ @@ -2194,7 +2194,7 @@ static int knife_update_active(KnifeTool_OpData *kcd) /* if no hits are found this would normally default to (0, 0, 0) so instead * get a point at the mouse ray closest to the previous point. * Note that drawing lines in `free-space` isn't properly supported - * but theres no guarantee (0, 0, 0) has any geometry either - campbell */ + * but there's no guarantee (0, 0, 0) has any geometry either - campbell */ if (kcd->curr.vert == NULL && kcd->curr.edge == NULL && kcd->curr.bmface == NULL) { float origin[3]; float origin_ofs[3]; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 313dd28e806..7b687f7f045 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2898,7 +2898,7 @@ static float bm_edge_seg_isect( b2 = ((x22 * y21) - (x21 * y22)) / xdiff2; } else { - m2 = MAXSLOPE; /* Verticle slope */ + m2 = MAXSLOPE; /* Vertical slope */ b2 = x22; } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 7a344be8e5a..65b42571bbc 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -433,14 +433,14 @@ void EDBM_selectmode_flush(BMEditMesh *em) void EDBM_deselect_flush(BMEditMesh *em) { - /* function below doesnt use. just do this to keep the values in sync */ + /* function below doesn't use. just do this to keep the values in sync */ em->bm->selectmode = em->selectmode; BM_mesh_deselect_flush(em->bm); } void EDBM_select_flush(BMEditMesh *em) { - /* function below doesnt use. just do this to keep the values in sync */ + /* function below doesn't use. just do this to keep the values in sync */ em->bm->selectmode = em->selectmode; BM_mesh_select_flush(em->bm); } @@ -1499,7 +1499,7 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v ar->winy / 2.0f, }; - ED_view3d_win_to_segment(ar, v3d, mval_f, origin, end, false); + ED_view3d_win_to_segment_clipped(ar, v3d, mval_f, origin, end, false); invert_m4_m4(invmat, obedit->obmat); mul_m4_v3(invmat, origin); diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 20ece9c3336..1615ec75565 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -262,7 +262,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, DerivedMesh *dm, const int ob_mode, MirrTop /* sort so we can count unique values */ qsort(topo_hash_prev, totvert, sizeof(MirrTopoHash_t), mirrtopo_hash_sort); - tot_unique = 1; /* account for skiping the first value */ + tot_unique = 1; /* account for skipping the first value */ for (a = 1; a < totvert; a++) { if (topo_hash_prev[a - 1] != topo_hash_prev[a]) { tot_unique++; diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 658bc5996a8..f3f7338716c 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -262,7 +262,7 @@ void ED_operatormacros_mesh(void) RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten", "Extrude Region and Shrink/Fatten", - "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER); + "Extrude along normals and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -297,7 +297,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) wmKeyMapItem *kmi; int i; - keymap = WM_keymap_find(keyconf, "Mesh", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Mesh", 0, 0); keymap->poll = ED_operator_editmesh; WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 8980e1830cf..3e9025baf40 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -349,9 +349,9 @@ int join_mesh_exec(bContext *C, wmOperator *op) } /* - if destination mesh had shapekeys, move them somewhere safe, and set up placeholders - * with arrays that are large enough to hold shapekey data for all meshes - * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're - * joining, set up a new keyblock and assign to the mesh + * with arrays that are large enough to hold shapekey data for all meshes + * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're + * joining, set up a new keyblock and assign to the mesh */ if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ |