[Bf-blender-cvs] [b0482728255] master: Cleanup: split selection operations into uvedit_select.c

Campbell Barton noreply at git.blender.org
Mon May 4 09:10:58 CEST 2020


Commit: b0482728255bff3d0dc689281267343fd4d8dc1a
Author: Campbell Barton
Date:   Mon May 4 16:39:59 2020 +1000
Branches: master
https://developer.blender.org/rBb0482728255bff3d0dc689281267343fd4d8dc1a

Cleanup: split selection operations into uvedit_select.c

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

M	source/blender/editors/uvedit/CMakeLists.txt
M	source/blender/editors/uvedit/uvedit_intern.h
M	source/blender/editors/uvedit/uvedit_ops.c
A	source/blender/editors/uvedit/uvedit_select.c

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

diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt
index d2ba9ab9591..b40b82c50fb 100644
--- a/source/blender/editors/uvedit/CMakeLists.txt
+++ b/source/blender/editors/uvedit/CMakeLists.txt
@@ -40,6 +40,7 @@ set(SRC
   uvedit_draw.c
   uvedit_ops.c
   uvedit_parametrizer.c
+  uvedit_select.c
   uvedit_smart_stitch.c
   uvedit_unwrap_ops.c
 
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index 7bc6b048585..737e0f65908 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -99,6 +99,7 @@ bool uv_find_nearest_face_multi(struct Scene *scene,
 void uvedit_live_unwrap_update(struct SpaceImage *sima,
                                struct Scene *scene,
                                struct Object *obedit);
+void uvedit_pixel_to_float(struct SpaceImage *sima, float r_dist[2], float pixeldist);
 
 /* operators */
 
@@ -113,4 +114,31 @@ void UV_OT_sphere_project(struct wmOperatorType *ot);
 void UV_OT_unwrap(struct wmOperatorType *ot);
 void UV_OT_stitch(struct wmOperatorType *ot);
 
+/* uvedit_select.c */
+
+bool uvedit_select_is_any_selected(struct Scene *scene, struct Image *ima, struct Object *obedit);
+bool uvedit_select_is_any_selected_multi(struct Scene *scene,
+                                         struct Image *ima,
+                                         struct Object **objects,
+                                         const uint objects_len);
+float *uv_sel_co_from_eve(struct Scene *scene,
+                          struct Object *obedit,
+                          struct Image *ima,
+                          struct BMEditMesh *em,
+                          struct BMVert *eve);
+
+void UV_OT_select_all(struct wmOperatorType *ot);
+void UV_OT_select(struct wmOperatorType *ot);
+void UV_OT_select_loop(struct wmOperatorType *ot);
+void UV_OT_select_linked(struct wmOperatorType *ot);
+void UV_OT_select_linked_pick(struct wmOperatorType *ot);
+void UV_OT_select_split(struct wmOperatorType *ot);
+void UV_OT_select_pinned(struct wmOperatorType *ot);
+void UV_OT_select_box(struct wmOperatorType *ot);
+void UV_OT_select_lasso(struct wmOperatorType *ot);
+void UV_OT_select_circle(struct wmOperatorType *ot);
+void UV_OT_select_more(struct wmOperatorType *ot);
+void UV_OT_select_less(struct wmOperatorType *ot);
+void UV_OT_select_overlap(struct wmOperatorType *ot);
+
 #endif /* __UVEDIT_INTERN_H__ */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index e169222380e..e8ebe0aa709 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -36,15 +36,9 @@
 #include "DNA_scene_types.h"
 #include "DNA_space_types.h"
 
-#include "BLI_alloca.h"
 #include "BLI_array.h"
-#include "BLI_blenlib.h"
-#include "BLI_hash.h"
-#include "BLI_kdopbvh.h"
 #include "BLI_kdtree.h"
-#include "BLI_lasso_2d.h"
 #include "BLI_math.h"
-#include "BLI_polyfill_2d.h"
 #include "BLI_utildefines.h"
 
 #include "BLT_translation.h"
@@ -52,31 +46,22 @@
 #include "BKE_context.h"
 #include "BKE_customdata.h"
 #include "BKE_editmesh.h"
-#include "BKE_image.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
-#include "BKE_mesh.h"
 #include "BKE_mesh_mapping.h"
 #include "BKE_node.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
 
 #include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
 
 #include "ED_image.h"
 #include "ED_mesh.h"
 #include "ED_node.h"
-#include "ED_object.h"
 #include "ED_screen.h"
-#include "ED_select_utils.h"
-#include "ED_transform.h"
 #include "ED_uvedit.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
-#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_message.h"
@@ -88,26 +73,6 @@
 
 #include "uvedit_intern.h"
 
-static bool uv_select_is_any_selected(Scene *scene, Image *ima, Object *obedit);
-static bool uv_select_is_any_selected_multi(Scene *scene,
-                                            Image *ima,
-                                            Object **objects,
-                                            const uint objects_len);
-static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, int action);
-static void uv_select_all_perform_multi(
-    Scene *scene, Image *ima, Object **objects, const uint objects_len, int action);
-static void uv_select_flush_from_tag_face(SpaceImage *sima,
-                                          Scene *scene,
-                                          Object *obedit,
-                                          const bool select);
-static void uv_select_flush_from_tag_loop(SpaceImage *sima,
-                                          Scene *scene,
-                                          Object *obedit,
-                                          const bool select);
-static void uv_select_tag_update_for_object(Depsgraph *depsgraph,
-                                            const ToolSettings *ts,
-                                            Object *obedit);
-
 /* -------------------------------------------------------------------- */
 /** \name State Testing
  * \{ */
@@ -225,7 +190,7 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i
 /** \name Space Conversion
  * \{ */
 
-static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist)
+void uvedit_pixel_to_float(SpaceImage *sima, float r_dist[2], float pixeldist)
 {
   int width, height;
 
@@ -237,351 +202,8 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist
     height = IMG_SIZE_FALLBACK;
   }
 
-  dist[0] = pixeldist / width;
-  dist[1] = pixeldist / height;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Visibility and Selection Utilities
- * \{ */
-
-static void uvedit_vertex_select_tagged(BMEditMesh *em,
-                                        Scene *scene,
-                                        bool select,
-                                        int cd_loop_uv_offset)
-{
-  BMFace *efa;
-  BMLoop *l;
-  BMIter iter, liter;
-
-  BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-    BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
-      if (BM_elem_flag_test(l->v, BM_ELEM_TAG)) {
-        uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
-      }
-    }
-  }
-}
-
-bool uvedit_face_visible_nolocal_ex(const ToolSettings *ts, BMFace *efa)
-{
-  if (ts->uv_flag & UV_SYNC_SELECTION) {
-    return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0);
-  }
-  else {
-    return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
-  }
-}
-bool uvedit_face_visible_nolocal(const Scene *scene, BMFace *efa)
-{
-  return uvedit_face_visible_nolocal_ex(scene->toolsettings, efa);
-}
-
-bool uvedit_face_visible_test_ex(const ToolSettings *ts, Object *obedit, Image *ima, BMFace *efa)
-{
-  if (ts->uv_flag & UV_SHOW_SAME_IMAGE) {
-    Image *face_image;
-    ED_object_get_active_image(obedit, efa->mat_nr + 1, &face_image, NULL, NULL, NULL);
-    return (face_image == ima) ? uvedit_face_visible_nolocal_ex(ts, efa) : false;
-  }
-  else {
-    return uvedit_face_visible_nolocal_ex(ts, efa);
-  }
-}
-bool uvedit_face_visible_test(const Scene *scene, Object *obedit, Image *ima, BMFace *efa)
-{
-  return uvedit_face_visible_test_ex(scene->toolsettings, obedit, ima, efa);
-}
-
-bool uvedit_face_select_test_ex(const ToolSettings *ts, BMFace *efa, const int cd_loop_uv_offset)
-{
-  if (ts->uv_flag & UV_SYNC_SELECTION) {
-    return (BM_elem_flag_test(efa, BM_ELEM_SELECT));
-  }
-  else {
-    BMLoop *l;
-    MLoopUV *luv;
-    BMIter liter;
-
-    BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
-      luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-      if (!(luv->flag & MLOOPUV_VERTSEL)) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-}
-bool uvedit_face_select_test(const Scene *scene, BMFace *efa, const int cd_loop_uv_offset)
-{
-  return uvedit_face_select_test_ex(scene->toolsettings, efa, cd_loop_uv_offset);
-}
-
-bool uvedit_face_select_set(const struct Scene *scene,
-                            struct BMEditMesh *em,
-                            struct BMFace *efa,
-                            const bool select,
-                            const bool do_history,
-                            const int cd_loop_uv_offset)
-{
-  if (select) {
-    return uvedit_face_select_enable(scene, em, efa, do_history, cd_loop_uv_offset);
-  }
-  else {
-    return uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset);
-  }
-}
-
-bool uvedit_face_select_enable(const Scene *scene,
-                               BMEditMesh *em,
-                               BMFace *efa,
-                               const bool do_history,
-                               const int cd_loop_uv_offset)
-{
-  const ToolSettings *ts = scene->toolsettings;
-
-  if (ts->uv_flag & UV_SYNC_SELECTION) {
-    BM_face_select_set(em->bm, efa, true);
-    if (do_history) {
-      BM_select_history_store(em->bm, (BMElem *)efa);
-    }
-  }
-  else {
-    BMLoop *l;
-    MLoopUV *luv;
-    BMIter liter;
-
-    BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
-      luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-      luv->flag |= MLOOPUV_VERTSEL;
-    }
-
-    return true;
-  }
-
-  return false;
-}
-
-bool uvedit_face_select_disable(const Scene *scene,
-                                BMEditMesh *em,
-                                BMFace *efa,
-                                const int cd_loop_uv_offset)
-{
-  const ToolSettings *ts = scene->toolsettings;
-
-  if (ts->uv_flag & UV_SYNC_SELECTION) {
-    BM_face_select_set(em->bm, efa, false);
-  }
-  else {
-    BMLoop *l;
-    MLoopUV *luv;
-    BMIter liter;
-
-    BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
-      luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-      luv->flag &= ~MLOOPUV_VERTSEL;
-    }
-
-    return true;
-  }
-
-  return false;
-}
-
-bool uvedit_edge_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_loop_uv_offset)
-{
-  if (ts->uv_flag & UV_SYNC_SEL

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list