[Bf-blender-cvs] [57d5fc7352d] sculpt-dev: sculpt-dev: Split boundary flags into its own attribute

Joseph Eagar noreply at git.blender.org
Tue Oct 11 01:12:56 CEST 2022


Commit: 57d5fc7352d6f2f406359b3f693b3e7189a98eee
Author: Joseph Eagar
Date:   Mon Oct 10 16:06:56 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB57d5fc7352d6f2f406359b3f693b3e7189a98eee

sculpt-dev: Split boundary flags into its own attribute

Boundary and corner flags are now stored in their own
attribute instead of in MSculptVert->flag.  Note that
the other parts of MSculptVert will eventually become
their own indiviudual attibute (including the ->flag
which is still used by dyntopo).

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/customdata.cc
M	source/blender/blenkernel/intern/dyntopo.c
M	source/blender/blenkernel/intern/paint.cc
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/blenkernel/intern/pbvh_intern.h
M	source/blender/editors/mesh/editmesh_mask_extract.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_array.c
M	source/blender/editors/sculpt_paint/sculpt_automasking.cc
M	source/blender/editors/sculpt_paint/sculpt_brush_types.c
M	source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M	source/blender/editors/sculpt_paint/sculpt_face_set.cc
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_ops.c
M	source/blender/editors/sculpt_paint/sculpt_paint_color.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/makesdna/DNA_meshdata_types.h

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 1628ab6b0d3..c694f1e17e5 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -735,6 +735,7 @@ typedef struct SculptAttributePointers {
   SculptAttribute *smooth_bdist;
   SculptAttribute *smooth_vel;
 
+  SculptAttribute *boundary_flags;
   SculptAttribute *sculpt_vert;
   SculptAttribute *stroke_id;
 
@@ -971,7 +972,7 @@ typedef struct SculptSession {
 
   bool fast_draw;  // hides facesets/masks and forces smooth to save GPU bandwidth
   struct MSculptVert *msculptverts;  // for non-bmesh
-  int msculptverts_size;
+  int last_msculptverts_count;
 
   /* This is a fixed-size array so we can pass pointers to its elements
    * to client code. This is important to keep bmesh offsets up to date.
@@ -989,7 +990,7 @@ typedef struct SculptSession {
    */
   bool sticky_shading_color;
 
-  uchar stroke_id;
+  ushort stroke_id;
 
   /**
    * Last used painting canvas key.
@@ -1007,6 +1008,28 @@ typedef struct SculptSession {
   uchar last_automask_stroke_id;
 } SculptSession;
 
+typedef enum eSculptBoundary {
+  SCULPT_BOUNDARY_MESH = 1 << 0,
+  SCULPT_BOUNDARY_FACE_SET = 1 << 1,
+  SCULPT_BOUNDARY_SEAM = 1 << 2,
+  SCULPT_BOUNDARY_SHARP = 1 << 3,
+  SCULPT_BOUNDARY_UV = 1 << 4,
+  SCULPT_BOUNDARY_NEEDS_UPDATE = 1 << 5,
+  SCULPT_BOUNDARY_ALL = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4),
+  SCULPT_BOUNDARY_DEFAULT = (1 << 0) | (1 << 3) | (1 << 4)  // mesh and sharp
+} eSculptBoundary;
+
+
+/* Note: This is stored in a single attribute with boundary flags */
+typedef enum eSculptCorner {
+  SCULPT_CORNER_NONE = 0,
+  SCULPT_CORNER_MESH = 1 << 6,
+  SCULPT_CORNER_FACE_SET = 1 << 7,
+  SCULPT_CORNER_SEAM = 1 << 8,
+  SCULPT_CORNER_SHARP = 1 << 9,
+  SCULPT_CORNER_UV = 1 << 10,
+} eSculptCorner;
+
 void BKE_sculptsession_free(struct Object *ob);
 void BKE_sculptsession_free_deformMats(struct SculptSession *ss);
 void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss);
@@ -1083,7 +1106,13 @@ BLI_INLINE void *BKE_sculpt_face_attr_get(const PBVHFaceRef vertex, const Sculpt
   return NULL;
 }
 
-bool BKE_sculptsession_check_sculptverts(SculptSession *ss, struct PBVH *pbvh, int totvert);
+BLI_INLINE void BKE_sculpt_boundary_flag_update(SculptSession *ss, PBVHVertRef vertex)
+{
+  int *flags = (int *)BKE_sculpt_vertex_attr_get(vertex, ss->attrs.boundary_flags);
+  *flags |= SCULPT_BOUNDARY_NEEDS_UPDATE;
+}
+
+bool BKE_sculptsession_check_sculptverts(struct Object *ob, struct PBVH *pbvh, int totvert);
 
 struct BMesh *BKE_sculptsession_empty_bmesh_create(void);
 void BKE_sculptsession_bmesh_attr_update_internal(struct Object *ob);
@@ -1135,7 +1164,7 @@ int *BKE_sculpt_face_sets_ensure(struct Object *ob);
  * Note that changes to the face visibility have to be propagated to other domains
  * (see #SCULPT_visibility_sync_all_from_faces).
  */
-bool *BKE_sculpt_hide_poly_ensure(struct Mesh *mesh);
+bool *BKE_sculpt_hide_poly_ensure(struct Object *ob);
 int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd);
 void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene);
 
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 6c03c254f17..78c6860cc0f 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -426,6 +426,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
                           const int cd_face_node_offset,
                           const int cd_sculpt_vert,
                           const int cd_face_areas,
+                          const int cd_boundary_flag,
                           bool fast_draw,
                           bool update_sculptverts);
 void BKE_pbvh_update_offsets(PBVH *pbvh,
@@ -433,7 +434,8 @@ void BKE_pbvh_update_offsets(PBVH *pbvh,
                              const int cd_face_node_offset,
                              const int cd_sculpt_vert,
                              const int cd_face_areas,
-                             const int cd_hide_poly);
+                             const int cd_hide_poly,
+                             const int cd_boudnary_flags);
 
 void BKE_pbvh_update_bmesh_offsets(PBVH *pbvh, int cd_vert_node_offset, int cd_face_node_offset);
 
@@ -1017,6 +1019,7 @@ void BKE_pbvh_bmesh_free_tris(PBVH *pbvh, PBVHNode *node);
 /*recalculates boundary flags for *all* vertices.  used by
   symmetrize.*/
 void BKE_pbvh_recalc_bmesh_boundary(PBVH *pbvh);
+void BKE_pbvh_set_boundary_flags(PBVH *pbvh, int *boundary_flags);
 
 /* saves all bmesh references to internal indices, to be restored later */
 void BKE_pbvh_bmesh_save_indices(PBVH *pbvh);
@@ -1052,6 +1055,7 @@ void BKE_pbvh_update_vert_boundary(int cd_sculpt_vert,
                                    int cd_vert_node_offset,
                                    int cd_face_node_offset,
                                    int cd_vcol,
+                                   int cd_boundary_flag,
                                    struct BMVert *v,
                                    int bound_symmetry,
                                    const CustomData *ldata,
@@ -1163,7 +1167,8 @@ typedef struct SculptLayerEntry {
 int BKE_pbvh_do_fset_symmetry(int fset, const int symflag, const float *co);
 bool BKE_pbvh_check_vert_boundary(PBVH *pbvh, struct BMVert *v);
 
-void BKE_pbvh_update_vert_boundary_faces(const int *face_sets,
+void BKE_pbvh_update_vert_boundary_faces(int *boundary_flags,
+                                         const int *face_sets,
                                          const bool *hide_poly,
                                          const struct MVert *mvert,
                                          const struct MEdge *medge,
@@ -1176,8 +1181,6 @@ void BKE_pbvh_update_vert_boundary_grids(PBVH *pbvh,
                                          struct SubdivCCG *subdiv_ccg,
                                          PBVHVertRef vertex);
 
-void BKE_pbvh_set_mdyntopo_verts(PBVH *pbvh, struct MSculptVert *mdyntopoverts);
-
 #if 0
 #  include "DNA_meshdata_types.h"
 ATTR_NO_OPT static void MV_ADD_FLAG(MSculptVert *mv, int flag)
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index ac0a5bffb02..52cbe27fd21 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4890,11 +4890,11 @@ void CustomData_bmesh_interp(CustomData *data,
   }
 }
 
-void CustomData_to_bmesh_block(const CustomData *source,
-                               CustomData *dest,
-                               int src_index,
-                               void **dest_block,
-                               bool use_default_init)
+ATTR_NO_OPT void CustomData_to_bmesh_block(const CustomData *source,
+                                           CustomData *dest,
+                                           int src_index,
+                                           void **dest_block,
+                                           bool use_default_init)
 {
   if (*dest_block == nullptr) {
     CustomData_bmesh_alloc_block(dest, dest_block);
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index 6d41cee73ec..706ada16f1d 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -53,17 +53,17 @@
 #define SCULPTVERT_VALENCE_TEMP SCULPTVERT_SPLIT_TEMP
 
 #define SCULPTVERT_SMOOTH_BOUNDARY \
-  (SCULPTVERT_BOUNDARY | SCULPTVERT_FSET_BOUNDARY | SCULPTVERT_SHARP_BOUNDARY | \
-   SCULPTVERT_SEAM_BOUNDARY | SCULPTVERT_UV_BOUNDARY)
+  (SCULPT_BOUNDARY_MESH | SCULPT_BOUNDARY_FACE_SET | SCULPT_BOUNDARY_SHARP | \
+   SCULPT_BOUNDARY_SEAM | SCULPT_BOUNDARY_UV)
 #define SCULPTVERT_ALL_BOUNDARY \
-  (SCULPTVERT_BOUNDARY | SCULPTVERT_FSET_BOUNDARY | SCULPTVERT_SHARP_BOUNDARY | \
-   SCULPTVERT_SEAM_BOUNDARY | SCULPTVERT_UV_BOUNDARY)
+  (SCULPT_BOUNDARY_MESH | SCULPT_BOUNDARY_FACE_SET | SCULPT_BOUNDARY_SHARP | \
+   SCULPT_BOUNDARY_SEAM | SCULPT_BOUNDARY_UV)
 #define SCULPTVERT_SMOOTH_CORNER \
-  (SCULPTVERT_CORNER | SCULPTVERT_FSET_CORNER | SCULPTVERT_SHARP_CORNER | \
-   SCULPTVERT_SEAM_CORNER | SCULPTVERT_UV_CORNER)
+  (SCULPT_CORNER_MESH | SCULPT_CORNER_FACE_SET | SCULPT_CORNER_SHARP | SCULPT_CORNER_SEAM | \
+   SCULPT_CORNER_UV)
 #define SCULPTVERT_ALL_CORNER \
-  (SCULPTVERT_CORNER | SCULPTVERT_FSET_CORNER | SCULPTVERT_SHARP_CORNER | \
-   SCULPTVERT_SEAM_CORNER | SCULPTVERT_UV_CORNER)
+  (SCULPT_CORNER_MESH | SCULPT_CORNER_FACE_SET | SCULPT_CORNER_SHARP | SCULPT_CORNER_SEAM | \
+   SCULPT_CORNER_UV)
 
 #define DYNTOPO_MAX_ITER 4096
 
@@ -181,6 +181,24 @@ static void pbvh_bmesh_verify(PBVH *pbvh);
 
 struct EdgeQueueContext;
 
+bool pbvh_boundary_needs_update_bmesh(PBVH *pbvh, BMVert *v)
+{
+  int *flags = (int *)BM_ELEM_CD_GET_VOID_P(v, pbvh->cd_boundary_flag);
+
+  return *flags & SCULPT_BOUNDARY_NEEDS_UPDATE;
+}
+
+void pbvh_boundary_update_bmesh(PBVH *pbvh, BMVert *v)
+{
+  if (pbvh->cd_boundary_flag == -1) {
+    printf("%s: error!\n", __func__);
+    return;
+  }
+
+  int *flags = (int *)BM_ELEM_CD_GET_VOID_P(v, pbvh->cd_boundary_flag);
+  *flags |= SCULPT_BOUNDARY_NEEDS_UPDATE;
+}
+
 static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root);
 static bool check_face_is_tri(PBVH *pbvh, BMFace *f);
 static bool check_vert_fan_are_tris(PBVH *pbvh, BMVert *v);
@@ -222,8 +240,7 @@ static void fix_mesh(PBVH *pbvh, BMesh *bm)
     MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
 
     MV_ADD_FLAG(mv,
-                SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_BOUNDARY | SCULPTVERT_NEED_DISK_SORT |
-                    SCULPTVERT_NEED_TRIANGULATE);
+                SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_DISK_SORT | SCULPTVERT_NEED_TRIANGULATE);
   }
 
   BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
@@ -654,17 +671,18 @@ BLI_INLINE void surface_smooth_v_safe(PBVH *pbvh, BMVert *v, float fac)
     return;
   }
 
-  if (mv1->flag & SCULPTVERT_NEED_BOUNDARY) {
+  if (pbvh_boundary_needs_update_bmesh(pbvh, v)) {
     pbvh_check_vert_boundary(pbvh, v);
   }
 
   // pbvh_check_vert_boundary(pbvh, v

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list