Commit: ce1670be25c7ee08ab6251463e2ae6fb07edecdb
Author: Phil Gosch
Date:   Tue May 24 16:27:42 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rBce1670be25c7ee08ab6251463e2ae6fb07edecdb

WIP: Added "select shortest path" operator for UVs

Main functionality still missing, calls mesh-tool for selecting shortest path 
if Sync Selection is checked

===================================================================

M       source/blender/editors/include/ED_mesh.h
M       source/blender/editors/mesh/editmesh_path.c
M       source/blender/editors/uvedit/uvedit_ops.c

===================================================================

diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index de798b1..6b1e305 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -128,6 +128,9 @@ void EDBM_flag_disable_all(struct BMEditMesh *em, const 
char hflag);
 bool BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
                        struct ARegion *ar, struct View3D *v3d, struct Object 
*obedit);
 
+/* editmesh_path.c*/
+int EDBM_shortest_path_select(struct bContext *C, struct wmOperator *op);
+
 /* editmesh_select.c */
 void EDBM_select_mirrored(
         struct BMEditMesh *em, const int axis, const bool extend,
diff --git a/source/blender/editors/mesh/editmesh_path.c 
b/source/blender/editors/mesh/editmesh_path.c
index 4431712..a044cb2 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -779,6 +779,11 @@ static int edbm_shortest_path_select_exec(bContext *C, 
wmOperator *op)
        }
 }
 
+int EDBM_shortest_path_select(struct bContext *C, struct wmOperator *op)
+{
+       return edbm_shortest_path_select_exec(C, op);
+}
+
 void MESH_OT_shortest_path_select(wmOperatorType *ot)
 {
        /* identifiers */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c 
b/source/blender/editors/uvedit/uvedit_ops.c
index 193b006..6a6e746 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1472,6 +1472,36 @@ static void UV_OT_select_less(wmOperatorType *ot)
        ot->poll = ED_operator_uvedit_space_image;
 }
 
+/*********************** shortest path ***********************/
+static int uv_shortest_path_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene = CTX_data_scene(C);
+       Object *obedit = CTX_data_edit_object(C);
+       ToolSettings *ts = scene->toolsettings;
+       BMEditMesh *em = BKE_editmesh_from_object(obedit);      
+
+       if (ts->uv_flag & UV_SYNC_SELECTION) {
+               return EDBM_shortest_path_select(C, op);
+       }
+                
+       /* TODO(SaphireS): implementation of operator based on UV islands*/
+
+       return OPERATOR_FINISHED;
+}
+
+static void UV_OT_shortest_path(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Select Shortest Path";
+       ot->description = "Select the shortest path between the current 
selection";
+       ot->idname = "UV_OT_shortest_path";
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+       
+       /* api callbacks */
+       ot->exec = uv_shortest_path_exec;
+       ot->poll = ED_operator_uvedit_space_image;
+}
+
 /* ******************** align operator **************** */
 
 static void uv_weld_align(bContext *C, int tool)
@@ -4246,6 +4276,7 @@ void ED_operatortypes_uvedit(void)
        WM_operatortype_append(UV_OT_circle_select);
        WM_operatortype_append(UV_OT_select_more);
        WM_operatortype_append(UV_OT_select_less);
+       WM_operatortype_append(UV_OT_shortest_path);
 
        WM_operatortype_append(UV_OT_snap_cursor);
        WM_operatortype_append(UV_OT_snap_selected);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to