From bd1d80d0cf9c8aa856b37a91750c94a0048528f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Mar 2019 11:38:55 +1100 Subject: Cleanup: use return args last --- source/blender/editors/include/ED_mesh.h | 12 ++++++++--- source/blender/editors/mesh/editface.c | 8 +++++--- source/blender/editors/mesh/meshtools.c | 23 ++++++++++++++-------- .../editors/sculpt_paint/paint_vertex_weight_ops.c | 10 +++++----- source/blender/editors/space_view3d/space_view3d.c | 2 -- .../blender/editors/space_view3d/view3d_select.c | 2 +- 6 files changed, 35 insertions(+), 22 deletions(-) (limited to 'source') diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 9fcd0c985ca..b912cf88102 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -365,9 +365,15 @@ int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct Me int ED_mesh_mirror_get_vert(struct Object *ob, int index); -bool ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], uint *r_index, uint dist_px, bool use_zbuf); -bool ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], uint *r_index, uint dist_px); -bool ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], uint *r_index, uint dist_px); +bool ED_mesh_pick_vert( + struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, bool use_zbuf, + uint *r_index); +bool ED_mesh_pick_face( + struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, + uint *r_index); +bool ED_mesh_pick_face_vert( + struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, + uint *r_index); struct MDeformVert *ED_mesh_active_dvert_get_em(struct Object *ob, struct BMVert **r_eve); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index e226985300c..12a96d41711 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -272,7 +272,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b if (me == NULL || me->totpoly == 0) return; if (mval) { - if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_DIST)) { + if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { return; } } @@ -374,11 +374,13 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b /* 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_DIST)) + if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { return false; + } - if (index >= me->totpoly) + if (index >= me->totpoly) { return false; + } mpoly_sel = me->mpoly + index; if (mpoly_sel->flag & ME_HIDE) return false; diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 0b2b9355a8a..5339c83d158 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1014,7 +1014,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) * * \return boolean true == Found */ -bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index, uint dist_px) +bool ED_mesh_pick_face( + bContext *C, Object *ob, const int mval[2], uint dist_px, + uint *r_index) { ViewContext vc; Mesh *me = ob->data; @@ -1032,18 +1034,19 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int ED_view3d_select_id_validate(&vc); - *index = ED_view3d_select_id_read_nearest( + *r_index = ED_view3d_select_id_read_nearest( &vc, mval, 1, me->totpoly + 1, &dist_px); } else { /* sample only on the exact position */ - *index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]); + *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]); } - if ((*index) == 0 || (*index) > (unsigned int)me->totpoly) + if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) { return false; + } - (*index)--; + (*r_index)--; return true; } @@ -1076,7 +1079,9 @@ static void ed_mesh_pick_face_vert__mpoly_find( * Use when the back buffer stores face index values. but we want a vert. * This gets the face then finds the closest vertex to mval. */ -bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], uint *r_index, uint dist_px) +bool ED_mesh_pick_face_vert( + bContext *C, Object *ob, const int mval[2], uint dist_px, + uint *r_index) { Depsgraph *depsgraph = CTX_data_depsgraph(C); unsigned int poly_index; @@ -1084,7 +1089,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], uint *r_ BLI_assert(me && GS(me->id.name) == ID_ME); - if (ED_mesh_pick_face(C, ob, mval, &poly_index, dist_px)) { + if (ED_mesh_pick_face(C, ob, mval, dist_px, &poly_index)) { Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); struct ARegion *ar = CTX_wm_region(C); @@ -1184,7 +1189,9 @@ static void ed_mesh_pick_vert__mapFunc(void *userData, int index, const float co } } } -bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], uint *r_index, uint dist_px, bool use_zbuf) +bool ED_mesh_pick_vert( + bContext *C, Object *ob, const int mval[2], uint dist_px, bool use_zbuf, + uint *r_index) { ViewContext vc; Mesh *me = ob->data; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 24a26676df3..a371d8ec93c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -188,15 +188,15 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d); if (use_vert_sel) { - if (ED_mesh_pick_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_VERT_DIST, true)) { + if (ED_mesh_pick_vert(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) { v_idx_best = index; } } else { - if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_DIST)) { + if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { v_idx_best = index; } - else if (ED_mesh_pick_face(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_DIST)) { + else if (ED_mesh_pick_face(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { /* this relies on knowning the internal worksings of ED_mesh_pick_face_vert() */ BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations"); } @@ -312,13 +312,13 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf( ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d); if (use_vert_sel) { - if (ED_mesh_pick_vert(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_DIST, true)) { + if (ED_mesh_pick_vert(C, vc.obact, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) { MDeformVert *dvert = &me->dvert[index]; found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups); } } else { - if (ED_mesh_pick_face(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_FACE_DIST)) { + if (ED_mesh_pick_face(C, vc.obact, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { const MPoly *mp = &me->mpoly[index]; uint fidx = mp->totloop - 1; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 25cc8854607..75f6f9f7c9a 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -533,8 +533,6 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar) { - RegionView3D *rv3d = ar->regiondata; - ED_view3d_stop_render_preview(wm, ar); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 02d469bfa73..6a42c06e59d 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1924,7 +1924,7 @@ static bool ed_wpaint_vertex_select_pick( uint index = 0; MVert *mv; - if (ED_mesh_pick_vert(C, obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_DIST, use_zbuf)) { + if (ED_mesh_pick_vert(C, obact, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, use_zbuf, &index)) { mv = &me->mvert[index]; if (extend) { mv->flag |= SELECT; -- cgit v1.2.3