[Bf-blender-cvs] [40ac3776dbf] master: Merge branch 'blender-v3.4-release'

Joseph Eagar noreply at git.blender.org
Tue Nov 22 21:42:09 CET 2022


Commit: 40ac3776dbf20a84353a7836b2777c757b0d2ba4
Author: Joseph Eagar
Date:   Tue Nov 22 12:33:34 2022 -0800
Branches: master
https://developer.blender.org/rB40ac3776dbf20a84353a7836b2777c757b0d2ba4

Merge branch 'blender-v3.4-release'

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



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

diff --cc source/blender/blenkernel/intern/pbvh.c
index 606dd547d62,f948749f7bb..796ffa8a62e
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -3654,6 -3749,7 +3656,7 @@@ static void pbvh_face_iter_step(PBVHFac
            fd->verts[i].i = ml->v;
          }
        }
 -
++      
        break;
      }
    }
@@@ -3722,273 -3820,3 +3726,92 @@@ bool BKE_pbvh_face_iter_done(PBVHFaceIt
        return true;
    }
  }
 +
 +void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
 +{
 +  switch (pbvh->header.type) {
 +    case PBVH_FACES: {
 +      BKE_mesh_flush_hidden_from_verts(mesh);
 +      BKE_pbvh_update_hide_attributes_from_mesh(pbvh);
 +      break;
 +    }
 +    case PBVH_BMESH: {
 +      BMIter iter;
 +      BMVert *v;
 +      BMEdge *e;
 +      BMFace *f;
 +
 +      BM_ITER_MESH (f, &iter, pbvh->header.bm, BM_FACES_OF_MESH) {
 +        BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
 +      }
 +
 +      BM_ITER_MESH (e, &iter, pbvh->header.bm, BM_EDGES_OF_MESH) {
 +        BM_elem_flag_disable(e, BM_ELEM_HIDDEN);
 +      }
 +
 +      BM_ITER_MESH (v, &iter, pbvh->header.bm, BM_VERTS_OF_MESH) {
 +        if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
 +          continue;
 +        }
 +        BMIter iter_l;
 +        BMLoop *l;
 +
 +        BM_ITER_ELEM (l, &iter_l, v, BM_LOOPS_OF_VERT) {
 +          BM_elem_flag_enable(l->e, BM_ELEM_HIDDEN);
 +          BM_elem_flag_enable(l->f, BM_ELEM_HIDDEN);
 +        }
 +      }
 +      break;
 +    }
 +    case PBVH_GRIDS: {
 +      const MPoly *mp = BKE_mesh_polys(mesh);
 +      const MLoop *mloop = BKE_mesh_loops(mesh);
 +      CCGKey key = pbvh->gridkey;
 +
 +      bool *hide_poly = (bool *)CustomData_get_layer_named(
 +          &mesh->pdata, CD_PROP_BOOL, ".hide_poly");
 +
 +      bool delete_hide_poly = true;
 +      for (int face_index = 0; face_index < mesh->totpoly; face_index++, mp++) {
 +        const MLoop *ml = mloop + mp->loopstart;
 +        bool hidden = false;
 +
 +        for (int loop_index = 0; !hidden && loop_index < mp->totloop; loop_index++, ml++) {
 +          int grid_index = mp->loopstart + loop_index;
 +
 +          if (pbvh->grid_hidden[grid_index] &&
 +              BLI_BITMAP_TEST(pbvh->grid_hidden[grid_index], key.grid_area - 1)) {
 +            hidden = true;
 +
 +            break;
 +          }
 +        }
 +
 +        if (hidden && !hide_poly) {
 +          hide_poly = (bool *)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".hide_poly");
 +
 +          if (!hide_poly) {
 +            CustomData_add_layer_named(
 +                &mesh->pdata, CD_PROP_BOOL, CD_CONSTRUCT, NULL, mesh->totpoly, ".hide_poly");
 +
 +            hide_poly = (bool *)CustomData_get_layer_named(
 +                &mesh->pdata, CD_PROP_BOOL, ".hide_poly");
 +          }
 +        }
 +
 +        if (hide_poly) {
 +          delete_hide_poly = delete_hide_poly && !hidden;
 +          hide_poly[face_index] = hidden;
 +        }
 +      }
 +
 +      if (delete_hide_poly) {
 +        CustomData_free_layer_named(&mesh->pdata, ".hide_poly", mesh->totpoly);
 +      }
 +
 +      BKE_mesh_flush_hidden_from_polys(mesh);
 +      BKE_pbvh_update_hide_attributes_from_mesh(pbvh);
 +      break;
 +    }
 +  }
 +}
- 
- static void pbvh_face_iter_verts_reserve(PBVHFaceIter *fd, int verts_num)
- {
-   if (verts_num >= fd->verts_size_) {
-     fd->verts_size_ = (verts_num + 1) << 2;
- 
-     if (fd->verts != fd->verts_reserved_) {
-       MEM_SAFE_FREE(fd->verts);
-     }
- 
-     fd->verts = MEM_malloc_arrayN(fd->verts_size_, sizeof(void *), __func__);
-   }
- 
-   fd->verts_num = verts_num;
- }
- 
- BLI_INLINE int face_iter_prim_to_face(PBVHFaceIter *fd, int prim_index)
- {
-   if (fd->subdiv_ccg_) {
-     return BKE_subdiv_ccg_grid_to_face_index(fd->subdiv_ccg_, prim_index);
-   }
-   else {
-     return fd->looptri_[prim_index].poly;
-   }
- }
- 
- void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
- {
-   if (do_step) {
-     fd->i++;
-   }
- 
-   switch (fd->pbvh_type_) {
-     case PBVH_BMESH: {
-       if (do_step) {
-         BLI_gsetIterator_step(&fd->bm_faces_iter_);
-         if (BLI_gsetIterator_done(&fd->bm_faces_iter_)) {
-           return;
-         }
-       }
- 
-       BMFace *f = (BMFace *)BLI_gsetIterator_getKey(&fd->bm_faces_iter_);
-       fd->face.i = (intptr_t)f;
-       fd->index = f->head.index;
- 
-       if (fd->cd_face_set_ != -1) {
-         fd->face_set = (int *)BM_ELEM_CD_GET_VOID_P(f, fd->cd_face_set_);
-       }
- 
-       if (fd->cd_hide_poly_ != -1) {
-         fd->hide = (bool *)BM_ELEM_CD_GET_VOID_P(f, fd->cd_hide_poly_);
-       }
- 
-       pbvh_face_iter_verts_reserve(fd, f->len);
-       int vertex_i = 0;
- 
-       BMLoop *l = f->l_first;
-       do {
-         fd->verts[vertex_i++].i = (intptr_t)l->v;
-       } while ((l = l->next) != f->l_first);
- 
-       break;
-     }
-     case PBVH_GRIDS:
-     case PBVH_FACES: {
-       int face_index = 0;
- 
-       if (do_step) {
-         fd->prim_index_++;
- 
-         while (fd->prim_index_ < fd->node_->totprim) {
-           face_index = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
- 
-           if (face_index != fd->last_face_index_) {
-             break;
-           }
- 
-           fd->prim_index_++;
-         }
-       }
-       else if (fd->prim_index_ < fd->node_->totprim) {
-         face_index = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
-       }
- 
-       if (fd->prim_index_ >= fd->node_->totprim) {
-         return;
-       }
- 
-       fd->last_face_index_ = face_index;
-       const MPoly *mp = fd->mpoly_ + face_index;
- 
-       fd->face.i = fd->index = face_index;
- 
-       if (fd->face_sets_) {
-         fd->face_set = fd->face_sets_ + face_index;
-       }
-       if (fd->hide_poly_) {
-         fd->hide = fd->hide_poly_ + face_index;
-       }
- 
-       pbvh_face_iter_verts_reserve(fd, mp->totloop);
- 
-       const MLoop *ml = fd->mloop_ + mp->loopstart;
-       for (int i = 0; i < mp->totloop; i++, ml++) {
-         if (fd->pbvh_type_ == PBVH_GRIDS) {
-           /* Grid corners. */
-           fd->verts[i].i = mp->loopstart + i;
-         }
-         else {
-           fd->verts[i].i = ml->v;
-         }
-       }
- 
-       break;
-     }
-   }
- }
- 
- void BKE_pbvh_face_iter_step(PBVHFaceIter *fd)
- {
-   pbvh_face_iter_step(fd, true);
- }
- 
- void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd)
- {
-   memset(fd, 0, sizeof(*fd));
- 
-   fd->node_ = node;
-   fd->pbvh_type_ = BKE_pbvh_type(pbvh);
- 
-   fd->verts = fd->verts_reserved_;
-   fd->verts_size_ = PBVH_FACE_ITER_VERTS_RESERVED;
- 
-   switch (BKE_pbvh_type(pbvh)) {
-     case PBVH_GRIDS:
-       fd->subdiv_ccg_ = pbvh->subdiv_ccg;
-     case PBVH_FACES:
-       fd->mpoly_ = pbvh->mpoly;
-       fd->mloop_ = pbvh->mloop;
-       fd->looptri_ = pbvh->looptri;
-       fd->hide_poly_ = pbvh->hide_poly;
-       fd->face_sets_ = pbvh->face_sets;
-       fd->last_face_index_ = -1;
- 
-       break;
-     case PBVH_BMESH:
-       fd->bm = pbvh->header.bm;
-       fd->cd_face_set_ = CustomData_get_offset_named(
-           &pbvh->header.bm->pdata, CD_PROP_INT32, ".sculpt_face_set");
-       fd->cd_hide_poly_ = CustomData_get_offset_named(
-           &pbvh->header.bm->pdata, CD_PROP_INT32, ".hide_poly");
- 
-       BLI_gsetIterator_init(&fd->bm_faces_iter_, node->bm_faces);
-       break;
-   }
- 
-   if (!BKE_pbvh_face_iter_done(fd)) {
-     pbvh_face_iter_step(fd, false);
-   }
- }
- 
- void BKE_pbvh_face_iter_finish(PBVHFaceIter *fd)
- {
-   if (fd->verts != fd->verts_reserved_) {
-     MEM_SAFE_FREE(fd->verts);
-   }
- }
- 
- bool BKE_pbvh_face_iter_done(PBVHFaceIter *fd)
- {
-   switch (fd->pbvh_type_) {
-     case PBVH_FACES:
-     case PBVH_GRIDS:
-       return fd->prim_index_ >= fd->node_->totprim;
-     case PBVH_BMESH:
-       return BLI_gsetIterator_done(&fd->bm_faces_iter_);
-     default:
-       BLI_assert_unreachable();
-       return true;
-   }
- }



More information about the Bf-blender-cvs mailing list