[Bf-blender-cvs] [9f45edd430f] sculpt-dev: Sculpt-dev: fix smooth_strength_factor bug

Joseph Eagar noreply at git.blender.org
Wed Nov 24 04:47:23 CET 2021


Commit: 9f45edd430f1daf8a9c7b966ccb692b8d0e51227
Author: Joseph Eagar
Date:   Tue Nov 23 19:46:18 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rB9f45edd430f1daf8a9c7b966ccb692b8d0e51227

Sculpt-dev: fix smooth_strength_factor bug

* Fixed bug where BRUSH_MAPPING_INHERIT was
  being or'd to BrushMapping->flag instead
  of assigned to ->inherit_mode.
* Fixed smooth_strength_factor
  and smooth_strength_projection.
* Also added yet more asan poisoning to mempool
* Added a function to build final inherited brush
  channel, BKE_brush_channel_copy_final_data.  Takes
  BrushMapping->inherit_mode into account.

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

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/intern/attribute.c
M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenkernel/intern/dyntopo.c
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/blenkernel/intern/pbvh_intern.h
M	source/blender/blenlib/intern/BLI_mempool.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/bmesh/intern/bmesh_core.c
M	source/blender/bmesh/intern/bmesh_private.h
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M	source/blender/editors/sculpt_paint/sculpt_filter_color.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 46c1d502164..fdca05b58fe 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 3
+#define BLENDER_FILE_SUBVERSION 4
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 731d4e04550..fee556cf905 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -249,6 +249,18 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
                                 BrushChannelSet *child,
                                 BrushChannelSet *parent);
 
+/*takes child and parent channels and builds inherited channel
+  in dst, with channel and brush mapping inheritance flags
+  properly resolved.
+
+  note that child or parent may be NULL, but not both.
+  */
+void BKE_brush_channel_copy_final_data(BrushChannel *dst,
+                                       BrushChannel *src_child,
+                                       BrushChannel *src_parent,
+                                       bool keep_mapping,
+                                       bool keep_idname_and_def);
+
 void BKE_brush_resolve_channels(struct Brush *brush, struct Sculpt *sd);
 
 void BKE_brush_channelset_set_final_int(BrushChannelSet *brushset,
@@ -309,10 +321,10 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
 
 /* returns size of vector */
 int BKE_brush_channelset_get_final_vector(BrushChannelSet *brushset,
-                                            BrushChannelSet *toolset,
-                                            const char *idname,
-                                            float r_vec[4],
-                                            BrushMappingData *mapdata);
+                                          BrushChannelSet *toolset,
+                                          const char *idname,
+                                          float r_vec[4],
+                                          BrushMappingData *mapdata);
 void BKE_brush_channelset_set_final_vector(BrushChannelSet *brushset,
                                            BrushChannelSet *toolset,
                                            const char *idname,
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c
index d13f3c4e277..f8e913894fd 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -477,7 +477,7 @@ CustomDataLayer *BKE_id_attributes_active_color_get(ID *id)
   }
 
   if (!ref->type) {
-    fprintf(stderr, "%s: invalid active color attribute\n", __func__);
+    //fprintf(stderr, "%s: invalid active color attribute\n", __func__);
     return NULL;
   }
 
@@ -515,7 +515,7 @@ void BKE_id_attributes_active_color_set(ID *id, CustomDataLayer *active_layer)
     if (customdata) {
       for (int i = 0; i < customdata->totlayer; i++) {
         CustomDataLayer *layer = &customdata->layers[i];
-
+        
         if (layer == active_layer && ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
           ref->type = layer->type;
           ref->domain = domain;
@@ -548,7 +548,7 @@ CustomDataLayer *BKE_id_attributes_render_color_get(ID *id)
   }
 
   if (!ref->type) {
-    fprintf(stderr, "%s: invalid render color attribute\n", __func__);
+    //fprintf(stderr, "%s: invalid render color attribute\n", __func__);
     return NULL;
   }
 
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 72f474b8163..6c7b40b3293 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -48,7 +48,7 @@
 #  pragma warning(error : 4018) /* signed/unsigned mismatch */
 #  pragma warning(error : 4245) /* conversion from 'int' to 'unsigned int' */
 #  pragma warning(error : 4389) /* signed/unsigned mismatch */
-#  pragma warning(error : 4002) /* too many actual parameters for macro 'identifier' */
+#  pragma warning(error : 4002) /* too many actual maeters for macro 'identifier' */
 #  pragma warning(error : 4003) /* not enough actual parameters for macro 'identifier' */
 #  pragma warning( \
       error : 4022) /* 'function': pointer mismatch for actual parameter 'parameter number' */
@@ -328,6 +328,53 @@ static void copy_channel_data_keep_mappings(BrushChannel *dst,
   }
 }
 
+void BKE_brush_channel_copy_final_data(BrushChannel *dst,
+                                       BrushChannel *src_child,
+                                       BrushChannel *src_parent,
+                                       bool keep_mapping,
+                                       bool keep_idname_and_def)
+{
+  if (!src_child || !src_parent) {
+    BKE_brush_channel_copy_data(
+        dst, src_child ? src_child : src_parent, keep_mapping, keep_idname_and_def);
+    return;
+  }
+
+  if (src_child->flag & BRUSH_CHANNEL_INHERIT) {
+    BKE_brush_channel_copy_data(dst, src_parent, keep_mapping, keep_idname_and_def);
+  }
+  else {
+    BKE_brush_channel_copy_data(dst, src_child, keep_mapping, keep_idname_and_def);
+  }
+
+  if (keep_mapping) {
+    return;
+  }
+
+  for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
+    BrushMapping *mp = NULL;
+
+    switch (src_child->mappings[i].inherit_mode) {
+      case BRUSH_MAPPING_INHERIT_CHANNEL:
+        mp = src_child->flag & BRUSH_CHANNEL_INHERIT ? src_parent->mappings + i :
+                                                       src_child->mappings + i;
+        break;
+      case BRUSH_MAPPING_INHERIT_ALWAYS:
+        mp = src_parent->mappings + i;
+        break;
+      case BRUSH_MAPPING_INHERIT_NEVER:
+        mp = src_child->mappings + i;
+        break;
+    }
+
+    if (UNLIKELY(!mp)) {
+      continue;
+    }
+
+    BKE_brush_mapping_copy_data(dst->mappings + i, mp);
+  }
+}
+
 void BKE_brush_channel_copy_data(BrushChannel *dst,
                                  BrushChannel *src,
                                  bool keep_mapping,
@@ -463,7 +510,7 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
     }
 
     if (mdef->inherit) {
-      mp->flag |= BRUSH_MAPPING_INHERIT_ALWAYS;
+      mp->inherit_mode = BRUSH_MAPPING_INHERIT_ALWAYS;
     }
 
     int slope = CURVEMAP_SLOPE_POSITIVE;
@@ -840,10 +887,8 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
       BKE_brush_channel_copy_data(mch, pch, true, false);
     }
 
-    /*apply mapping inheritance flags, which are respected
-      for non inherited channels.  note that absense
-      of BRUSH_MAPPING_FLAG doen't prevent mapping inheritance
-      if BRUSH_CHANNEL_INHERIT in ch->flag *is* set.*/
+    /* apply mapping inheritance flags, which are respected
+       even for non inherited channels.*/
     for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
       if (brush_mapping_inherits(ch, ch->mappings + i)) {
         BKE_brush_mapping_copy_data(mch->mappings + i, pch->mappings + i);
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 1c99cb37547..261f166b548 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -274,6 +274,7 @@ static bool check_builtin_init()
 
     for (int j = 0; j < BRUSH_MAPPING_MAX; j++) {
       (&def->mappings.pressure)[j].inherit = true;
+      (&def->mappings.pressure)[j].enabled = i == 0 && j == 0;
     }
   }
 
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index bc813d617e7..a05b42e2e5a 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -2877,6 +2877,10 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
         // deal with non-manifold iffyness
         destroy_nonmanifold_fins(pbvh, e);
         push_subentry = true;
+
+        if (bm_elem_is_free((BMElem *)e, BM_EDGE)) {
+          continue;
+        }
       }
 
       MSculptVert *mv1 = BKE_PBVH_SCULPTVERT(cd_sculpt_vert, e->v1);
@@ -3798,6 +3802,13 @@ static BMVert *pbvh_bmesh_collapse_edge(PBVH *pbvh,
       }
 
       do {
+        BMLoop *l2 = l;
+        do {
+          if (BM_ELEM_CD_GET_INT(l2->v, pbvh->cd_vert_node_offset) != DYNTOPO_NODE_NONE) {
+            pbvh_bmesh_vert_remove(pbvh, l2->v);
+          }
+        } while ((l2 = l2->next) != l);
+
         if (BM_ELEM_CD_GET_INT(l->f, pbvh->cd_face_node_offset) != DYNTOPO_NODE_NONE) {
           pbvh_bmesh_face_remove(pbvh, l->f, false, false, false);
           BM_log_face_topo_pre(pbvh->bm_log, l->f);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index b8f87818a70..7301b792b70 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1084,6 +1084,12 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
     Sculpt *data = MEM_callocN(sizeof(*data), __func__);
     paint = &data->paint;
 
+    if (!data->channels) {
+      data->channels = BKE_brush_channelset_create(__func__);
+    }
+
+    BKE_brush_check_toolsettings(data);
+
     /* Turn on X plane mirror symmetry by default */
     paint->symmetry_flags |= PAINT_SYMM_X;
 
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 9b8534a985f..3ccdf3d444a 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -68,6 +68,7 @@ Topology rake:
 
 #include "bmesh.h"
 #include "pbvh_intern.h"
+#include "atomic_ops.h"
 
 #include <math.h>
 #include <stdio.h>
@@ -75,7 +76,7 @@ Topology rake:
 
 #include <stdarg.h>
 
-static void _debugprint(const char *fmt, ...)
+ATTR_NO_OPT static

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list