[Bf-blender-cvs] [daa4a333839] temp_bmesh_multires: Merge branch 'master' into temp_bmesh_multires

Joseph Eagar noreply at git.blender.org
Wed May 19 07:27:24 CEST 2021


Commit: daa4a333839636d83464085355c04886de7ebdb8
Author: Joseph Eagar
Date:   Mon May 17 19:48:16 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBdaa4a333839636d83464085355c04886de7ebdb8

Merge branch 'master' into temp_bmesh_multires

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



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

diff --cc release/scripts/addons
index 4fcdbfe7c20,4fcdbfe7c20..131f04b8cb1
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
--Subproject commit 4fcdbfe7c20edfc1204c0aa46c98ea25354abcd9
++Subproject commit 131f04b8cb1240a3be35510bd9ebeb6fbbc2d90f
diff --cc source/blender/editors/sculpt_paint/sculpt_expand.c
index 0a4a2fe27a1,40874375772..a89a247a071
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@@ -287,14 -271,9 +287,13 @@@ static bool sculpt_expand_state_get(Scu
   * Main function to get the state of a face for the current state and settings of a #ExpandCache.
   * Returns true when the target data should be modified by expand.
   */
 -static bool sculpt_expand_face_state_get(SculptSession *ss, ExpandCache *expand_cache, const int f)
 +static bool sculpt_expand_face_state_get(SculptSession *ss,
 +                                         ExpandCache *expand_cache,
 +                                         const SculptFaceRef f)
  {
 -  if (expand_cache->original_face_sets[f] <= 0) {
 +  const int f_i = BKE_pbvh_face_index_to_table(ss->pbvh, f);
-   const int fset = SCULPT_face_set_get(ss, f);
 +
-   if (fset <= 0) {
++  if (expand_cache->original_face_sets[f_i] <= 0) {
      return false;
    }
  
@@@ -322,7 -301,7 +321,7 @@@
    }
  
    if (expand_cache->falloff_type == SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET) {
-     if (fset == expand_cache->initial_active_face_set) {
 -    if (ss->face_sets[f] == expand_cache->initial_active_face_set) {
++    if (SCULPT_face_set_get(ss, f) == expand_cache->initial_active_face_set) {
        enabled = false;
      }
    }
@@@ -1517,22 -1396,16 +1516,20 @@@ static void sculpt_expand_original_stat
   */
  static void sculpt_expand_face_sets_restore(SculptSession *ss, ExpandCache *expand_cache)
  {
-   if (ss->bm) {
-     const int totfaces = ss->totfaces;
-     const int cd_faceset = ss->cd_faceset_offset;
+   const int totfaces = ss->totfaces;
 +
-     for (int i = 0; i < totfaces; i++) {
-       BMFace *f = (BMFace *)BKE_pbvh_table_index_to_face(ss->pbvh, i).i;
+   for (int i = 0; i < totfaces; i++) {
++    SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
 +
-       BM_ELEM_CD_SET_INT(f, cd_faceset, expand_cache->initial_face_sets[i]);
+     if (expand_cache->original_face_sets[i] <= 0) {
+       /* Do not modify hidden Face Sets, even when restoring the IDs state. */
+       continue;
      }
-   }
-   else {
-     const int totfaces = ss->totfaces;
- 
-     for (int i = 0; i < totfaces; i++) {
-       ss->face_sets[i] = expand_cache->initial_face_sets[i];
 -    if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, i)) {
++    if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, fref)) {
+       continue;
      }
 -    ss->face_sets[i] = expand_cache->initial_face_sets[i];
++
++    SCULPT_face_set_set(ss, fref, expand_cache->initial_face_sets[i]);
    }
  }
  
@@@ -2026,96 -1893,6 +2023,122 @@@ static int sculpt_expand_modal(bContex
    return OPERATOR_RUNNING_MODAL;
  }
  
 +/**
 + * Deletes the `delete_id` Face Set ID from the mesh Face Sets
 + * and stores the result in `r_face_set`.
 + * The faces that were using the `delete_id` Face Set are filled
 + * using the content from their neighbors.
 + */
 +static void sculpt_expand_delete_face_set_id_bmesh(int *r_face_sets,
 +                                                   SculptSession *ss,
 +                                                   ExpandCache *expand_cache,
 +                                                   const int delete_id)
 +{
 +  BMIter iter;
 +  BMFace *f;
 +  int i = 0;
 +  const int totface = ss->totpoly;
 +
 +  /* Check that all the face sets IDs in the mesh are not equal to `delete_id`
 +   * before attempting to delete it. */
 +  bool all_same_id = true;
 +
 +  BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) {
 +    SculptFaceRef fref = {(intptr_t)f};
 +    i++;
 +
 +    if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, fref)) {
 +      continue;
 +    }
 +
 +    if (r_face_sets[i] != delete_id) {
 +      all_same_id = false;
 +      break;
 +    }
 +  }
 +
 +  if (all_same_id) {
 +    return;
 +  }
 +
 +  BLI_LINKSTACK_DECLARE(queue, void *);
 +  BLI_LINKSTACK_DECLARE(queue_next, void *);
 +
 +  BLI_LINKSTACK_INIT(queue);
 +  BLI_LINKSTACK_INIT(queue_next);
 +
 +  for (int i = 0; i < totface; i++) {
 +    SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
 +
 +    if (r_face_sets[i] == delete_id) {
 +      BLI_LINKSTACK_PUSH(queue, POINTER_FROM_INT(fref.i));
 +    }
 +  }
 +
 +  while (BLI_LINKSTACK_SIZE(queue)) {
++    bool any_updated = false;
++
 +    while (BLI_LINKSTACK_SIZE(queue)) {
 +      const SculptFaceRef f = {(intptr_t)(BLI_LINKSTACK_POP(queue))};
 +      BMFace *bf = (BMFace *)f.i;
 +      const int f_index = BM_elem_index_get(bf);
 +
 +      int other_id = delete_id;
 +      BMLoop *l = bf->l_first;
 +      do {
 +        BMLoop *l2 = l->radial_next;
 +        do {
 +          const int neighbor_face_index = BM_elem_index_get(l2->f);
 +
++          if (expand_cache->original_face_sets[neighbor_face_index] <= 0) {
++            /* Skip picking IDs from hidden Face Sets. */
++            continue;
++          }
++
 +          if (r_face_sets[neighbor_face_index] != delete_id) {
 +            other_id = r_face_sets[neighbor_face_index];
 +          }
 +
 +          l2 = l2->radial_next;
 +        } while (l2 != l);
 +
 +        l = l->next;
 +      } while (l != bf->l_first);
 +
 +      if (other_id != delete_id) {
++        any_updated = true;
 +        r_face_sets[f_index] = other_id;
 +      }
 +      else {
 +        BLI_LINKSTACK_PUSH(queue_next, bf);
 +      }
 +    }
 +
++    if (!any_updated) {
++      /* No Face Sets where updated in this iteration, which means that no more content to keep
++       * filling the polys of the deleted Face Set was found. Break to avoid entering an infinite
++       * loop trying to search for those polys again. */
++      break;
++    }
++
 +    BLI_LINKSTACK_SWAP(queue, queue_next);
 +  }
 +
 +  BLI_LINKSTACK_FREE(queue);
 +  BLI_LINKSTACK_FREE(queue_next);
++
++  /* Ensure that the visibility state of the modified Face Sets is the same as the original ones.
++   */
++  for (int i = 0; i < totface; i++) {
++    if (expand_cache->original_face_sets[i] >= 0) {
++      r_face_sets[i] = abs(r_face_sets[i]);
++    }
++    else {
++      r_face_sets[i] = -abs(r_face_sets[i]);
++    }
++  }
 +}
 +
  /**
   * Deletes the `delete_id` Face Set ID from the mesh Face Sets
   * and stores the result in `r_face_set`.



More information about the Bf-blender-cvs mailing list