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:
authorCampbell Barton <ideasman42@gmail.com>2009-12-22 20:18:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-22 20:18:33 +0300
commitb3d30c66babbd656647bcdead36db00d7e52cd5d (patch)
tree12055b6bbca7c9f317a9150a0756d45782889de4 /source/blender/editors/uvedit
parent22a892f4024db7da71ccdced00bf494c28443510 (diff)
select linked and select linked pick working again (wth shift for extend)
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c93
1 files changed, 80 insertions, 13 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 3d58e7f03dc..b592d5a62f1 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -835,15 +835,16 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2]
MTFace *tf;
UvVertMap *vmap;
UvMapVert *vlist, *iterv, *startv;
- int a, i, nverts, j, stacksize= 0, *stack;
+ int a, i, nverts, stacksize= 0, *stack;
char *flag;
- vmap= EM_make_uv_vert_map(em, 1, 1, limit);
+ EM_init_index_arrays(em, 0, 0, 1); /* we can use this too */
+ vmap= EM_make_uv_vert_map(em, 1, 0, limit);
if(vmap == NULL)
return;
- stack= MEM_mallocN(sizeof(*stack)* BLI_countlist(&em->faces), "UvLinkStack");
- flag= MEM_callocN(sizeof(*flag)*BLI_countlist(&em->faces), "UvLinkFlag");
+ stack= MEM_mallocN(sizeof(*stack) * em->totface, "UvLinkStack");
+ flag= MEM_callocN(sizeof(*flag) * em->totface, "UvLinkFlag");
if(!hit) {
for(a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
@@ -872,10 +873,8 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2]
while(stacksize > 0) {
stacksize--;
a= stack[stacksize];
-
- for(j=0, efa= em->faces.first; efa; efa= efa->next, j++)
- if(j==a)
- break;
+
+ efa = EM_get_face_for_index(a);
nverts= efa->v4? 4: 3;
@@ -897,14 +896,14 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2]
break;
else if(!flag[iterv->f]) {
flag[iterv->f]= 1;
- stack[stacksize]= iterv->f;;
+ stack[stacksize]= iterv->f;
stacksize++;
}
}
}
}
- if(!extend && hit) {
+ if(!extend) {
for(a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(flag[a])
@@ -913,7 +912,7 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2]
tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
}
}
- else if(extend && hit) {
+ else {
for(a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
if(flag[a]) {
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -947,6 +946,7 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2]
MEM_freeN(stack);
MEM_freeN(flag);
EM_free_uv_vert_map(vmap);
+ EM_free_index_arrays();
}
/* ******************** align operator **************** */
@@ -1814,7 +1814,7 @@ void UV_OT_select_loop(wmOperatorType *ot)
/* ******************** linked select operator **************** */
-static int select_linked_exec(bContext *C, wmOperator *op)
+static select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, int pick)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
@@ -1825,6 +1825,8 @@ static int select_linked_exec(bContext *C, wmOperator *op)
float limit[2];
int extend;
+ NearestHit hit, *hit_p= NULL;
+
if(ts->uv_flag & UV_SYNC_SELECTION) {
BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled.");
BKE_mesh_end_editmesh(obedit->data, em);
@@ -1833,7 +1835,31 @@ static int select_linked_exec(bContext *C, wmOperator *op)
extend= RNA_boolean_get(op->ptr, "extend");
uvedit_pixel_to_float(sima, limit, 0.05f);
- select_linked(scene, ima, em, limit, NULL, extend);
+
+ if(pick) {
+ float co[2];
+
+ if(event) {
+ /* invoke */
+ ARegion *ar= CTX_wm_region(C);
+ int x, y;
+
+ x= event->x - ar->winrct.xmin;
+ y= event->y - ar->winrct.ymin;
+
+ UI_view2d_region_to_view(&ar->v2d, x, y, &co[0], &co[1]);
+ RNA_float_set_array(op->ptr, "location", co);
+ }
+ else {
+ /* exec */
+ RNA_float_get_array(op->ptr, "location", co);
+ }
+
+ find_nearest_uv_vert(scene, ima, em, co, NULL, &hit);
+ hit_p= &hit;
+ }
+
+ select_linked(scene, ima, em, limit, hit_p, extend);
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
@@ -1842,6 +1868,11 @@ static int select_linked_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int select_linked_exec(bContext *C, wmOperator *op)
+{
+ return select_linked_internal(C, op, NULL, 0);
+}
+
void UV_OT_select_linked(wmOperatorType *ot)
{
/* identifiers */
@@ -1859,6 +1890,37 @@ void UV_OT_select_linked(wmOperatorType *ot)
"Extend", "Extend selection rather than clearing the existing selection.");
}
+static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ return select_linked_internal(C, op, event, 1);
+}
+
+static int select_linked_pick_exec(bContext *C, wmOperator *op)
+{
+ return select_linked_internal(C, op, NULL, 1);
+}
+
+void UV_OT_select_linked_pick(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Select Linked Pick";
+ ot->description= "Select all UV vertices linked under the mouse.";
+ ot->idname= "UV_OT_select_linked_pick";
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* api callbacks */
+ ot->invoke= select_linked_pick_invoke;
+ ot->exec= select_linked_pick_exec;
+ ot->poll= ED_operator_uvedit;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", 0,
+ "Extend", "Extend selection rather than clearing the existing selection.");
+
+ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
+ "Location", "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds.", -100.0f, 100.0f);
+}
+
/* ******************** unlink selection operator **************** */
static int unlink_selection_exec(bContext *C, wmOperator *op)
@@ -3101,6 +3163,7 @@ void ED_operatortypes_uvedit(void)
WM_operatortype_append(UV_OT_select);
WM_operatortype_append(UV_OT_select_loop);
WM_operatortype_append(UV_OT_select_linked);
+ WM_operatortype_append(UV_OT_select_linked_pick);
WM_operatortype_append(UV_OT_unlink_selection);
WM_operatortype_append(UV_OT_select_pinned);
WM_operatortype_append(UV_OT_select_border);
@@ -3151,6 +3214,10 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
/* selection manipulation */
WM_keymap_add_item(keymap, "UV_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "UV_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select_linked", LKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "extend", TRUE);
+ RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE);
+
WM_keymap_add_item(keymap, "UV_OT_unlink_selection", LKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "UV_OT_select_all", AKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "UV_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);