[Bf-blender-cvs] [313c6811c3a] sculpt-dev: Sculpt: fix nasty radius symmetry bug

Joseph Eagar noreply at git.blender.org
Wed Oct 6 22:37:33 CEST 2021


Commit: 313c6811c3ab155e9b0fcd432a36f3879586a0b6
Author: Joseph Eagar
Date:   Wed Oct 6 13:35:22 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB313c6811c3ab155e9b0fcd432a36f3879586a0b6

Sculpt: fix nasty radius symmetry bug

* Brush radius wasn't being calculated correctly if symmetry was on.
* Unnessed SCULPT_run_commandlist, it now calls
  do_symmetrical_brush_actions instead of the reverse.
* Renamed MDynTopoVert to MSculptVert.  Old name didn't
  make sense given that all three PBVH types now use it.
  Mercifully it's never saved in files, and even if it
  somehow was saved the CD file loading code checks for
  that.

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/customdata.c
M	source/blender/blenkernel/intern/dyntopo.c
M	source/blender/blenkernel/intern/paint.c
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/bmesh/intern/bmesh_log.c
M	source/blender/bmesh/intern/bmesh_log.h
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_curvature.c
M	source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M	source/blender/editors/sculpt_paint/sculpt_face_set.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_smooth.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/gpu/intern/gpu_buffers.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 4845118693f..456d845613c 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -37,7 +37,7 @@ extern "C" {
 #endif
 
 struct SculptCustomLayer;
-struct MDynTopoVert;
+struct MSculptVert;
 struct BMFace;
 struct BMesh;
 struct BlendDataReader;
@@ -628,7 +628,7 @@ typedef struct SculptSession {
 
   /* BMesh for dynamic topology sculpting */
   struct BMesh *bm;
-  int cd_dyn_vert;
+  int cd_sculpt_vert;
   int cd_vert_node_offset;
   int cd_face_node_offset;
   int cd_vcol_offset;
@@ -771,7 +771,7 @@ typedef struct SculptSession {
   int stroke_id, boundary_symmetry;
 
   bool fast_draw;  // hides facesets/masks and forces smooth to save GPU bandwidth
-  struct MDynTopoVert *mdyntopo_verts;  // for non-bmesh
+  struct MSculptVert *mdyntopo_verts;  // for non-bmesh
   int mdyntopo_verts_size;
 
   /*list of up to date custom layer references,
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 34dc6df8830..229fb7bb7e4 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -130,7 +130,7 @@ struct GPU_PBVH_Buffers;
 struct IsectRayPrecalc;
 struct MLoop;
 struct MLoopTri;
-struct MDynTopoVert;
+struct MSculptVert;
 struct MPoly;
 struct MVert;
 struct Mesh;
@@ -283,7 +283,7 @@ void BKE_pbvh_build_mesh(PBVH *pbvh,
                          const struct MPoly *mpoly,
                          const struct MLoop *mloop,
                          struct MVert *verts,
-                         struct MDynTopoVert *mdyntopo_verts,
+                         struct MSculptVert *mdyntopo_verts,
                          int totvert,
                          struct CustomData *vdata,
                          struct CustomData *ldata,
@@ -305,13 +305,13 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
                           struct BMLog *log,
                           const int cd_vert_node_offset,
                           const int cd_face_node_offset,
-                          const int cd_dyn_vert,
+                          const int cd_sculpt_vert,
                           const int cd_face_areas,
                           bool fast_draw);
 void BKE_pbvh_update_offsets(PBVH *pbvh,
                              const int cd_vert_node_offset,
                              const int cd_face_node_offset,
-                             const int cd_dyn_vert,
+                             const int cd_sculpt_vert,
                              const int cd_face_areas);
 void BKE_pbvh_free(PBVH *pbvh);
 
@@ -500,7 +500,7 @@ void BKE_pbvh_check_tri_areas(PBVH *pbvh, PBVHNode *node);
 // updates boundaries and valences for whole mesh
 void BKE_pbvh_bmesh_on_mesh_change(PBVH *pbvh);
 bool BKE_pbvh_bmesh_check_valence(PBVH *pbvh, SculptVertRef vertex);
-void BKE_pbvh_bmesh_update_valence(int cd_dyn_vert, SculptVertRef vertex);
+void BKE_pbvh_bmesh_update_valence(int cd_sculpt_vert, SculptVertRef vertex);
 void BKE_pbvh_bmesh_update_all_valence(PBVH *pbvh);
 void BKE_pbvh_bmesh_flag_all_disk_sort(PBVH *pbvh);
 bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, SculptVertRef vertex);
@@ -626,7 +626,7 @@ typedef struct PBVHVertexIter {
   struct TableGSet *bm_unique_verts, *bm_other_verts;
 
   struct CustomData *bm_vdata;
-  int cd_dyn_vert;
+  int cd_sculpt_vert;
   int cd_vert_mask_offset;
   int cd_vcol_offset;
 
@@ -642,7 +642,7 @@ typedef struct PBVHVertexIter {
   bool visible;
 } PBVHVertexIter;
 
-#define BKE_PBVH_DYNVERT(cd_dyn_vert, v) ((MDynTopoVert *)BM_ELEM_CD_GET_VOID_P(v, cd_dyn_vert))
+#define BKE_PBVH_SCULPTVERT(cd_sculpt_vert, v) ((MSculptVert *)BM_ELEM_CD_GET_VOID_P(v, cd_sculpt_vert))
 
 void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int mode);
 
@@ -833,7 +833,7 @@ PBVHNode *BKE_pbvh_node_from_face_bmesh(PBVH *pbvh, struct BMFace *f);
 PBVHNode *BKE_pbvh_node_from_index(PBVH *pbvh, int node_i);
 
 struct BMesh *BKE_pbvh_reorder_bmesh(PBVH *pbvh);
-void BKE_pbvh_update_vert_boundary(int cd_dyn_vert,
+void BKE_pbvh_update_vert_boundary(int cd_sculpt_vert,
                                    int cd_faceset_offset,
                                    int cd_vert_node_offset,
                                    int cd_face_node_offset,
@@ -947,20 +947,20 @@ void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
                                          struct MEdge *medge,
                                          struct MLoop *mloop,
                                          struct MPoly *mpoly,
-                                         struct MDynTopoVert *mdyntopo_verts,
+                                         struct MSculptVert *mdyntopo_verts,
                                          struct MeshElemMap *pmap,
                                          SculptVertRef vertex);
 void BKE_pbvh_update_vert_boundary_grids(PBVH *pbvh,
                                          struct SubdivCCG *subdiv_ccg,
                                          SculptVertRef vertex);
 
-void BKE_pbvh_set_mdyntopo_verts(PBVH *pbvh, struct MDynTopoVert *mdyntopoverts);
+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(MDynTopoVert *mv, int flag)
+ATTR_NO_OPT static void MV_ADD_FLAG(MSculptVert *mv, int flag)
 {
-  if (flag & DYNVERT_NEED_BOUNDARY) {
+  if (flag & SCULPTVERT_NEED_BOUNDARY) {
     flag |= flag;
   }
 
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 65462e6a8c1..636f60b22b5 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1504,14 +1504,14 @@ static bool layerValidate_propfloat2(void *data, const uint totitems, const bool
 
 static void layerDynTopoVert_copy(const void *source, void *dest, int count)
 {
-  memcpy(dest, source, count * sizeof(MDynTopoVert));
+  memcpy(dest, source, count * sizeof(MSculptVert));
 }
 
 static void layerDynTopoVert_interp(
     const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
 {
   float co[3], no[3], origmask, color[4];
-  MDynTopoVert *mv = (MDynTopoVert *)dest;
+  MSculptVert *mv = (MSculptVert *)dest;
   // float totweight = 0.0f;
 
   if (count == 0) {
@@ -1525,7 +1525,7 @@ static void layerDynTopoVert_interp(
   zero_v4(color);
 
   for (int i = 0; i < count; i++) {
-    MDynTopoVert *mv2 = (MDynTopoVert *)sources[i];
+    MSculptVert *mv2 = (MSculptVert *)sources[i];
     float w;
 
     if (i == 0) {  // copy flag from first source
@@ -1977,8 +1977,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
      NULL,
      layerDefault_mesh_id},
     /* 53 CD_DYNTOPO_VERT */
-    {sizeof(MDynTopoVert),
-     "MDynTopoVert",
+    {sizeof(MSculptVert),
+     "MSculptVert",
      1,
      NULL,  // flag singleton layer
      layerDynTopoVert_copy,
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index 6de21ce0f80..67384fb9cb8 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -36,15 +36,18 @@
 
 //#define DYNTOPO_REPORT
 
-#define DYNVERT_VALENCE_TEMP DYNVERT_SPLIT_TEMP
+#define SCULPTVERT_VALENCE_TEMP SCULPTVERT_SPLIT_TEMP
 
 #define USE_NEW_SPLIT
-#define DYNVERT_SMOOTH_BOUNDARY (DYNVERT_BOUNDARY | DYNVERT_FSET_BOUNDARY | DYNVERT_SHARP_BOUNDARY)
-#define DYNVERT_ALL_BOUNDARY \
-  (DYNVERT_BOUNDARY | DYNVERT_FSET_BOUNDARY | DYNVERT_SHARP_BOUNDARY | DYNVERT_SEAM_BOUNDARY)
-#define DYNVERT_SMOOTH_CORNER (DYNVERT_CORNER | DYNVERT_FSET_CORNER | DYNVERT_SHARP_CORNER)
-#define DYNVERT_ALL_CORNER \
-  (DYNVERT_CORNER | DYNVERT_FSET_CORNER | DYNVERT_SHARP_CORNER | DYNVERT_SEAM_CORNER)
+#define SCULPTVERT_SMOOTH_BOUNDARY \
+  (SCULPTVERT_BOUNDARY | SCULPTVERT_FSET_BOUNDARY | SCULPTVERT_SHARP_BOUNDARY)
+#define SCULPTVERT_ALL_BOUNDARY \
+  (SCULPTVERT_BOUNDARY | SCULPTVERT_FSET_BOUNDARY | SCULPTVERT_SHARP_BOUNDARY | \
+   SCULPTVERT_SEAM_BOUNDARY)
+#define SCULPTVERT_SMOOTH_CORNER \
+  (SCULPTVERT_CORNER | SCULPTVERT_FSET_CORNER | SCULPTVERT_SHARP_CORNER)
+#define SCULPTVERT_ALL_CORNER \
+  (SCULPTVERT_CORNER | SCULPTVERT_FSET_CORNER | SCULPTVERT_SHARP_CORNER | SCULPTVERT_SEAM_CORNER)
 
 #define DYNTOPO_MAX_ITER 4096
 
@@ -198,11 +201,11 @@ static void fix_mesh(PBVH *pbvh, BMesh *bm)
 
   BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
     v->e = NULL;
-    MDynTopoVert *mv = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert, v);
+    MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
 
     MV_ADD_FLAG(mv,
-                DYNVERT_NEED_VALENCE | DYNVERT_NEED_BOUNDARY | DYNVERT_NEED_DISK_SORT |
-                    DYNVERT_NEED_TRIANGULATE);
+                SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_BOUNDARY | SCULPTVERT_NEED_DISK_SORT |
+                    SCULPTVERT_NEED_TRIANGULATE);
   }
 
   BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
@@ -567,7 +570,7 @@ BLI_INLINE void surface_smooth_v_safe(PBVH *pbvh, BMVert *v, float fac)
   float tan[3];
   float tot = 0.0;
 
-  MDynTopoVert *mv1 = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert, v);
+  MSculptVert *mv1 = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
 
   if (mv1->stroke_id != pbvh->stroke_id) {
     copy_v3_v3(origco1, v->co);
@@ -590,17 +593,17 @@ BLI_INLINE void surface_smooth_v_safe(PBVH *pbvh, BMVert *v, float fac)
     return;
   }
 
-  if (mv1->flag & DYNVERT_NEED_BOUNDARY) {
+  if (mv1->flag & SCULPTVERT_NEED_BOUNDARY) {
     return;  // can't update boundary in thread
   }
 
   // pbvh_check_vert_boundary(pbvh, v);
 
-  const int cd_dyn_vert = pbvh->cd_dyn_vert;
+  const int cd_sculpt_vert = pbvh->cd_sculpt_vert;
 
-  const bool bound1 = mv1->flag & DYNVERT_SMOOTH_BOUNDARY;
+  const bool bound1 = mv1->flag & SCULPTVERT_SMOOTH_BOUNDARY;
 
-  if (mv1->flag & DYNVERT_SMOOTH_CORNER) {
+  if (mv1->flag & SCULPTVERT_SMOOTH_CORNER) {
     return;
   }
 
@@ -610,8 +613,8 @@ BLI_INLINE void surface_smooth_v_safe(PBVH *pbvh, BMVert *v, float fac)
     // can't check for boundary here, thread
     pbvh_check_vert_boundary(pbvh, v2);


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list