[Bf-blender-cvs] [920b6987466] master: Merge branch 'blender-v2.83-release'

Campbell Barton noreply at git.blender.org
Fri May 22 14:42:52 CEST 2020


Commit: 920b6987466da30b53b2c923baf1096f312e64a9
Author: Campbell Barton
Date:   Fri May 22 22:42:16 2020 +1000
Branches: master
https://developer.blender.org/rB920b6987466da30b53b2c923baf1096f312e64a9

Merge branch 'blender-v2.83-release'

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



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

diff --cc source/blender/editors/uvedit/uvedit_intern.h
index ffab5bd094f,167e8df6fa7..31384d6df17
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@@ -114,31 -107,4 +108,28 @@@ void UV_OT_sphere_project(struct wmOper
  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(struct Scene *scene, struct Object *obedit);
 +bool uvedit_select_is_any_selected_multi(struct Scene *scene,
-                                          struct Image *ima,
 +                                         struct Object **objects,
 +                                         const uint objects_len);
 +const float *uvedit_first_selected_uv_from_vertex(struct Scene *scene,
-                                                   struct Object *obedit,
-                                                   struct Image *ima,
 +                                                  struct BMVert *eve,
 +                                                  const int cd_loop_uv_offset);
 +
 +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 --cc source/blender/editors/uvedit/uvedit_ops.c
index a99e05cb52b,49c802131e6..78b6cfc44ac
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@@ -392,8 -746,7 +385,7 @@@ bool ED_uvedit_center_from_pivot_ex(Spa
          uint objects_len = 0;
          Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
              view_layer, ((View3D *)NULL), &objects_len);
-         *r_has_select = uvedit_select_is_any_selected_multi(
-             scene, sima->image, objects, objects_len);
 -        *r_has_select = uv_select_is_any_selected_multi(scene, objects, objects_len);
++        *r_has_select = uvedit_select_is_any_selected_multi(scene, objects, objects_len);
          MEM_freeN(objects);
        }
        break;
@@@ -422,250 -775,2765 +414,249 @@@ bool ED_uvedit_center_from_pivot
  /** \} */
  
  /* -------------------------------------------------------------------- */
 -/** \name Find Nearest Elements
 +/** \name Weld Align Operator
   * \{ */
  
 -bool uv_find_nearest_edge(Scene *scene, Object *obedit, const float co[2], UvNearestHit *hit)
 +typedef enum eUVWeldAlign {
 +  UV_STRAIGHTEN,
 +  UV_STRAIGHTEN_X,
 +  UV_STRAIGHTEN_Y,
 +  UV_ALIGN_AUTO,
 +  UV_ALIGN_X,
 +  UV_ALIGN_Y,
 +  UV_WELD,
 +} eUVWeldAlign;
 +
 +static void uv_weld_align(bContext *C, eUVWeldAlign tool)
  {
 -  BMEditMesh *em = BKE_editmesh_from_object(obedit);
 -  BMFace *efa;
 -  BMLoop *l;
 -  BMIter iter, liter;
 -  MLoopUV *luv, *luv_next;
 -  int i;
 -  bool found = false;
 +  Scene *scene = CTX_data_scene(C);
 +  ViewLayer *view_layer = CTX_data_view_layer(C);
 +  SpaceImage *sima = CTX_wm_space_image(C);
-   Image *ima = CTX_data_edit_image(C);
 +  const ToolSettings *ts = scene->toolsettings;
 +  const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
 +  float cent[2], min[2], max[2];
  
 -  const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
 +  INIT_MINMAX2(min, max);
  
 -  BM_mesh_elem_index_ensure(em->bm, BM_VERT);
 +  uint objects_len = 0;
 +  Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
 +      view_layer, ((View3D *)NULL), &objects_len);
  
 -  BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
 -    if (!uvedit_face_visible_test(scene, efa)) {
 -      continue;
 -    }
 -    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 (tool == UV_ALIGN_AUTO) {
 +    for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 +      Object *obedit = objects[ob_index];
 +      BMEditMesh *em = BKE_editmesh_from_object(obedit);
 +
 +      if (synced_selection && (em->bm->totvertsel == 0)) {
 +        continue;
 +      }
  
 -      const float dist_test_sq = dist_squared_to_line_segment_v2(co, luv->uv, luv_next->uv);
 +      const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
  
 -      if (dist_test_sq < hit->dist_sq) {
 -        hit->efa = efa;
 +      BMIter iter, liter;
 +      BMFace *efa;
 +      BMLoop *l;
  
 -        hit->l = l;
 -        hit->luv = luv;
 -        hit->luv_next = luv_next;
 -        hit->lindex = i;
 +      BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-         if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
++        if (!uvedit_face_visible_test(scene, efa)) {
 +          continue;
 +        }
  
 -        hit->dist_sq = dist_test_sq;
 -        found = true;
 +        BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
 +          if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
 +            MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
 +            minmax_v2v2_v2(min, max, luv->uv);
 +          }
 +        }
        }
      }
 +    tool = (max[0] - min[0] >= max[1] - min[1]) ? UV_ALIGN_Y : UV_ALIGN_X;
    }
 -  return found;
 -}
  
-   ED_uvedit_center_multi(scene, ima, objects, objects_len, cent, 0);
 -bool uv_find_nearest_edge_multi(Scene *scene,
 -                                Object **objects,
 -                                const uint objects_len,
 -                                const float co[2],
 -                                UvNearestHit *hit_final)
 -{
 -  bool found = false;
++  ED_uvedit_center_multi(scene, objects, objects_len, cent, 0);
 +
    for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
      Object *obedit = objects[ob_index];
 -    if (uv_find_nearest_edge(scene, obedit, co, hit_final)) {
 -      hit_final->ob = obedit;
 -      found = true;
 +    BMEditMesh *em = BKE_editmesh_from_object(obedit);
 +    bool changed = false;
 +
 +    if (synced_selection && (em->bm->totvertsel == 0)) {
 +      continue;
      }
 -  }
 -  return found;
 -}
  
 -bool uv_find_nearest_face(Scene *scene, Object *obedit, const float co[2], UvNearestHit *hit_final)
 -{
 -  BMEditMesh *em = BKE_editmesh_from_object(obedit);
 -  bool found = false;
 +    const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
  
 -  const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
 +    if (ELEM(tool, UV_ALIGN_X, UV_WELD)) {
 +      BMIter iter, liter;
 +      BMFace *efa;
 +      BMLoop *l;
  
 -  /* this will fill in hit.vert1 and hit.vert2 */
 -  float dist_sq_init = hit_final->dist_sq;
 -  UvNearestHit hit = *hit_final;
 -  if (uv_find_nearest_edge(scene, obedit, co, &hit)) {
 -    hit.dist_sq = dist_sq_init;
 -    hit.l = NULL;
 -    hit.luv = hit.luv_next = NULL;
 +      BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-         if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
++        if (!uvedit_face_visible_test(scene, efa)) {
 +          continue;
 +        }
  
 -    BMIter iter;
 -    BMFace *efa;
 -
 -    BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
 -      if (!uvedit_face_visible_test(scene, efa)) {
 -        continue;
 -      }
 -
 -      float cent[2];
 -      uv_poly_center(efa, cent, cd_loop_uv_offset);
 -
 -      const float dist_test_sq = len_squared_v2v2(co, cent);
 -
 -      if (dist_test_sq < hit.dist_sq) {
 -        hit.efa = efa;
 -        hit.dist_sq = dist_test_sq;
 -        found = true;
 -      }
 -    }
 -  }
 -  if (found) {
 -    *hit_final = hit;
 -  }
 -  return found;
 -}
 -
 -bool uv_find_nearest_face_multi(Scene *scene,
 -                                Object **objects,
 -                                const uint objects_len,
 -                                const float co[2],
 -                                UvNearestHit *hit_final)
 -{
 -  bool found = false;
 -  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 -    Object *obedit = objects[ob_index];
 -    if (uv_find_nearest_face(scene, obedit, co, hit_final)) {
 -      hit_final->ob = obedit;
 -      found = true;
 -    }
 -  }
 -  return found;
 -}
 -
 -static bool uv_nearest_between(const BMLoop *l, const float co[2], const int cd_loop_uv_offset)
 -{
 -  const float *uv_prev = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_uv_offset))->uv;
 -  const float *uv_curr = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset))->uv;
 -  const float *uv_next = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset))->uv;
 -
 -  return ((line_point_side_v2(uv_prev, uv_curr, co) > 0.0f) &&
 -          (line_point_side_v2(uv_next, uv_curr, co) <= 0.0f));
 -}
 -
 -bool uv_find_nearest_vert(Scene *scene,
 -                          Object *obedit,
 -                          float const co[2],
 -                          const float penalty_dist,
 -                          UvNearestHit *hit_final)
 -{
 -  bool found = false;
 -
 -  /* this will fill in hit.vert1 and hit.vert2 */
 -  float dist_sq_init = hit_final->dist_sq;
 -  UvNearestHit hit = *hit_final;
 -  if (uv_find_nearest_edge(scene, obedit, co, &hit)) {
 -    hit.dist_sq = dist_sq_init;
 -
 -    hit.l = NULL;
 -    hit.luv = hit.luv_next = NULL;
 -
 -    BMEditMesh *em = BKE_editmesh_from_object(obedit);
 -    BMFace *efa;
 -    BMIter iter;
 -
 -    BM_mesh_elem_index_ensure(em->bm, BM_VERT);
 -
 -    const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
 -
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list