diff options
author | Rohan Rathi <rohanrathi08@gmail.com> | 2018-06-11 18:33:07 +0300 |
---|---|---|
committer | Rohan Rathi <rohanrathi08@gmail.com> | 2018-06-11 18:33:07 +0300 |
commit | 12551299326fea494020d19708220a9d31dd11d0 (patch) | |
tree | c6a81baaf6dc869071fafa46f0597f22c7acdb6e /source/blender/editors/mesh | |
parent | 0c6410ec0cffdcb0641fa85d8394f7c682c44143 (diff) | |
parent | 7529690df38ced314d59af3b10c610e3fd56c807 (diff) |
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editface.c | 28 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_bevel.c | 10 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife_project.c | 27 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 36 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 7 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 36 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_navmesh.c | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 63 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 147 |
12 files changed, 196 insertions, 178 deletions
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 6d1f478249a..7e31b6a3774 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -64,7 +64,7 @@ void paintface_flush_flags(Object *ob, short flag) const int *index_array = NULL; int totpoly; int i; - + BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0); if (me == NULL) @@ -106,7 +106,7 @@ void paintface_hide(Object *ob, const bool unselected) Mesh *me; MPoly *mpoly; int a; - + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; @@ -122,10 +122,10 @@ void paintface_hide(Object *ob, const bool unselected) if (mpoly->flag & ME_HIDE) { mpoly->flag &= ~ME_FACE_SEL; } - + mpoly++; } - + BKE_mesh_flush_hidden_from_polys(me); paintface_flush_flags(ob, SELECT | ME_HIDE); @@ -258,7 +258,7 @@ void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags) me = BKE_mesh_from_object(ob); if (me == NULL) return; - + if (action == SEL_TOGGLE) { action = SEL_SELECT; @@ -311,7 +311,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) if (!me || !me->mloopuv) { return ok; } - + copy_m3_m4(bmat, ob->obmat); mvert = me->mvert; @@ -338,19 +338,19 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b Mesh *me; MPoly *mpoly, *mpoly_sel; unsigned int a, index; - + /* Get the face under the cursor */ me = BKE_mesh_from_object(ob); if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) return false; - + if (index >= me->totpoly) return false; mpoly_sel = me->mpoly + index; if (mpoly_sel->flag & ME_HIDE) return false; - + /* clear flags */ mpoly = me->mpoly; a = me->totpoly; @@ -360,7 +360,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b mpoly++; } } - + me->act_face = (int)index; if (extend) { @@ -378,7 +378,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b else { mpoly_sel->flag |= ME_FACE_SEL; } - + /* image window redraw */ paintface_flush_flags(ob, SELECT); @@ -399,7 +399,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten const int size[2] = { BLI_rcti_size_x(rect) + 1, BLI_rcti_size_y(rect) + 1}; - + me = BKE_mesh_from_object(ob); if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) { @@ -455,7 +455,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten IMB_freeImBuf(ibuf); MEM_freeN(selar); -#ifdef __APPLE__ +#ifdef __APPLE__ glReadBuffer(GL_BACK); #endif @@ -520,7 +520,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags) me = BKE_mesh_from_object(ob); if (me == NULL) return; - + if (action == SEL_TOGGLE) { action = SEL_SELECT; diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 859b0942e55..1daf020dc7b 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -87,7 +87,7 @@ typedef struct { typedef struct { float initial_length[NUM_VALUE_KINDS]; float scale[NUM_VALUE_KINDS]; - NumInput num_input[NUM_VALUE_KINDS]; + NumInput num_input[NUM_VALUE_KINDS]; float shift_value[NUM_VALUE_KINDS]; /* The current value when shift is pressed. Negative when shift not active. */ bool is_modal; @@ -258,7 +258,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) opdata->shift_value[i] = -1.0f; opdata->initial_length[i] = -1.0f; /* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */ - opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch; + opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch; initNumInput(&opdata->num_input[i]); opdata->num_input[i].idx_max = 0; @@ -428,7 +428,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, len = len_v2(mlen); vmode = opdata->value_mode; if (mode_changed || opdata->initial_length[vmode] == -1.0f) { - /* If current value is not default start value, adjust len so that + /* If current value is not default start value, adjust len so that * the scaling and offset in edbm_bevel_mouse_set_value will * start at current value */ value = (vmode == SEGMENTS_VALUE) ? @@ -642,7 +642,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) (opdata->value_mode == OFFSET_VALUE || opdata->value_mode == OFFSET_VALUE_PERCENT)) { edbm_bevel_mouse_set_value(op, event); - } + } edbm_bevel_calc(op); edbm_bevel_update_header(C, op); handled = true; @@ -684,7 +684,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) case VKEY: if (event->val == KM_RELEASE) break; - + { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "vertex_only"); RNA_property_boolean_set(op->ptr, prop, !RNA_property_boolean_get(op->ptr, prop)); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 80fed05a0b5..be54bba7aa4 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2007 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Joseph Eagar, Joshua Leung, Howard Trickey, * Campbell Barton * @@ -1806,7 +1806,7 @@ static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], ED_view3d_unproject(kcd->vc.ar, mval[0], mval[1], ofs, r_origin_ofs); /* transform into object space */ - invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); + invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); mul_m4_v3(kcd->ob->imat, r_origin); mul_m4_v3(kcd->ob->imat, r_origin_ofs); diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index ba030c42a04..5ccbcf063ad 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -40,6 +40,7 @@ #include "BKE_curve.h" #include "BKE_cdderivedmesh.h" #include "BKE_editmesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_report.h" #include "DEG_depsgraph.h" @@ -62,27 +63,28 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene, { Depsgraph *depsgraph = CTX_data_depsgraph(C); ARegion *ar = CTX_wm_region(C); - DerivedMesh *dm; - bool dm_needsFree; + struct Mesh *me_eval; + bool me_eval_needs_free; if (ob->type == OB_MESH || ob->derivedFinal) { - dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH); - dm_needsFree = false; + me_eval = (ob->runtime.mesh_eval ? + ob->runtime.mesh_eval : mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH)); + me_eval_needs_free = false; } else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - dm = CDDM_from_curve(ob); - dm_needsFree = true; + me_eval = BKE_mesh_new_nomain_from_curve(ob); + me_eval_needs_free = true; } else { - dm = NULL; + me_eval = NULL; } - if (dm) { + if (me_eval) { ListBase nurbslist = {NULL, NULL}; float projmat[4][4]; - BKE_mesh_to_curve_nurblist(dm, &nurbslist, 0); /* wire */ - BKE_mesh_to_curve_nurblist(dm, &nurbslist, 1); /* boundary */ + BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 0); /* wire */ + BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 1); /* boundary */ ED_view3d_ob_project_mat_get(ar->regiondata, ob, projmat); @@ -109,12 +111,11 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene, BKE_nurbList_free(&nurbslist); - if (dm_needsFree) { - dm->release(dm); + if (me_eval_needs_free) { + BKE_mesh_free(me_eval); } } - return polys; } diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 37b85ae9f09..3e787b2055a 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2007 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Joseph Eagar, Joshua Leung * * ***** END GPL LICENSE BLOCK ***** @@ -77,7 +77,7 @@ typedef struct RingSelOpData { ARegion *ar; /* region that ringsel was activated in */ void *draw_handle; /* for drawing preview loop */ - + float (*edges)[2][3]; int totedge; @@ -109,7 +109,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) { View3D *v3d = CTX_wm_view3d(C); RingSelOpData *lcd = arg; - + if ((lcd->totedge > 0) || (lcd->totpoint > 0)) { if (v3d && v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -172,7 +172,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed, break; } } - + /* this should never happen */ if (!l) { v[0][0] = eed->v1; @@ -181,7 +181,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed, v[1][1] = lasteed->v2; return; } - + l2 = BM_loop_other_edge_loop(l, eed->v1); rev = (l2 == l->prev); while (l2->v != lasteed->v1 && l2->v != lasteed->v2) { @@ -446,7 +446,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) BMVert *v_eed_orig[2] = {lcd->eed->v1, lcd->eed->v2}; edgering_select(lcd); - + if (lcd->do_cut) { const bool is_macro = (op->opm != NULL); /* a single edge (rare, but better support) */ @@ -494,7 +494,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) BM_select_history_store(em->bm, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */ if (em->selectmode & SCE_SELECT_EDGE) BM_select_history_store(em->bm, lcd->eed); - + EDBM_selectmode_flush(lcd->em); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, lcd->ob->data); } @@ -508,7 +508,7 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op) /* deactivate the extra drawing stuff in 3D-View */ ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle); - + edgering_preview_free(lcd); MEM_freeN(lcd->objects); @@ -776,7 +776,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTMOUSE: /* confirm */ // XXX hardcoded if (event->val == KM_PRESS) return loopcut_finish(lcd, C, op); - + ED_region_tag_redraw(lcd->ar); handled = true; break; @@ -791,11 +791,11 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) /* cancel */ ED_region_tag_redraw(lcd->ar); ED_area_headerprint(CTX_wm_area(C), NULL); - + ringcut_cancel(C, op); return OPERATOR_CANCELLED; } - + ED_region_tag_redraw(lcd->ar); handled = true; break; @@ -897,7 +897,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) str_rep, str_rep + NUM_STR_REP_LEN); ED_area_headerprint(CTX_wm_area(C), buf); } - + /* keep going until the user confirms */ return OPERATOR_RUNNING_MODAL; } @@ -911,11 +911,11 @@ void MESH_OT_edgering_select(wmOperatorType *ot) ot->name = "Edge Ring Select"; ot->idname = "MESH_OT_edgering_select"; ot->description = "Select an edge ring"; - + /* callbacks */ ot->invoke = ringsel_invoke; - ot->poll = ED_operator_editmesh_region_view3d; - + ot->poll = ED_operator_editmesh_region_view3d; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -932,14 +932,14 @@ void MESH_OT_loopcut(wmOperatorType *ot) ot->name = "Loop Cut"; ot->idname = "MESH_OT_loopcut"; ot->description = "Add a new loop between existing loops"; - + /* callbacks */ ot->invoke = ringcut_invoke; ot->exec = loopcut_exec; ot->modal = loopcut_modal; ot->cancel = ringcut_cancel; ot->poll = ED_operator_editmesh_region_view3d; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index fd8efcd84e3..634c65485e9 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -678,10 +678,10 @@ BMEdge *EDBM_edge_find_nearest_ex( { FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE); ED_view3d_backbuf_validate_with_select_mode(vc, select_mode); - + index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test); eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL; - + FAKE_SELECT_MODE_END(vc, fake_select_mode); } @@ -1061,7 +1061,7 @@ static bool unified_findnearest( mval_prev[0] = vc->mval[0]; mval_prev[1] = vc->mval[1]; - + /* Only one element type will be non-null. */ BLI_assert(((hit.v.ele != NULL) + (hit.e.ele != NULL) + (hit.f.ele != NULL)) <= 1); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index afa89b11974..bbeb80fa8af 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -365,6 +365,7 @@ void MESH_OT_unsubdivide(wmOperatorType *ot) void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) { + Main *bmain = CTX_data_main(C); Object *obedit = em->ob; BMIter iter; BMVert *eve; @@ -372,7 +373,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) ED_view3d_init_mats_rv3d(obedit, ar->regiondata); struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_scene(C), CTX_data_depsgraph(C), 0, + bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ar, CTX_wm_view3d(C)); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -3630,7 +3631,7 @@ static Base *mesh_separate_tagged(Main *bmain, Scene *scene, ViewLayer *view_lay base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, USER_DUP_MESH); /* DAG_relations_tag_update(bmain); */ /* normally would call directly after but in this case delay recalc */ - assign_matarar(base_new->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */ + assign_matarar(bmain, base_new->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */ ED_object_base_select(base_new, BA_SELECT); @@ -5316,7 +5317,7 @@ static int edbm_dissolve_degenerate_exec(bContext *C, wmOperator *op) } /* objects */ const float thresh = RNA_float_get(op->ptr, "threshold"); - + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; BMEditMesh *em = BKE_editmesh_from_object(obedit); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 676af4fea5b..d2410c7d97b 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2009 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -255,7 +255,7 @@ void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) CustomData *ldata = GET_CD_DATA(me, ldata); const int layernum = CustomData_get_active_layer(ldata, CD_MLOOPUV); ED_mesh_uv_loop_reset_ex(me, layernum); - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); } @@ -301,7 +301,7 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set) CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name); } - + if (active_set || layernum_dst == 0) { CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst); CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum_dst); @@ -517,7 +517,7 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + return OPERATOR_FINISHED; } @@ -527,7 +527,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) ot->name = "Add UV Map"; ot->description = "Add UV Map"; ot->idname = "MESH_OT_uv_texture_add"; - + /* api callbacks */ ot->poll = layers_poll; ot->exec = mesh_uv_texture_add_exec; @@ -545,7 +545,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e Mesh *me; Object *obedit; int exitmode = 0; - + if (v3d == NULL) { BKE_report(op->reports, RPT_ERROR, "No 3D View Available"); return OPERATOR_CANCELLED; @@ -558,7 +558,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e BKE_report(op->reports, RPT_ERROR, "Not an object or mesh"); return OPERATOR_CANCELLED; } - + ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM); if (!ima) { return OPERATOR_CANCELLED; @@ -576,7 +576,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e } if (me->edit_btmesh == NULL) return OPERATOR_CANCELLED; - + if (exitmode) { EDBM_mesh_load(obedit); EDBM_mesh_free(me->edit_btmesh); @@ -591,9 +591,9 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e /* dummie drop support; ensure view shows a result :) */ if (v3d) v3d->flag2 |= V3D_SOLID_TEX; - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + return OPERATOR_FINISHED; } @@ -603,14 +603,14 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) ot->name = "Drop Image to Mesh UV Map"; ot->description = "Assign Image to active UV Map, or create an UV Map"; ot->idname = "MESH_OT_drop_named_image"; - + /* api callbacks */ ot->poll = layers_poll; ot->invoke = drop_named_image_invoke; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); @@ -630,7 +630,7 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + return OPERATOR_FINISHED; } @@ -640,7 +640,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) ot->name = "Remove UV Map"; ot->description = "Remove UV Map"; ot->idname = "MESH_OT_uv_texture_remove"; - + /* api callbacks */ ot->poll = layers_poll; ot->exec = mesh_uv_texture_remove_exec; @@ -668,7 +668,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) ot->name = "Add Vertex Color"; ot->description = "Add vertex color layer"; ot->idname = "MESH_OT_vertex_color_add"; - + /* api callbacks */ ot->poll = layers_poll; ot->exec = mesh_vertex_color_add_exec; @@ -694,7 +694,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) ot->name = "Remove Vertex Color"; ot->description = "Remove vertex color layer"; ot->idname = "MESH_OT_vertex_color_remove"; - + /* api callbacks */ ot->exec = mesh_vertex_color_remove_exec; ot->poll = layers_poll; diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index e585f407052..eb04d62452c 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -48,7 +48,7 @@ struct LinkNode; /* *** editmesh_utils.c *** */ /* - * ok: the EDBM module is for editmode bmesh stuff. in contrast, the + * ok: the EDBM module is for editmode bmesh stuff. in contrast, the * BMEdit module is for code shared with blenkernel that concerns * the BMEditMesh structure. */ diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 0d6c7320a95..5cfb269cbc3 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -383,7 +383,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, /* create custom data layer to save polygon idx */ CustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData"); CustomData_bmesh_init_pool(&em->bm->pdata, 0, BM_FACE); - + /* create verts and faces for detailed mesh */ meshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes); polys = recast_polyMeshGetPolys(pmesh, NULL, &nvp); @@ -445,7 +445,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); if (createob) { @@ -616,14 +616,14 @@ static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op)) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMFace *ef; BMIter iter; - + if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { int targetPolyIdx = findFreeNavPolyIndex(em); if (targetPolyIdx > 0) { /* set target poly idx to selected faces */ /*XXX this originally went last to first, but that isn't possible anymore*/ - + BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) { int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 60200313b8c..546c000d726 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2009 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -98,12 +98,12 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_loop_to_region); WM_operatortype_append(MESH_OT_region_to_loop); WM_operatortype_append(MESH_OT_select_axis); - + WM_operatortype_append(MESH_OT_uvs_rotate); WM_operatortype_append(MESH_OT_uvs_reverse); WM_operatortype_append(MESH_OT_colors_rotate); WM_operatortype_append(MESH_OT_colors_reverse); - + WM_operatortype_append(MESH_OT_fill); WM_operatortype_append(MESH_OT_fill_grid); WM_operatortype_append(MESH_OT_fill_holes); @@ -229,7 +229,7 @@ void ED_operatormacros_mesh(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it", OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); @@ -326,14 +326,14 @@ void ED_operatormacros_mesh(void) /* note mesh keymap also for other space? */ void ED_keymap_mesh(wmKeyConfig *keyconf) -{ +{ wmKeyMap *keymap; wmKeyMapItem *kmi; int i; - + keymap = WM_keymap_find(keyconf, "Mesh", 0, 0); keymap->poll = ED_operator_editmesh; - + WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_offset_edge_loops_slide", RKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0); @@ -344,6 +344,24 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "vertex_only", true); /* selecting */ + + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX); + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE); + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE); + + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX); + RNA_boolean_set(kmi->ptr, "use_extend", true); + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE); + RNA_boolean_set(kmi->ptr, "use_extend", true); + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE); + RNA_boolean_set(kmi->ptr, "use_extend", true); + /* standard mouse selection goes via space_view3d */ kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", false); @@ -381,20 +399,17 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_select_prev_item", PADMINUS, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); - + WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); - - /* selection mode */ - WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0); - + /* hide */ kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); @@ -407,14 +422,14 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "inside", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "inside", true); - + WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); @@ -448,9 +463,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0); // WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */ WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_vert_connect_path", JKEY, KM_PRESS, 0, 0); @@ -470,7 +485,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", XKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", DELKEY, KM_PRESS, KM_CTRL, 0); - + kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true); RNA_boolean_set(kmi->ptr, "only_selected", false); @@ -478,7 +493,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false); RNA_boolean_set(kmi->ptr, "only_selected", true); - + WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); /* menus */ @@ -489,13 +504,13 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); - + /* useful stuff from object-mode */ for (i = 0; i <= 5; i++) { kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "level", i); } - + ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, true); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 9b86f904161..41e1ca13b79 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -54,6 +54,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_material.h" #include "BKE_object.h" #include "BKE_object_deform.h" @@ -286,7 +287,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode"); return OPERATOR_CANCELLED; } - + /* ob is the object we are adding geometry to */ if (!ob || ob->type != OB_MESH) { BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh"); @@ -306,23 +307,23 @@ int join_mesh_exec(bContext *C, wmOperator *op) totloop += me->totloop; totpoly += me->totpoly; totmat += base->object->totcol; - + if (base->object == ob) ok = true; - + /* check for shapekeys */ if (me->key) haskey++; } } CTX_DATA_END; - - /* that way the active object is always selected */ + + /* that way the active object is always selected */ if (ok == false) { BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh"); return OPERATOR_CANCELLED; } - + /* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */ me = (Mesh *)ob->data; key = me->key; @@ -331,7 +332,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No mesh data to join"); return OPERATOR_CANCELLED; } - + if (totvert > MESH_MAX_VERTS) { BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is %ld", totvert, MESH_MAX_VERTS); return OPERATOR_CANCELLED; @@ -346,23 +347,23 @@ int join_mesh_exec(bContext *C, wmOperator *op) matmap = MEM_callocN(sizeof(*matmap) * totmat, "join_mesh matmap"); } totcol = ob->totcol; - + /* obact materials in new main array, is nicer start! */ for (a = 0; a < ob->totcol; a++) { matar[a] = give_current_material(ob, a + 1); id_us_plus((ID *)matar[a]); /* increase id->us : will be lowered later */ } - + /* - 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 + * - 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!) */ nkey = BKE_key_copy(bmain, key); - + /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { if (kb->data) MEM_freeN(kb->data); @@ -375,14 +376,14 @@ int join_mesh_exec(bContext *C, wmOperator *op) key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; } - + /* first pass over objects - copying materials and vertexgroups across */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { /* only act if a mesh, and not the one we're joining to */ if ((ob != base->object) && (base->object->type == OB_MESH)) { me = base->object->data; - + /* Join this object's vertex groups to the base one's */ for (dg = base->object->defbase.first; dg; dg = dg->next) { /* See if this group exists in the object (if it doesn't, add it to the end) */ @@ -394,8 +395,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) } if (ob->defbase.first && ob->actdef == 0) ob->actdef = 1; - - + + if (me->totvert) { /* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */ if (totcol < MAXMAT) { @@ -419,7 +420,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } } } - + /* if this mesh has shapekeys, check if destination mesh already has matching entries too */ if (me->key && key) { /* for remapping KeyBlock.relative */ @@ -481,7 +482,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) edgeofs = 0; loopofs = 0; polyofs = 0; - + /* inverse transform for all selected meshes in this object */ invert_m4_m4(imat, ob->obmat); @@ -522,10 +523,10 @@ int join_mesh_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* return to mesh we're merging to */ me = ob->data; - + CustomData_free(&me->vdata, me->totvert); CustomData_free(&me->edata, me->totedge); CustomData_free(&me->ldata, me->totloop); @@ -546,7 +547,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* update normals in case objects with non-uniform scale are joined */ BKE_mesh_calc_normals(me); - + /* old material array */ for (a = 1; a <= ob->totcol; a++) { ma = ob->mat[a - 1]; @@ -573,13 +574,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* other mesh users */ test_all_objects_materials(bmain, (ID *)me); - + /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { /* We can assume nobody is using that ID currently. */ BKE_libblock_free_ex(bmain, nkey, false, false); } - + /* ensure newly inserted keys are time sorted */ if (key && (key->type != KEY_RELATIVE)) { BKE_key_sort(key); @@ -599,7 +600,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /*********************** JOIN AS SHAPES ***************************/ -/* Append selected meshes vertex locations as shapes of the active mesh, +/* Append selected meshes vertex locations as shapes of the active mesh, * return 0 if no join is made (error) and 1 of the join is done */ int join_mesh_shapes_exec(bContext *C, wmOperator *op) @@ -613,14 +614,14 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; - + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object == ob) continue; - + if (base->object->type == OB_MESH) { selme = (Mesh *)base->object->data; - + if (selme->totvert == me->totvert) ok = true; else @@ -628,7 +629,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + if (!ok) { if (nonequal_verts) BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices"); @@ -636,7 +637,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No additional selected meshes with equal vertex count to join"); return OPERATOR_CANCELLED; } - + if (key == NULL) { key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; @@ -645,32 +646,32 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) kb = BKE_keyblock_add(key, NULL); BKE_keyblock_convert_from_mesh(me, kb); } - + /* now ready to add new keys from selected meshes */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object == ob) continue; - + if (base->object->type == OB_MESH) { selme = (Mesh *)base->object->data; - + if (selme->totvert == me->totvert) { dm = mesh_get_derived_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); - + if (!dm) continue; - + kb = BKE_keyblock_add(key, base->object->id.name + 2); - + DM_to_meshkey(dm, me, kb); - + dm->release(dm); } } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); - + return OPERATOR_FINISHED; } @@ -739,12 +740,12 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, DerivedMesh *dm, int index Mesh *me = ob->data; MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; float vec[3]; - + mvert = &mvert[index]; vec[0] = -mvert->co[0]; vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - + return ED_mesh_mirror_spatial_table(ob, NULL, dm, vec, 'u'); } @@ -802,7 +803,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c { float vec[3]; int i; - + /* ignore nan verts */ if ((isfinite(co[0]) == false) || (isfinite(co[1]) == false) || @@ -810,11 +811,11 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c { return NULL; } - + vec[0] = -co[0]; vec[1] = co[1]; vec[2] = co[2]; - + i = ED_mesh_mirror_spatial_table(ob, em, NULL, vec, 'u'); if (i != -1) { return BM_vert_at_index(em->bm, i); @@ -831,14 +832,14 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e if (index == -1) { BMIter iter; BMVert *v; - + index = 0; BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (v == eve) break; index++; } - + if (index == em->bm->totvert) { return NULL; } @@ -849,7 +850,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e if (poinval != -1) return (BMVert *)(poinval); return NULL; -} +} BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *eve, const float co[3], int index, const bool use_topology) { @@ -921,19 +922,19 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float { BMIter iter; BMFace *efa; - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { uv_poly_center(efa, cent, cd_loop_uv_offset); - + if ( (fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f) ) { BMIter liter; BMLoop *l; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); if ( (fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f) ) { return luv->uv; - + } } } @@ -982,7 +983,7 @@ static int mirror_facerotation(MFace *a, MFace *b) else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) return 2; } - + return -1; } @@ -1154,21 +1155,22 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int static void ed_mesh_pick_face_vert__mpoly_find( /* context */ struct ARegion *ar, const float mval[2], - /* mesh data */ - DerivedMesh *dm, MPoly *mp, MLoop *mloop, + /* mesh data (evaluated) */ + const MPoly *mp, + const MVert *mvert, const MLoop *mloop, /* return values */ float *r_len_best, int *r_v_idx_best) { const MLoop *ml; int j = mp->totloop; for (ml = &mloop[mp->loopstart]; j--; ml++) { - float co[3], sco[2], len; + float sco[2]; const int v_idx = ml->v; - dm->getVertCo(dm, v_idx, co); + const float *co = mvert[v_idx].co; if (ED_view3d_project_float_object(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - len = len_manhattan_v2v2(mval, sco); - if (len < *r_len_best) { - *r_len_best = len; + const float len_test = len_manhattan_v2v2(mval, sco); + if (len_test < *r_len_best) { + *r_len_best = len_test; *r_v_idx_best = v_idx; } } @@ -1191,7 +1193,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned struct ARegion *ar = CTX_wm_region(C); /* derived mesh to find deformed locations */ - DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); int v_idx_best = ORIGINDEX_NONE; @@ -1199,36 +1201,38 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned const float mval_f[2] = {UNPACK2(mval)}; float len_best = FLT_MAX; - MPoly *dm_mpoly; - MLoop *dm_mloop; - unsigned int dm_mpoly_tot; + MPoly *me_eval_mpoly; + MLoop *me_eval_mloop; + MVert *me_eval_mvert; + unsigned int me_eval_mpoly_len; const int *index_mp_to_orig; - dm_mpoly = dm->getPolyArray(dm); - dm_mloop = dm->getLoopArray(dm); + me_eval_mpoly = me_eval->mpoly; + me_eval_mloop = me_eval->mloop; + me_eval_mvert = me_eval->mvert; - dm_mpoly_tot = dm->getNumPolys(dm); + me_eval_mpoly_len = me_eval->totpoly; - index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); + index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); /* tag all verts using this face */ if (index_mp_to_orig) { unsigned int i; - for (i = 0; i < dm_mpoly_tot; i++) { + for (i = 0; i < me_eval_mpoly_len; i++) { if (index_mp_to_orig[i] == poly_index) { ed_mesh_pick_face_vert__mpoly_find( ar, mval_f, - dm, &dm_mpoly[i], dm_mloop, + &me_eval_mpoly[i], me_eval_mvert, me_eval_mloop, &len_best, &v_idx_best); } } } else { - if (poly_index < dm_mpoly_tot) { + if (poly_index < me_eval_mpoly_len) { ed_mesh_pick_face_vert__mpoly_find( ar, mval_f, - dm, &dm_mpoly[poly_index], dm_mloop, + &me_eval_mpoly[poly_index], me_eval_mvert, me_eval_mloop, &len_best, &v_idx_best); } } @@ -1236,15 +1240,12 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned /* map 'dm -> me' index if possible */ if (v_idx_best != ORIGINDEX_NONE) { const int *index_mv_to_orig; - - index_mv_to_orig = dm->getVertDataArray(dm, CD_ORIGINDEX); + index_mv_to_orig = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); if (index_mv_to_orig) { v_idx_best = index_mv_to_orig[v_idx_best]; } } - dm->release(dm); - if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < me->totvert)) { *index = v_idx_best; return true; |