Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_select.c')
-rw-r--r--source/blender/editors/uvedit/uvedit_select.c125
1 files changed, 34 insertions, 91 deletions
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c
index 77529ca0275..d227fefbdd1 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -144,22 +144,16 @@ BMLoop *ED_uvedit_active_edge_loop_get(BMesh *bm)
/** \name Visibility and Selection Utilities
* \{ */
-static void uv_select_limit_default(SpaceImage *sima, float r_limit[2])
-{
- uvedit_pixel_to_float(sima, 0.05f, r_limit);
-}
-
/**
* Apply a penalty to elements that are already selected
* so elements that aren't already selected are prioritized.
+ *
+ * \note This is calculated in screen-space otherwise zooming in on a uv-vert and
+ * shift-selecting can consider an adjacent point close enough to add to
+ * the selection rather than de-selecting the closest.
*/
static float uv_select_penalty_default(SpaceImage *sima)
{
- /* Notice 'limit' is the same no matter the zoom level, since this is like
- * remove doubles and could annoying if it joined points when zoomed out.
- * 'penalty' is in screen pixel space otherwise zooming in on a uv-vert and
- * shift-selecting can consider an adjacent point close enough to add to
- * the selection rather than de-selecting the closest. */
float penalty[2];
uvedit_pixel_to_float(sima, 5.0f / (sima ? sima->zoom : 1.0f), penalty);
return len_v2(penalty);
@@ -224,14 +218,13 @@ void uvedit_face_select_set_with_sticky(const SpaceImage *sima,
BMFace *efa,
const bool select,
const bool do_history,
- const float limit[2],
const int cd_loop_uv_offset)
{
BMLoop *l_iter, *l_first;
l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
do {
uvedit_uv_select_set_with_sticky(
- sima, scene, em, l_iter, select, do_history, limit, cd_loop_uv_offset);
+ sima, scene, em, l_iter, select, do_history, cd_loop_uv_offset);
} while ((l_iter = l_iter->next) != l_first);
}
@@ -329,13 +322,11 @@ void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima,
BMLoop *l,
const bool select,
const bool do_history,
- const float limit[2],
const uint cd_loop_uv_offset)
{
+ uvedit_uv_select_set_with_sticky(sima, scene, em, l, select, do_history, cd_loop_uv_offset);
uvedit_uv_select_set_with_sticky(
- sima, scene, em, l, select, do_history, limit, cd_loop_uv_offset);
- uvedit_uv_select_set_with_sticky(
- sima, scene, em, l->next, select, do_history, limit, cd_loop_uv_offset);
+ sima, scene, em, l->next, select, do_history, cd_loop_uv_offset);
}
void uvedit_edge_select_set(const Scene *scene,
@@ -444,7 +435,6 @@ void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima,
BMLoop *l,
const bool select,
const bool do_history,
- const float limit[2],
const uint cd_loop_uv_offset)
{
const ToolSettings *ts = scene->toolsettings;
@@ -477,8 +467,7 @@ void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima,
else {
const MLoopUV *luv_other = BM_ELEM_CD_GET_VOID_P(l_radial_iter,
cd_loop_uv_offset);
- if (fabsf(luv_other->uv[0] - luv->uv[0]) < limit[0] &&
- fabsf(luv_other->uv[1] - luv->uv[1]) < limit[1]) {
+ if (equals_v2v2(luv_other->uv, luv->uv)) {
do_select = true;
}
}
@@ -560,7 +549,6 @@ void uvedit_uv_select_disable(const Scene *scene,
static BMLoop *uvedit_loop_find_other_radial_loop_with_visible_face(Scene *scene,
BMLoop *l_src,
- const float limit[2],
const int cd_loop_uv_offset)
{
BMLoop *l_other = NULL;
@@ -568,7 +556,7 @@ static BMLoop *uvedit_loop_find_other_radial_loop_with_visible_face(Scene *scene
if (l_iter != l_src) {
do {
if (uvedit_face_visible_test(scene, l_iter->f) &&
- BM_loop_uv_share_edge_check_with_limit(l_src, l_iter, limit, cd_loop_uv_offset)) {
+ BM_loop_uv_share_edge_check(l_src, l_iter, cd_loop_uv_offset)) {
/* Check UV's are contiguous. */
if (l_other == NULL) {
l_other = l_iter;
@@ -957,8 +945,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
return true;
}
-static int uv_select_edgeloop(
- Scene *scene, Object *obedit, UvNearestHit *hit, const float limit[2], const bool extend)
+static int uv_select_edgeloop(Scene *scene, Object *obedit, UvNearestHit *hit, const bool extend)
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
@@ -974,7 +961,7 @@ static int uv_select_edgeloop(
/* setup */
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
- vmap = BM_uv_vert_map_create(em->bm, limit, false, false);
+ vmap = BM_uv_vert_map_create(em->bm, false, false);
BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
@@ -1064,12 +1051,8 @@ static int uv_select_edgeloop(
/** \name Edge Ring Select
* \{ */
-static int uv_select_edgering(const SpaceImage *sima,
- Scene *scene,
- Object *obedit,
- UvNearestHit *hit,
- const float limit[2],
- const bool extend)
+static int uv_select_edgering(
+ const SpaceImage *sima, Scene *scene, Object *obedit, UvNearestHit *hit, const bool extend)
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
bool select;
@@ -1091,8 +1074,7 @@ static int uv_select_edgering(const SpaceImage *sima,
BMLoop *l_pair[2] = {
hit->l,
- uvedit_loop_find_other_radial_loop_with_visible_face(
- scene, hit->l, limit, cd_loop_uv_offset),
+ uvedit_loop_find_other_radial_loop_with_visible_face(scene, hit->l, cd_loop_uv_offset),
};
for (int side = 0; side < 2; side++) {
@@ -1104,11 +1086,11 @@ static int uv_select_edgering(const SpaceImage *sima,
}
uvedit_face_select_set_with_sticky(
- sima, scene, em, l_step->f, select, false, limit, cd_loop_uv_offset);
+ sima, scene, em, l_step->f, select, false, cd_loop_uv_offset);
BM_elem_flag_enable(l_step->f, BM_ELEM_TAG);
l_step = uvedit_loop_find_other_radial_loop_with_visible_face(
- scene, l_step->next->next, limit, cd_loop_uv_offset);
+ scene, l_step->next->next, cd_loop_uv_offset);
}
}
@@ -1124,7 +1106,6 @@ static int uv_select_edgering(const SpaceImage *sima,
static void uv_select_linked_multi(Scene *scene,
Object **objects,
const uint objects_len,
- const float limit[2],
UvNearestHit *hit_final,
bool extend,
bool deselect,
@@ -1159,7 +1140,7 @@ static void uv_select_linked_multi(Scene *scene,
*
* Better solve this by having a delimit option for select-linked operator,
* keeping island-select working as is. */
- vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
+ vmap = BM_uv_vert_map_create(em->bm, !select_faces, false);
if (vmap == NULL) {
continue;
@@ -1659,13 +1640,8 @@ void UV_OT_select_all(wmOperatorType *ot)
/** \name Mouse Select Operator
* \{ */
-static bool uv_sticky_select(const float limit[2],
- const int hitv[],
- int v,
- float *hituv[],
- const float uv[2],
- int sticky,
- int hitlen)
+static bool uv_sticky_select(
+ const int hitv[], int v, float *hituv[], const float uv[2], int sticky, int hitlen)
{
/* This function test if some vertex needs to selected
* in addition to the existing ones due to sticky select */
@@ -1676,7 +1652,7 @@ static bool uv_sticky_select(const float limit[2],
for (int i = 0; i < hitlen; i++) {
if (hitv[i] == v) {
if (sticky == SI_STICKY_LOC) {
- if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1]) {
+ if (equals_v2v2(hituv[i], uv)) {
return true;
}
}
@@ -1711,10 +1687,9 @@ static int uv_mouse_select_multi(bContext *C,
/* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */
int flush = 0;
int hitlen = 0;
- float limit[2], **hituv = NULL;
+ float **hituv = NULL;
const float penalty_dist = uv_select_penalty_default(sima);
- uv_select_limit_default(sima, limit);
/* retrieve operation mode */
if (ts->uv_flag & UV_SYNC_SELECTION) {
@@ -1838,7 +1813,7 @@ static int uv_mouse_select_multi(bContext *C,
}
/* Current behavior of 'extend'
* is actually toggling, so pass extend flag as 'toggle' here */
- uv_select_linked_multi(scene, objects, objects_len, limit, &hit, false, false, extend, false);
+ uv_select_linked_multi(scene, objects, objects_len, &hit, false, false, extend, false);
}
else if (extend) {
if (selectmode == UV_SELECT_VERTEX) {
@@ -1879,8 +1854,7 @@ static int uv_mouse_select_multi(bContext *C,
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
+ if (uv_sticky_select(hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_set(scene, em, l, select, false, cd_loop_uv_offset);
}
}
@@ -1921,8 +1895,7 @@ static int uv_mouse_select_multi(bContext *C,
}
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
+ if (uv_sticky_select(hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_enable(scene, em, l, false, cd_loop_uv_offset);
}
@@ -2047,7 +2020,6 @@ static int uv_mouse_select_loop_generic_multi(bContext *C,
bool found_item = false;
/* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */
int flush = 0;
- float limit[2];
/* Find edge. */
found_item = uv_find_nearest_edge_multi(scene, objects, objects_len, co, &hit);
@@ -2058,8 +2030,6 @@ static int uv_mouse_select_loop_generic_multi(bContext *C,
Object *obedit = hit.ob;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
- uv_select_limit_default(sima, limit);
-
/* Do selection. */
if (!extend) {
/* TODO(MULTI_EDIT): We only need to de-select non-active */
@@ -2067,10 +2037,10 @@ static int uv_mouse_select_loop_generic_multi(bContext *C,
}
if (loop_type == UV_LOOP_SELECT) {
- flush = uv_select_edgeloop(scene, obedit, &hit, limit, extend);
+ flush = uv_select_edgeloop(scene, obedit, &hit, extend);
}
else if (loop_type == UV_RING_SELECT) {
- flush = uv_select_edgering(sima, scene, obedit, &hit, limit, extend);
+ flush = uv_select_edgering(sima, scene, obedit, &hit, extend);
}
else {
BLI_assert(0);
@@ -2227,11 +2197,9 @@ void UV_OT_select_edge_ring(wmOperatorType *ot)
static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, bool pick)
{
- SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
const ToolSettings *ts = scene->toolsettings;
ViewLayer *view_layer = CTX_data_view_layer(C);
- float limit[2];
bool extend = true;
bool deselect = false;
bool select_faces = (ts->uv_flag & UV_SYNC_SELECTION) && (ts->selectmode & SCE_SELECT_FACE);
@@ -2249,7 +2217,6 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
extend = RNA_boolean_get(op->ptr, "extend");
deselect = RNA_boolean_get(op->ptr, "deselect");
}
- uv_select_limit_default(sima, limit);
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
@@ -2280,15 +2247,8 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
uv_select_all_perform_multi(scene, objects, objects_len, SEL_DESELECT);
}
- uv_select_linked_multi(scene,
- objects,
- objects_len,
- limit,
- pick ? &hit : NULL,
- extend,
- deselect,
- false,
- select_faces);
+ uv_select_linked_multi(
+ scene, objects, objects_len, pick ? &hit : NULL, extend, deselect, false, select_faces);
/* weak!, but works */
Object **objects_free = objects;
@@ -2633,13 +2593,10 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima,
}
else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) {
struct UvVertMap *vmap;
- float limit[2];
uint efa_index;
- uv_select_limit_default(sima, limit);
-
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
- vmap = BM_uv_vert_map_create(em->bm, limit, false, false);
+ vmap = BM_uv_vert_map_create(em->bm, false, false);
if (vmap == NULL) {
return;
}
@@ -2720,13 +2677,10 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima,
}
else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) {
struct UvVertMap *vmap;
- float limit[2];
uint efa_index;
- uv_select_limit_default(sima, limit);
-
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
- vmap = BM_uv_vert_map_create(em->bm, limit, false, false);
+ vmap = BM_uv_vert_map_create(em->bm, false, false);
if (vmap == NULL) {
return;
}
@@ -2774,7 +2728,6 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
MLoopUV *luv;
rctf rectf;
bool pinned;
- float limit[2];
const bool use_face_center = ((ts->uv_flag & UV_SYNC_SELECTION) ?
(ts->selectmode == SCE_SELECT_FACE) :
(ts->uv_selectmode == UV_SELECT_FACE));
@@ -2792,8 +2745,6 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
pinned = RNA_boolean_get(op->ptr, "pinned");
- uv_select_limit_default(sima, limit);
-
bool changed_multi = false;
uint objects_len = 0;
@@ -2905,8 +2856,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
.ob = obedit,
.efa = efa,
};
- uv_select_linked_multi(
- scene, objects, objects_len, limit, &hit, true, !select, false, false);
+ uv_select_linked_multi(scene, objects, objects_len, &hit, true, !select, false, false);
}
}
@@ -3001,7 +2951,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
MLoopUV *luv;
int x, y, radius, width, height;
float zoomx, zoomy;
- float limit[2], offset[2], ellipse[2];
+ float offset[2], ellipse[2];
const bool use_face_center = ((ts->uv_flag & UV_SYNC_SELECTION) ?
(ts->selectmode == SCE_SELECT_FACE) :
@@ -3025,8 +2975,6 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(&region->v2d, x, y, &offset[0], &offset[1]);
- uv_select_limit_default(sima, limit);
-
bool changed_multi = false;
uint objects_len = 0;
@@ -3128,8 +3076,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
.ob = obedit,
.efa = efa,
};
- uv_select_linked_multi(
- scene, objects, objects_len, limit, &hit, true, !select, false, false);
+ uv_select_linked_multi(scene, objects, objects_len, &hit, true, !select, false, false);
}
}
@@ -3220,12 +3167,9 @@ static bool do_lasso_select_mesh_uv(bContext *C,
BMFace *efa;
BMLoop *l;
- float limit[2];
bool changed_multi = false;
rcti rect;
- uv_select_limit_default(sima, limit);
-
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
uint objects_len = 0;
@@ -3327,8 +3271,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
.ob = obedit,
.efa = efa,
};
- uv_select_linked_multi(
- scene, objects, objects_len, limit, &hit, true, !select, false, false);
+ uv_select_linked_multi(scene, objects, objects_len, &hit, true, !select, false, false);
}
}