diff options
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_select.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_select.c | 104 |
1 files changed, 60 insertions, 44 deletions
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index ca66981cd3a..938b798f4b6 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -55,18 +55,21 @@ #include "uvedit_intern.h" -static void uv_select_all_perform(Scene *scene, Object *obedit, int action); - -static void uv_select_all_perform_multi_ex( - Scene *scene, Object **objects, const uint objects_len, int action, const Object *ob_exclude); -static void uv_select_all_perform_multi(Scene *scene, +static void uv_select_all_perform(const Scene *scene, Object *obedit, int action); + +static void uv_select_all_perform_multi_ex(const Scene *scene, + Object **objects, + const uint objects_len, + int action, + const Object *ob_exclude); +static void uv_select_all_perform_multi(const Scene *scene, Object **objects, const uint objects_len, int action); -static void uv_select_flush_from_tag_face(Scene *scene, Object *obedit, const bool select); -static void uv_select_flush_from_tag_loop(Scene *scene, Object *obedit, const bool select); -static void uv_select_flush_from_loop_edge_flag(Scene *scene, BMEditMesh *em); +static void uv_select_flush_from_tag_face(const Scene *scene, Object *obedit, const bool select); +static void uv_select_flush_from_tag_loop(const Scene *scene, Object *obedit, const bool select); +static void uv_select_flush_from_loop_edge_flag(const Scene *scene, BMEditMesh *em); static void uv_select_tag_update_for_object(Depsgraph *depsgraph, const ToolSettings *ts, @@ -435,7 +438,7 @@ void uvedit_edge_select_shared_vert(const Scene *scene, const bool do_history, const int cd_loop_uv_offset) { - BLI_assert((sticky_flag == SI_STICKY_LOC) || (sticky_flag == SI_STICKY_VERTEX)); + BLI_assert(ELEM(sticky_flag, SI_STICKY_LOC, SI_STICKY_VERTEX)); /* Set edge flags. Rely on this for face visibility checks */ uvedit_edge_select_set_noflush(scene, l, select, sticky_flag, cd_loop_uv_offset); @@ -644,7 +647,7 @@ void uvedit_uv_select_shared_vert(const Scene *scene, const bool do_history, const int cd_loop_uv_offset) { - BLI_assert((sticky_flag == SI_STICKY_LOC) || (sticky_flag == SI_STICKY_VERTEX)); + BLI_assert(ELEM(sticky_flag, SI_STICKY_LOC, SI_STICKY_VERTEX)); BMEdge *e_first, *e_iter; e_first = e_iter = l->e; @@ -1200,7 +1203,10 @@ bool uvedit_vert_is_all_other_faces_selected(const Scene *scene, /** * Clear specified UV flag (vert/edge/pinned). */ -static void bm_uv_flag_clear(Scene *scene, BMesh *bm, const int flag, const int cd_loop_uv_offset) +static void bm_uv_flag_clear(const Scene *scene, + BMesh *bm, + const int flag, + const int cd_loop_uv_offset) { BMFace *efa; BMLoop *l; @@ -1223,12 +1229,13 @@ static void bm_uv_flag_clear(Scene *scene, BMesh *bm, const int flag, const int * * \{ */ -void ED_uvedit_selectmode_flush(Scene *scene, BMEditMesh *em) +void ED_uvedit_selectmode_flush(const Scene *scene, BMEditMesh *em) { - ToolSettings *ts = scene->toolsettings; + const ToolSettings *ts = scene->toolsettings; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); BLI_assert((ts->uv_flag & UV_SYNC_SELECTION) == 0); + UNUSED_VARS_NDEBUG(ts); /* Vertex Mode only. */ if (ts->uv_selectmode & UV_SELECT_VERTEX) { @@ -1261,14 +1268,15 @@ void ED_uvedit_selectmode_flush(Scene *scene, BMEditMesh *em) /** \name UV Flush selection (up/down) * \{ */ -/* Careful when using this in face select mode. - * For face selections with sticky mode enabled, this can create invalid selection states. */ -void uvedit_select_flush(Scene *scene, BMEditMesh *em) +void uvedit_select_flush(const Scene *scene, BMEditMesh *em) { - ToolSettings *ts = scene->toolsettings; + /* Careful when using this in face select mode. + * For face selections with sticky mode enabled, this can create invalid selection states. */ + const ToolSettings *ts = scene->toolsettings; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); BLI_assert((ts->uv_flag & UV_SYNC_SELECTION) == 0); + UNUSED_VARS_NDEBUG(ts); BMFace *efa; BMLoop *l; @@ -1289,12 +1297,13 @@ void uvedit_select_flush(Scene *scene, BMEditMesh *em) } } -void uvedit_deselect_flush(Scene *scene, BMEditMesh *em) +void uvedit_deselect_flush(const Scene *scene, BMEditMesh *em) { - ToolSettings *ts = scene->toolsettings; + const ToolSettings *ts = scene->toolsettings; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); BLI_assert((ts->uv_flag & UV_SYNC_SELECTION) == 0); + UNUSED_VARS_NDEBUG(ts); BMFace *efa; BMLoop *l; @@ -1711,7 +1720,7 @@ static int uv_select_edgering(Scene *scene, Object *obedit, UvNearestHit *hit, c if (select && uvedit_edge_select_test(scene, l_step, cd_loop_uv_offset)) { break; } - else if (!select && !uvedit_edge_select_test(scene, l_step, cd_loop_uv_offset)) { + if (!select && !uvedit_edge_select_test(scene, l_step, cd_loop_uv_offset)) { break; } } @@ -2163,7 +2172,7 @@ void UV_OT_select_less(wmOperatorType *ot) /** \name (De)Select All Operator * \{ */ -bool uvedit_select_is_any_selected(Scene *scene, Object *obedit) +bool uvedit_select_is_any_selected(const Scene *scene, Object *obedit) { const ToolSettings *ts = scene->toolsettings; BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -2191,7 +2200,9 @@ bool uvedit_select_is_any_selected(Scene *scene, Object *obedit) return false; } -bool uvedit_select_is_any_selected_multi(Scene *scene, Object **objects, const uint objects_len) +bool uvedit_select_is_any_selected_multi(const Scene *scene, + Object **objects, + const uint objects_len) { bool found = false; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { @@ -2204,7 +2215,7 @@ bool uvedit_select_is_any_selected_multi(Scene *scene, Object **objects, const u return found; } -static void uv_select_all(Scene *scene, BMEditMesh *em, bool select_all) +static void uv_select_all(const Scene *scene, BMEditMesh *em, bool select_all) { BMFace *efa; BMLoop *l; @@ -2223,7 +2234,7 @@ static void uv_select_all(Scene *scene, BMEditMesh *em, bool select_all) } } -static void uv_select_invert(Scene *scene, BMEditMesh *em) +static void uv_select_invert(const Scene *scene, BMEditMesh *em) { const ToolSettings *ts = scene->toolsettings; BLI_assert((ts->uv_flag & UV_SYNC_SELECTION) == 0); @@ -2240,13 +2251,13 @@ static void uv_select_invert(Scene *scene, BMEditMesh *em) } BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - if ((uv_selectmode == UV_SELECT_EDGE) || (uv_selectmode == UV_SELECT_FACE)) { + if (ELEM(uv_selectmode, UV_SELECT_EDGE, UV_SELECT_FACE)) { /* Use #MLOOPUV_EDGESEL to flag edges that must be selected. */ luv->flag ^= MLOOPUV_EDGESEL; luv->flag &= ~MLOOPUV_VERTSEL; } /* Use #MLOOPUV_VERTSEL to flag verts that must be selected. */ - else if ((uv_selectmode == UV_SELECT_VERTEX) || (uv_selectmode == UV_SELECT_ISLAND)) { + else if (ELEM(uv_selectmode, UV_SELECT_VERTEX, UV_SELECT_ISLAND)) { luv->flag ^= MLOOPUV_VERTSEL; luv->flag &= ~MLOOPUV_EDGESEL; } @@ -2254,15 +2265,15 @@ static void uv_select_invert(Scene *scene, BMEditMesh *em) } /* Flush based on uv vert/edge flags and current UV select mode */ - if ((uv_selectmode == UV_SELECT_EDGE) || (uv_selectmode == UV_SELECT_FACE)) { + if (ELEM(uv_selectmode, UV_SELECT_EDGE, UV_SELECT_FACE)) { uv_select_flush_from_loop_edge_flag(scene, em); } - else if ((uv_selectmode == UV_SELECT_VERTEX) || (uv_selectmode == UV_SELECT_ISLAND)) { + else if (ELEM(uv_selectmode, UV_SELECT_VERTEX, UV_SELECT_ISLAND)) { uvedit_select_flush(scene, em); } } -static void uv_select_all_perform(Scene *scene, Object *obedit, int action) +static void uv_select_all_perform(const Scene *scene, Object *obedit, int action) { const ToolSettings *ts = scene->toolsettings; BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -2303,8 +2314,11 @@ static void uv_select_all_perform(Scene *scene, Object *obedit, int action) } } -static void uv_select_all_perform_multi_ex( - Scene *scene, Object **objects, const uint objects_len, int action, const Object *ob_exclude) +static void uv_select_all_perform_multi_ex(const Scene *scene, + Object **objects, + const uint objects_len, + int action, + const Object *ob_exclude) { if (action == SEL_TOGGLE) { action = uvedit_select_is_any_selected_multi(scene, objects, objects_len) ? SEL_DESELECT : @@ -2320,7 +2334,7 @@ static void uv_select_all_perform_multi_ex( } } -static void uv_select_all_perform_multi(Scene *scene, +static void uv_select_all_perform_multi(const Scene *scene, Object **objects, const uint objects_len, int action) @@ -3133,7 +3147,7 @@ static void uv_select_tag_update_for_object(Depsgraph *depsgraph, /** * helper function for #uv_select_flush_from_tag_loop and uv_select_flush_from_tag_face */ -static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, +static void uv_select_flush_from_tag_sticky_loc_internal(const Scene *scene, BMEditMesh *em, UvVertMap *vmap, const uint efa_index, @@ -3191,7 +3205,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, * \note This function is very similar to #uv_select_flush_from_tag_loop, * be sure to update both upon changing. */ -static void uv_select_flush_from_tag_face(Scene *scene, Object *obedit, const bool select) +static void uv_select_flush_from_tag_face(const Scene *scene, Object *obedit, const bool select) { /* Selecting UV Faces with some modes requires us to change * the selection in other faces (depending on the sticky mode). @@ -3207,7 +3221,7 @@ static void uv_select_flush_from_tag_face(Scene *scene, Object *obedit, const bo const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && - ((ts->uv_sticky == SI_STICKY_VERTEX) || (ts->uv_sticky == SI_STICKY_LOC))) { + ELEM(ts->uv_sticky, SI_STICKY_VERTEX, SI_STICKY_LOC)) { struct UvVertMap *vmap; uint efa_index; @@ -3260,7 +3274,7 @@ static void uv_select_flush_from_tag_face(Scene *scene, Object *obedit, const bo * \note This function is very similar to #uv_select_flush_from_tag_face, * be sure to update both upon changing. */ -static void uv_select_flush_from_tag_loop(Scene *scene, Object *obedit, const bool select) +static void uv_select_flush_from_tag_loop(const Scene *scene, Object *obedit, const bool select) { /* Selecting UV Loops with some modes requires us to change * the selection in other faces (depending on the sticky mode). @@ -3342,7 +3356,7 @@ static void uv_select_flush_from_tag_loop(Scene *scene, Object *obedit, const bo * * \note Current behavior is selecting only; deselecting can be added but the behavior isn't * required anywhere.*/ -static void uv_select_flush_from_loop_edge_flag(Scene *scene, BMEditMesh *em) +static void uv_select_flush_from_loop_edge_flag(const Scene *scene, BMEditMesh *em) { const ToolSettings *ts = scene->toolsettings; BMFace *efa; @@ -3352,7 +3366,7 @@ static void uv_select_flush_from_loop_edge_flag(Scene *scene, BMEditMesh *em) const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && - ((ts->uv_sticky == SI_STICKY_LOC) || (ts->uv_sticky == SI_STICKY_VERTEX))) { + ELEM(ts->uv_sticky, SI_STICKY_LOC, SI_STICKY_VERTEX)) { /* Use the #MLOOPUV_EDGESEL flag to identify which verts must to be selected */ struct UvVertMap *vmap; uint efa_index; @@ -4355,7 +4369,7 @@ void UV_OT_select_overlap(wmOperatorType *ot) * So an edge that has two connected edge loops only assigns one loop in the array. * \{ */ -BMFace **ED_uvedit_selected_faces(Scene *scene, BMesh *bm, int len_max, int *r_faces_len) +BMFace **ED_uvedit_selected_faces(const Scene *scene, BMesh *bm, int len_max, int *r_faces_len) { const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); CLAMP_MAX(len_max, bm->totface); @@ -4383,7 +4397,7 @@ finally: return faces; } -BMLoop **ED_uvedit_selected_edges(Scene *scene, BMesh *bm, int len_max, int *r_edges_len) +BMLoop **ED_uvedit_selected_edges(const Scene *scene, BMesh *bm, int len_max, int *r_edges_len) { const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); CLAMP_MAX(len_max, bm->totloop); @@ -4439,7 +4453,7 @@ finally: return edges; } -BMLoop **ED_uvedit_selected_verts(Scene *scene, BMesh *bm, int len_max, int *r_verts_len) +BMLoop **ED_uvedit_selected_verts(const Scene *scene, BMesh *bm, int len_max, int *r_verts_len) { const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); CLAMP_MAX(len_max, bm->totloop); @@ -4505,7 +4519,9 @@ finally: * * Use only when sync select disabled. */ -static void uv_isolate_selected_islands(Scene *scene, BMEditMesh *em, const int cd_loop_uv_offset) +static void uv_isolate_selected_islands(const Scene *scene, + BMEditMesh *em, + const int cd_loop_uv_offset) { BLI_assert((scene->toolsettings->uv_flag & UV_SYNC_SELECTION) == 0); BMFace *efa; @@ -4553,9 +4569,9 @@ static void uv_isolate_selected_islands(Scene *scene, BMEditMesh *em, const int MEM_freeN(is_island_not_selected); } -void ED_uvedit_selectmode_clean(Scene *scene, Object *obedit) +void ED_uvedit_selectmode_clean(const Scene *scene, Object *obedit) { - ToolSettings *ts = scene->toolsettings; + const ToolSettings *ts = scene->toolsettings; BLI_assert((ts->uv_flag & UV_SYNC_SELECTION) == 0); BMEditMesh *em = BKE_editmesh_from_object(obedit); char sticky = ts->uv_sticky; |