[Bf-blender-cvs] [7627e0980dd] master: Merge branch 'blender-v2.93-release'

Campbell Barton noreply at git.blender.org
Thu Apr 29 15:58:42 CEST 2021


Commit: 7627e0980ddc860917f0484a976956eacbcbe1ac
Author: Campbell Barton
Date:   Thu Apr 29 23:57:42 2021 +1000
Branches: master
https://developer.blender.org/rB7627e0980ddc860917f0484a976956eacbcbe1ac

Merge branch 'blender-v2.93-release'

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



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

diff --cc source/blender/editors/transform/transform_convert_mesh.c
index 9ef033639f6,5c05e35feb4..8d942b1094e
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@@ -816,212 -811,222 +816,226 @@@ void transform_convert_mesh_islanddata_
    }
  }
  
 -void createTransEditVerts(TransInfo *t)
 -{
 -  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
 -    TransDataExtension *tx = NULL;
 -    BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
 -    Mesh *me = tc->obedit->data;
 -    BMesh *bm = em->bm;
 -    BMVert *eve;
 -    BMIter iter;
 -    float mtx[3][3], smtx[3][3];
 -    int a;
 -    const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
 +/** \} */
  
 -    struct TransIslandData island_data = {NULL};
 -    struct TransMirrorData mirror_data = {NULL};
 -    struct TransMeshDataCrazySpace crazyspace_data = {NULL};
 +/* -------------------------------------------------------------------- */
 +/** \name Connectivity Distance for Proportional Editing
 + * \{ */
  
 -    /**
 -     * Quick check if we can transform.
 -     *
 -     * \note ignore modes here, even in edge/face modes,
 -     * transform data is created by selected vertices.
 -     */
 +/* Propagate distance from v1 and v2 to v0. */
 +static bool bmesh_test_dist_add(BMVert *v0,
 +                                BMVert *v1,
 +                                BMVert *v2,
 +                                float *dists,
 +                                /* optionally track original index */
 +                                int *index,
 +                                const float mtx[3][3])
 +{
 +  if ((BM_elem_flag_test(v0, BM_ELEM_SELECT) == 0) &&
 +      (BM_elem_flag_test(v0, BM_ELEM_HIDDEN) == 0)) {
 +    const int i0 = BM_elem_index_get(v0);
 +    const int i1 = BM_elem_index_get(v1);
  
 -    /* Support other objects using PET to adjust these, unless connected is enabled. */
 -    if ((!prop_mode || (prop_mode & T_PROP_CONNECTED)) && (bm->totvertsel == 0)) {
 -      continue;
 +    BLI_assert(dists[i1] != FLT_MAX);
 +    if (dists[i0] <= dists[i1]) {
 +      return false;
      }
  
 -    int data_len = 0;
 -    if (prop_mode) {
 -      BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
 -        if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
 -          data_len++;
 -        }
 +    float dist0;
 +
 +    if (v2) {
 +      /* Distance across triangle. */
 +      const int i2 = BM_elem_index_get(v2);
 +      BLI_assert(dists[i2] != FLT_MAX);
 +      if (dists[i0] <= dists[i2]) {
 +        return false;
        }
 +
 +      float vm0[3], vm1[3], vm2[3];
 +      mul_v3_m3v3(vm0, mtx, v0->co);
 +      mul_v3_m3v3(vm1, mtx, v1->co);
 +      mul_v3_m3v3(vm2, mtx, v2->co);
 +
 +      dist0 = geodesic_distance_propagate_across_triangle(vm0, vm1, vm2, dists[i1], dists[i2]);
      }
      else {
 -      data_len = bm->totvertsel;
 -    }
 +      /* Distance along edge. */
 +      float vec[3];
 +      sub_v3_v3v3(vec, v1->co, v0->co);
 +      mul_m3_v3(mtx, vec);
  
 -    if (data_len == 0) {
 -      continue;
 +      dist0 = dists[i1] + len_v3(vec);
      }
  
 -    /* Snap rotation along normal needs a common axis for whole islands,
 -     * otherwise one get random crazy results, see T59104.
 -     * However, we do not want to use the island center for the pivot/translation reference. */
 -    const bool is_snap_rotate = ((t->mode == TFM_TRANSLATION) &&
 -                                 /* There is not guarantee that snapping
 -                                  * is initialized yet at this point... */
 -                                 (usingSnappingNormal(t) ||
 -                                  (t->settings->snap_flag & SCE_SNAP_ROTATE) != 0) &&
 -                                 (t->around != V3D_AROUND_LOCAL_ORIGINS));
 +    if (dist0 < dists[i0]) {
 +      dists[i0] = dist0;
 +      if (index != NULL) {
 +        index[i0] = index[i1];
 +      }
 +      return true;
 +    }
 +  }
  
 -    /* Even for translation this is needed because of island-orientation, see: T51651. */
 -    const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS) || is_snap_rotate;
 -    if (is_island_center) {
 -      /* In this specific case, near-by vertices will need to know
 -       * the island of the nearest connected vertex. */
 -      const bool calc_single_islands = ((prop_mode & T_PROP_CONNECTED) &&
 -                                        (t->around == V3D_AROUND_LOCAL_ORIGINS) &&
 -                                        (em->selectmode & SCE_SELECT_VERTEX));
 +  return false;
 +}
  
 -      const bool calc_island_center = !is_snap_rotate;
 -      /* The island axismtx is only necessary in some modes.
 -       * TODO(Germano): Extend the list to exclude other modes. */
 -      const bool calc_island_axismtx = !ELEM(t->mode, TFM_SHRINKFATTEN);
 +static bool bmesh_test_loose_edge(BMEdge *edge)
 +{
 +  /* Actual loose edge. */
 +  if (edge->l == NULL) {
 +    return true;
 +  }
  
 -      transform_convert_mesh_islands_calc(
 -          em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data);
 +  /* Loose edge due to hidden adjacent faces. */
 +  BMIter iter;
 +  BMFace *face;
 +  BM_ITER_ELEM (face, &iter, edge, BM_FACES_OF_EDGE) {
 +    if (BM_elem_flag_test(face, BM_ELEM_HIDDEN) == 0) {
 +      return false;
      }
 +  }
 +  return true;
 +}
  
 -    copy_m3_m4(mtx, tc->obedit->obmat);
 -    /* we use a pseudo-inverse so that when one of the axes is scaled to 0,
 -     * matrix inversion still works and we can still moving along the other */
 -    pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
 +/**
 + * \param mtx: Measure distance in this space.
 + * \param dists: Store the closest connected distance to selected vertices.
 + * \param index: Optionally store the original index we're measuring the distance to (can be NULL).
 + */
 +void transform_convert_mesh_connectivity_distance(struct BMesh *bm,
 +                                                  const float mtx[3][3],
 +                                                  float *dists,
 +                                                  int *index)
 +{
 +  BLI_LINKSTACK_DECLARE(queue, BMEdge *);
  
 -    /* Original index of our connected vertex when connected distances are calculated.
 -     * Optional, allocate if needed. */
 -    int *dists_index = NULL;
 -    float *dists = NULL;
 -    if (prop_mode & T_PROP_CONNECTED) {
 -      dists = MEM_mallocN(bm->totvert * sizeof(float), __func__);
 -      if (is_island_center) {
 -        dists_index = MEM_mallocN(bm->totvert * sizeof(int), __func__);
 -      }
 -      transform_convert_mesh_connectivity_distance(em->bm, mtx, dists, dists_index);
 -    }
 +  /* any BM_ELEM_TAG'd edge is in 'queue_next', so we don't add in twice */
 +  const int tag_queued = BM_ELEM_TAG;
 +  const int tag_loose = BM_ELEM_TAG_ALT;
  
 -    /* Create TransDataMirror. */
 -    if (tc->use_mirror_axis_any) {
 -      bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
 -      bool use_select = (t->flag & T_PROP_EDIT) == 0;
 -      const bool mirror_axis[3] = {
 -          tc->use_mirror_axis_x, tc->use_mirror_axis_y, tc->use_mirror_axis_z};
 -      transform_convert_mesh_mirrordata_calc(
 -          em, use_select, use_topology, mirror_axis, &mirror_data);
 +  BLI_LINKSTACK_DECLARE(queue_next, BMEdge *);
  
 -      if (mirror_data.vert_map) {
 -        tc->data_mirror_len = mirror_data.mirror_elem_len;
 -        tc->data_mirror = MEM_mallocN(mirror_data.mirror_elem_len * sizeof(*tc->data_mirror),
 -                                      __func__);
 +  BLI_LINKSTACK_INIT(queue);
 +  BLI_LINKSTACK_INIT(queue_next);
  
 -        BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
 -          if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
 -            if (mirror_data.vert_map[a].index != -1) {
 -              data_len--;
 -            }
 -          }
 +  {
 +    /* Set indexes and initial distances for selected vertices. */
 +    BMIter viter;
 +    BMVert *v;
 +    int i;
 +
 +    BM_ITER_MESH_INDEX (v, &viter, bm, BM_VERTS_OF_MESH, i) {
 +      float dist;
 +      BM_elem_index_set(v, i); /* set_inline */
 +
 +      if (BM_elem_flag_test(v, BM_ELEM_SELECT) == 0 || BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
 +        dist = FLT_MAX;
 +        if (index != NULL) {
 +          index[i] = i;
 +        }
 +      }
 +      else {
 +        dist = 0.0f;
 +        if (index != NULL) {
 +          index[i] = i;
          }
        }
 +
 +      dists[i] = dist;
      }
 +    bm->elem_index_dirty &= ~BM_VERT;
 +  }
  
 -    /* Detect CrazySpace [tm]. */
 -    transform_convert_mesh_crazyspace_detect(t, tc, em, &crazyspace_data);
 +  {
 +    /* Add edges with at least one selected vertex to the queue. */
 +    BMIter eiter;
 +    BMEdge *e;
  
 -    /* Create TransData. */
 -    BLI_assert(data_len >= 1);
 -    tc->data_len = data_len;
 -    tc->data = MEM_callocN(data_len * sizeof(TransData), "TransObData(Mesh EditMode)");
 -    if (t->mode == TFM_SHRINKFATTEN) {
 -      /* warning, this is overkill, we only need 2 extra floats,
 -       * but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill
 -       * since we may not use the 'alt' transform mode to maintain shell thickness,
 -       * but with generic transform code its hard to lazy init vars */
 -      tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
 -                                      "TransObData ext");
 -    }
 +    BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
+ 
 -    int cd_vert_bweight_offset = -1;
 -    if (t->mode == TFM_BWEIGHT) {
 -      BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_VERT_BWEIGHT);
 -      cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
 -    }
++      /* Always clear to satisfy the assert, also predictable to leave in cleared state. */
++      BM_elem_flag_disable(e, tag_queued);
+ 
 -    TransData *tob = tc->data;
 -    TransDataMirror *td_mirror = tc->data_mirror;
 -    BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
 -      if (BM_elem_flag_test(eve, BM_ELEM_HIDD

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list