UV Sticky mode is not respected with Border select #50132

Closed
opened 2016-11-28 12:15:09 +01:00 by Cenek Strichel · 30 comments

Blender Version
2.78a

Short description of error
Sticky mode is not used with border select in UV editor.

If you click on UV: But with border select:
click.png border.png
**Blender Version** 2.78a **Short description of error** Sticky mode is not used with border select in UV editor. |If you click on UV:|But with border select:| | -- | -- | |![click.png](https://archive.blender.org/developer/F407080/click.png)|![border.png](https://archive.blender.org/developer/F407082/border.png)|
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @Cenda

Added subscriber: @Cenda

Added subscriber: @AnthonyEdlin

Added subscriber: @AnthonyEdlin

Can confirm this is current behavior. Also circle select and lasso select also don't follow sticky mode. Not sure if this is desired behavior or not. Shouldn't be that hard to add to those operators, could mark todo for someone that wants an easier task.

Can confirm this is current behavior. Also circle select and lasso select also don't follow sticky mode. Not sure if this is desired behavior or not. Shouldn't be that hard to add to those operators, could mark todo for someone that wants an easier task.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

As noted this doesn't work, but more a case of not being implemented then a software error.

Nice TODO for new developer - move to quick hacks.

As noted this doesn't work, but more a case of not being implemented then a software error. Nice TODO for new developer - move to quick hacks.

Added subscriber: @ShyGuyMath

Added subscriber: @ShyGuyMath
cris self-assigned this 2016-11-30 21:33:20 +01:00

I'd like to try this, if no one has made a claim!

I'd like to try this, if no one has made a claim!

Sure go for it, you can assign me I'll help test and review once you have a patch.

Sure go for it, you can assign me I'll help test and review once you have a patch.
cris removed their assignment 2016-12-01 04:43:27 +01:00
Anthony Edlin was assigned by cris 2016-12-01 04:43:27 +01:00

Okay, cool thanks!

Okay, cool thanks!
Anthony Edlin removed their assignment 2016-12-01 04:52:20 +01:00
cris was assigned by Anthony Edlin 2016-12-01 04:52:20 +01:00
Author

Also Selection Mode is not respected by Border Select. Edge and Island mode is not usable with Border Select.

Also Selection Mode is not respected by Border Select. Edge and Island mode is not usable with Border Select.

Added subscriber: @amdbcg

Added subscriber: @amdbcg
Member

Added subscriber: @DarshanKadu

Added subscriber: @DarshanKadu
Member

Hi is this task done !
I would like to take this task .

Hi is this task done ! I would like to take this task .

Hi darshan, sorry things have been very busy in my life. Yeah you are more then free to take it off my hands.

Hi darshan, sorry things have been very busy in my life. Yeah you are more then free to take it off my hands.

Added subscriber: @umarabdullahi-2

Added subscriber: @umarabdullahi-2

Me too i want to try if you allow

Me too i want to try if you allow
Member

ya sure you can help me in this task !!

ya sure you can help me in this task !!
Member
index 193b006cf0..27525f7755 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2842,6 +2842,65 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object

 /* ********************border select operator**************** */

+bool uv_touched_vetex(int hitv[4], int v, int sticky, int hitlen) {
+       int  i = 0;
+
+       for (i = 0; i<hitlen; i++) {
+               if (hitv[i] == v) {
+                       if (sticky == SI_STICKY_VERTEX)
+                               return true;
+               }
+       }
+
+       return false;
+}
+
+void uv_get_hit_vertex(BMLoop *l, MLoopUV *luv, MLoopUV *luv_next, MTexPoly *tf,
+                                       BMFace *efa,const bool cd_loop_uv_offset, NearestHit *hit ,int index) {
+
+       memset(hit, 0, sizeof(hit));
+
+       hit->l = l;
+       hit->luv = luv;
+       hit->luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+       hit->tf = tf;
+       hit->efa = efa;
+       hit->lindex = index;
+       return;
+}
+
+void uv_select_sticky_border(BMEditMesh *em, Scene *scene, Image *ima, int v, NearestHit *hit, int sticky) {
+       BMFace *efa;
+       BMIter iter, liter;
+       BMLoop *l;
+       MTexPoly *tf;
+       int *hitv = NULL;
+       int hitlen = 0, i = 0;
+
+       const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+       const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
+
+       if (hit->efa == NULL || sticky == SI_STICKY_DISABLE)
+               return;
+
+       hitv = BLI_array_alloca(hitv, hit->efa->len);
+       copy_vn_i(hitv, hit->efa->len, 0xFFFFFFFF);
+       hitv[hit->lindex] = BM_elem_index_get(hit->l->v);
+       hitlen = hit->efa->len;
+       printf("%d    %d\n", hit->efa->len, hitlen);
+       BM_ITER_MESH(efa, &iter, em->bm, BM_FACES_OF_MESH) {
+               tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
+               if (!uvedit_face_visible_test(scene, ima, efa, tf))
+                       continue;
+               BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i) {
+                       if (uv_touched_vetex(hitv, BM_elem_index_get(l->v), sticky, hit->efa->len)) {
+                               uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset);
+                       }
+               }
+       }
+
+}
+
 static int uv_border_select_exec(bContext *C, wmOperator *op)
 {
        SpaceImage *sima = CTX_wm_space_image(C);
@@ -2855,8 +2914,10 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
        BMLoop *l;
        BMIter iter, liter;
        MTexPoly *tf;
-       MLoopUV *luv;
+       MLoopUV *luv ,*luv_next;
+       NearestHit hit;
        rctf rectf;
+       int sticky,i=0;
        bool changed, pinned, select, extend;
        const bool use_face_center = (ts->uv_flag & UV_SYNC_SELECTION) ?
                                    (ts->selectmode == SCE_SELECT_FACE) :
@@ -2874,6 +2935,8 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
        pinned = RNA_boolean_get(op->ptr, "pinned");
        extend = RNA_boolean_get(op->ptr, "extend");

+       sticky = (sima) ? sima->sticky : 1;
+
        if (!extend)
                uv_select_all_perform(scene, ima, em, SEL_DESELECT);

@@ -2911,19 +2974,28 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
                        tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
                        if (!uvedit_face_visible_test(scene, ima, efa, tf))
                                continue;
-                       BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+                       BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
                                luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+                               luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);

                                if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION)) {

                                        /* UV_SYNC_SELECTION - can't do pinned selection */
                                        if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
                                                uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+                                               if (sticky == SI_STICKY_VERTEX) {
+                                                       uv_get_hit_vertex(l, luv, luv_next, tf, efa, cd_loop_uv_offset, &hit, i);
+                                                       uv_select_sticky_border(em, scene, ima, BM_elem_index_get(l->v), &hit, sticky);
+                                               }
                                        }
                                }
                                else if (pinned) {
                                        if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
                                                uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+                                               if (sticky == SI_STICKY_VERTEX) {
+                                                       uv_get_hit_vertex(l, luv, luv_next, tf, efa, cd_loop_uv_offset, &hit, i);
+                                                       uv_select_sticky_border(em, scene, ima, BM_elem_index_get(l->v), &hit, sticky);
+                                               }
                                        }
                                }
                        }

``` index 193b006cf0..27525f7755 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2842,6 +2842,65 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object /* ********************border select operator**************** */ +bool uv_touched_vetex(int hitv[4], int v, int sticky, int hitlen) { + int i = 0; + + for (i = 0; i<hitlen; i++) { + if (hitv[i] == v) { + if (sticky == SI_STICKY_VERTEX) + return true; + } + } + + return false; +} + +void uv_get_hit_vertex(BMLoop *l, MLoopUV *luv, MLoopUV *luv_next, MTexPoly *tf, + BMFace *efa,const bool cd_loop_uv_offset, NearestHit *hit ,int index) { + + memset(hit, 0, sizeof(hit)); + + hit->l = l; + hit->luv = luv; + hit->luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); + hit->tf = tf; + hit->efa = efa; + hit->lindex = index; + return; +} + +void uv_select_sticky_border(BMEditMesh *em, Scene *scene, Image *ima, int v, NearestHit *hit, int sticky) { + BMFace *efa; + BMIter iter, liter; + BMLoop *l; + MTexPoly *tf; + int *hitv = NULL; + int hitlen = 0, i = 0; + + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); + + if (hit->efa == NULL || sticky == SI_STICKY_DISABLE) + return; + + hitv = BLI_array_alloca(hitv, hit->efa->len); + copy_vn_i(hitv, hit->efa->len, 0xFFFFFFFF); + hitv[hit->lindex] = BM_elem_index_get(hit->l->v); + hitlen = hit->efa->len; + printf("%d %d\n", hit->efa->len, hitlen); + BM_ITER_MESH(efa, &iter, em->bm, BM_FACES_OF_MESH) { + tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); + if (!uvedit_face_visible_test(scene, ima, efa, tf)) + continue; + BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i) { + if (uv_touched_vetex(hitv, BM_elem_index_get(l->v), sticky, hit->efa->len)) { + uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset); + } + } + } + +} + static int uv_border_select_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); @@ -2855,8 +2914,10 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) BMLoop *l; BMIter iter, liter; MTexPoly *tf; - MLoopUV *luv; + MLoopUV *luv ,*luv_next; + NearestHit hit; rctf rectf; + int sticky,i=0; bool changed, pinned, select, extend; const bool use_face_center = (ts->uv_flag & UV_SYNC_SELECTION) ? (ts->selectmode == SCE_SELECT_FACE) : @@ -2874,6 +2935,8 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) pinned = RNA_boolean_get(op->ptr, "pinned"); extend = RNA_boolean_get(op->ptr, "extend"); + sticky = (sima) ? sima->sticky : 1; + if (!extend) uv_select_all_perform(scene, ima, em, SEL_DESELECT); @@ -2911,19 +2974,28 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION)) { /* UV_SYNC_SELECTION - can't do pinned selection */ if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) { uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset); + if (sticky == SI_STICKY_VERTEX) { + uv_get_hit_vertex(l, luv, luv_next, tf, efa, cd_loop_uv_offset, &hit, i); + uv_select_sticky_border(em, scene, ima, BM_elem_index_get(l->v), &hit, sticky); + } } } else if (pinned) { if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) { uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset); + if (sticky == SI_STICKY_VERTEX) { + uv_get_hit_vertex(l, luv, luv_next, tf, efa, cd_loop_uv_offset, &hit, i); + uv_select_sticky_border(em, scene, ima, BM_elem_index_get(l->v), &hit, sticky); + } } } } ```
Member

This is the patch i have created for border selection .Using this the sticky mode(veres selection ) for border selection is same as mouse selection.

This is the patch i have created for border selection .Using this the sticky mode(veres selection ) for border selection is same as mouse selection.
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

Please make differential with this patch to make reviewing it a little easier

https://developer.blender.org/differential/diff/create/

Please make differential with this patch to make reviewing it a little easier https://developer.blender.org/differential/diff/create/
Member

https://developer.blender.org/differential/diff/8311/#a335e5e2
this is the diff patch

[[ https://developer.blender.org/differential/diff/8311/#a335e5e2 ]] this is the diff patch
Member

https://developer.blender.org/D2526
this is the differential i have created .

https://developer.blender.org/D2526 this is the differential i have created .

uv_select_sticky_border is called in a loop, this isnt needed since you can use LOOPS_OF_VERT iterator to find all face corners attached to the vertex.

`uv_select_sticky_border` is called in a loop, this isnt needed since you can use LOOPS_OF_VERT iterator to find all face corners attached to the vertex.
cris was unassigned by Campbell Barton 2017-03-03 15:09:48 +01:00
Member

I have updated the diff
Here is the link https://developer.blender.org/D2596

I have updated the diff Here is the link https://developer.blender.org/D2596
Member

Added subscriber: @HugoSales

Added subscriber: @HugoSales
Member

Submitted https://developer.blender.org/D3074 to fix this

Submitted https://developer.blender.org/D3074 to fix this

This issue was referenced by 5d54d6b479

This issue was referenced by 5d54d6b4797111d83e7d945362aa99c86ac17662

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
11 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#50132
No description provided.