[Bf-blender-cvs] [18d18b5a986] master: UV: move sticky selection from image space into tool settings

Campbell Barton noreply at git.blender.org
Wed Feb 16 03:51:28 CET 2022


Commit: 18d18b5a986724d43f45bac63a98400741e8e12a
Author: Campbell Barton
Date:   Wed Feb 16 13:46:00 2022 +1100
Branches: master
https://developer.blender.org/rB18d18b5a986724d43f45bac63a98400741e8e12a

UV: move sticky selection from image space into tool settings

Having this setting stored in the image space caused low level selection
logic to have to pass around the image space (which could be NULL
in some cases). Use the tool-settings instead since there doesn't seem
to be much/any advantage in having this setting per-space.

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

M	release/scripts/startup/bl_ui/space_image.py
M	source/blender/editors/include/ED_uvedit.h
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/editors/uvedit/uvedit_path.c
M	source/blender/editors/uvedit/uvedit_select.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 16e3f32e88a..5b840fae341 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -780,7 +780,7 @@ class IMAGE_HT_header(Header):
                 layout.template_edit_mode_selection()
             else:
                 layout.prop(tool_settings, "uv_select_mode", text="", expand=True)
-                layout.prop(uvedit, "sticky_select_mode", icon_only=True)
+                layout.prop(tool_settings, "uv_sticky_select_mode", icon_only=True)
 
         IMAGE_MT_editor_menus.draw_collapsible(context, layout)
 
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 0c9ddc97508..26af378b1b7 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -97,8 +97,7 @@ bool uvedit_face_select_test(const struct Scene *scene, struct BMFace *efa, int
 bool uvedit_edge_select_test(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset);
 bool uvedit_uv_select_test(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset);
 /* uv face */
-void uvedit_face_select_set_with_sticky(const struct SpaceImage *sima,
-                                        const struct Scene *scene,
+void uvedit_face_select_set_with_sticky(const struct Scene *scene,
                                         struct BMEditMesh *em,
                                         struct BMFace *efa,
                                         bool select,
@@ -120,8 +119,7 @@ void uvedit_face_select_disable(const struct Scene *scene,
                                 struct BMFace *efa,
                                 int cd_loop_uv_offset);
 /* uv edge */
-void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima,
-                                        const struct Scene *scene,
+void uvedit_edge_select_set_with_sticky(const struct Scene *scene,
                                         struct BMEditMesh *em,
                                         struct BMLoop *l,
                                         bool select,
@@ -143,8 +141,7 @@ void uvedit_edge_select_disable(const struct Scene *scene,
                                 struct BMLoop *l,
                                 int cd_loop_uv_offset);
 /* uv vert */
-void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima,
-                                      const struct Scene *scene,
+void uvedit_uv_select_set_with_sticky(const struct Scene *scene,
                                       struct BMEditMesh *em,
                                       struct BMLoop *l,
                                       bool select,
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 3d5b9207ad1..ccaabe18620 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1572,7 +1572,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op)
   const ToolSettings *ts = scene->toolsettings;
 
   const bool use_face_center = (ts->uv_selectmode == UV_SELECT_FACE);
-  const bool stickymode = sima ? (sima->sticky != SI_STICKY_DISABLE) : 1;
+  const bool stickymode = sima ? (ts->uv_sticky != SI_STICKY_DISABLE) : 1;
   const bool select = RNA_boolean_get(op->ptr, "select");
 
   uint objects_len = 0;
diff --git a/source/blender/editors/uvedit/uvedit_path.c b/source/blender/editors/uvedit/uvedit_path.c
index 225b595852f..33621c1f0b6 100644
--- a/source/blender/editors/uvedit/uvedit_path.c
+++ b/source/blender/editors/uvedit/uvedit_path.c
@@ -138,7 +138,6 @@ struct PathSelectParams {
 };
 
 struct UserData_UV {
-  const SpaceImage *sima;
   Scene *scene;
   BMEditMesh *em;
   uint cd_loop_uv_offset;
@@ -226,8 +225,7 @@ static void looptag_set_cb(BMLoop *l, bool val, void *user_data_v)
   }
 }
 
-static int mouse_mesh_uv_shortest_path_vert(const SpaceImage *sima,
-                                            Scene *scene,
+static int mouse_mesh_uv_shortest_path_vert(Scene *scene,
                                             Object *obedit,
                                             const struct PathSelectParams *op_params,
                                             BMLoop *l_src,
@@ -269,7 +267,6 @@ static int mouse_mesh_uv_shortest_path_vert(const SpaceImage *sima,
   }
 
   struct UserData_UV user_data = {
-      .sima = sima,
       .scene = scene,
       .em = em,
       .cd_loop_uv_offset = cd_loop_uv_offset,
@@ -389,15 +386,13 @@ static bool facetag_test_cb(BMFace *f, void *user_data_v)
 static void facetag_set_cb(BMFace *f, bool val, void *user_data_v)
 {
   struct UserData_UV *user_data = user_data_v;
-  const SpaceImage *sima = user_data->sima;
   const Scene *scene = user_data->scene;
   BMEditMesh *em = user_data->em;
   const uint cd_loop_uv_offset = user_data->cd_loop_uv_offset;
-  uvedit_face_select_set_with_sticky(sima, scene, em, f, val, false, cd_loop_uv_offset);
+  uvedit_face_select_set_with_sticky(scene, em, f, val, false, cd_loop_uv_offset);
 }
 
-static int mouse_mesh_uv_shortest_path_face(const SpaceImage *sima,
-                                            Scene *scene,
+static int mouse_mesh_uv_shortest_path_face(Scene *scene,
                                             Object *obedit,
                                             const struct PathSelectParams *op_params,
                                             BMFace *f_src,
@@ -410,7 +405,6 @@ static int mouse_mesh_uv_shortest_path_face(const SpaceImage *sima,
   int flush = 0;
 
   struct UserData_UV user_data = {
-      .sima = sima,
       .scene = scene,
       .em = em,
       .cd_loop_uv_offset = cd_loop_uv_offset,
@@ -489,8 +483,7 @@ static int mouse_mesh_uv_shortest_path_face(const SpaceImage *sima,
 
 static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op);
 
-static bool uv_shortest_path_pick_ex(const SpaceImage *sima,
-                                     Scene *scene,
+static bool uv_shortest_path_pick_ex(Scene *scene,
                                      Depsgraph *depsgraph,
                                      Object *obedit,
                                      const struct PathSelectParams *op_params,
@@ -508,8 +501,7 @@ static bool uv_shortest_path_pick_ex(const SpaceImage *sima,
     /* pass */
   }
   else if (ele_src->head.htype == BM_FACE) {
-    flush = mouse_mesh_uv_shortest_path_face(sima,
-                                             scene,
+    flush = mouse_mesh_uv_shortest_path_face(scene,
                                              obedit,
                                              op_params,
                                              (BMFace *)ele_src,
@@ -519,8 +511,7 @@ static bool uv_shortest_path_pick_ex(const SpaceImage *sima,
     ok = true;
   }
   else if (ele_src->head.htype == BM_LOOP) {
-    flush = mouse_mesh_uv_shortest_path_vert(sima,
-                                             scene,
+    flush = mouse_mesh_uv_shortest_path_vert(scene,
                                              obedit,
                                              op_params,
                                              (BMLoop *)ele_src,
@@ -560,7 +551,6 @@ static bool uv_shortest_path_pick_ex(const SpaceImage *sima,
 
 static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
-  SpaceImage *sima = CTX_wm_space_image(C);
   Scene *scene = CTX_data_scene(C);
   const ToolSettings *ts = scene->toolsettings;
   const char uv_selectmode = ED_uvedit_select_mode_get(scene);
@@ -667,7 +657,7 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
   }
 
   uv_shortest_path_pick_ex(
-      sima, scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset);
+      scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset);
 
   /* To support redo. */
   int index;
@@ -691,7 +681,6 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
 static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op)
 {
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
-  const SpaceImage *sima = CTX_wm_space_image(C);
   Scene *scene = CTX_data_scene(C);
   const char uv_selectmode = ED_uvedit_select_mode_get(scene);
   Object *obedit = CTX_data_edit_object(C);
@@ -742,15 +731,8 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op)
   path_select_params_from_op(op, &op_params);
   op_params.track_active = true;
 
-  if (!uv_shortest_path_pick_ex(sima,
-                                scene,
-                                depsgraph,
-                                obedit,
-                                &op_params,
-                                ele_src,
-                                ele_dst,
-                                aspect_y,
-                                cd_loop_uv_offset)) {
+  if (!uv_shortest_path_pick_ex(
+          scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, cd_loop_uv_offset)) {
     return OPERATOR_CANCELLED;
   }
 
@@ -791,7 +773,6 @@ void UV_OT_shortest_path_pick(wmOperatorType *ot)
 static int uv_shortest_path_select_exec(bContext *C, wmOperator *op)
 {
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
-  const SpaceImage *sima = CTX_wm_space_image(C);
   Scene *scene = CTX_data_scene(C);
   const char uv_selectmode = ED_uvedit_select_mode_get(scene);
   bool found_valid_elements = false;
@@ -840,15 +821,8 @@ static int uv_shortest_path_select_exec(bContext *C, wmOperator *op)
       struct PathSelectParams op_params;
       path_select_params_from_op(op, &op_params);
 
-      uv_shortest_path_pick_ex(sima,
-                               scene,
-                               depsgraph,
-                               obedit,
-                               &op_params,
-                               ele_src,
-                               ele_dst,
-                               aspect_y,
-                               cd_loop_uv_offset);
+      uv_shortest_path_pick_ex(
+          scene, depsgraph, obedit, &op_para

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list