[Bf-blender-cvs] [3788fd2c290] sculpt-dev: Sculpt-dev: expose a few cloth settings for cloth deform target in bounday/pose brushes.

Joseph Eagar noreply at git.blender.org
Sun Dec 5 07:51:12 CET 2021


Commit: 3788fd2c290948eeb9b517702b77c829ece1bf12
Author: Joseph Eagar
Date:   Sat Dec 4 19:45:31 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rB3788fd2c290948eeb9b517702b77c829ece1bf12

Sculpt-dev: expose a few cloth settings for cloth
            deform target in bounday/pose brushes.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenkernel/intern/dyntopo.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/bmesh/intern/bmesh_construct.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_cloth.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_transform.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index d69d08aa4bb..7431cbbe4c5 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -479,6 +479,10 @@ class VIEW3D_PT_tools_brush_color(Panel, View3DPaintPanel):
     @classmethod
     def poll(cls, context):
         settings = cls.paint_settings(context)
+
+        if not settings:
+            return False
+
         brush = settings.brush
 
         if context.image_paint_object:
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index fdca05b58fe..b758734f05e 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 4
+#define BLENDER_FILE_SUBVERSION 5
 
 /* 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 472ae082068..9fbb980f126 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -76,6 +76,8 @@ struct UnifiedPaintSettings;
   BKE_brush_channelset_get_final_float(childset, parentset, MAKE_BUILTIN_CH_NAME(channel), mapdata)
 #define BRUSHSET_GET_INT(chset, channel, mapdata) \
   BKE_brush_channelset_get_int(chset, MAKE_BUILTIN_CH_NAME(channel), mapdata)
+#define BRUSHSET_GET_BOOL(chset, channel, mapdata) \
+  (!!BRUSHSET_GET_INT(chset, channel, mapdata))
 #define BRUSHSET_GET_FINAL_INT(child, parent, channel, mapdata) \
   BKE_brush_channelset_get_final_int(child, parent, MAKE_BUILTIN_CH_NAME(channel), mapdata)
 #define BRUSHSET_GET_FINAL_BOOL(child, parent, channel, mapdata) \
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 6d3d03363af..3f6f28bcb2c 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -2950,105 +2950,6 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool
   return im;
 }
 
-void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
-{
-  *out = brush->dyntopo;
-
-  int inherit = out->inherit;
-
-  if (inherit & DYNTOPO_INHERIT_ALL) {
-    inherit = 0x7FFFFFFF;
-  }
-
-  if (!(sd->flags & SCULPT_DYNTOPO_ENABLED)) {
-    out->flag |= DYNTOPO_DISABLED;
-  }
-
-  if (inherit & DYNTOPO_INHERIT_MODE) {
-    if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
-      out->mode = DYNTOPO_DETAIL_CONSTANT;
-    }
-    else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
-      out->mode = DYNTOPO_DETAIL_BRUSH;
-    }
-    else if (sd->flags & SCULPT_DYNTOPO_DETAIL_MANUAL) {
-      out->mode = DYNTOPO_DETAIL_MANUAL;
-    }
-    else {
-      out->mode = DYNTOPO_DETAIL_RELATIVE;
-    }
-  }
-
-  if (inherit & DYNTOPO_INHERIT_RADIUS_SCALE) {
-    out->radius_scale = sd->dyntopo_radius_scale;
-  }
-
-  if (inherit & DYNTOPO_INHERIT_DETAIL_SIZE) {
-    out->detail_size = sd->detail_size;
-  }
-
-  if (inherit & DYNTOPO_INHERIT_DETAIL_RANGE) {
-    out->detail_range = sd->detail_range;
-  }
-
-  if (inherit & DYNTOPO_INHERIT_DETAIL_PERCENT) {
-    out->detail_percent = sd->detail_percent;
-  }
-
-  if (inherit & DYNTOPO_INHERIT_SPACING) {
-    out->spacing = sd->dyntopo_spacing;
-  }
-
-  if (inherit & DYNTOPO_INHERIT_CONSTANT_DETAIL) {
-    out->constant_detail = sd->constant_detail;
-  }
-
-  if (inherit & DYNTOPO_SUBDIVIDE) {
-    if (sd->flags & SCULPT_DYNTOPO_SUBDIVIDE) {
-      out->flag |= DYNTOPO_SUBDIVIDE;
-    }
-    else {
-      out->flag &= ~DYNTOPO_SUBDIVIDE;
-    }
-  }
-
-  if (inherit & DYNTOPO_LOCAL_COLLAPSE) {
-    if (sd->flags & SCULPT_DYNTOPO_LOCAL_COLLAPSE) {
-      out->flag |= DYNTOPO_LOCAL_COLLAPSE;
-    }
-    else {
-      out->flag &= ~DYNTOPO_LOCAL_COLLAPSE;
-    }
-  }
-
-  if (inherit & DYNTOPO_LOCAL_SUBDIVIDE) {
-    if (sd->flags & SCULPT_DYNTOPO_LOCAL_SUBDIVIDE) {
-      out->flag |= DYNTOPO_LOCAL_SUBDIVIDE;
-    }
-    else {
-      out->flag &= ~DYNTOPO_LOCAL_SUBDIVIDE;
-    }
-  }
-
-  if (inherit & DYNTOPO_COLLAPSE) {
-    if (sd->flags & SCULPT_DYNTOPO_COLLAPSE) {
-      out->flag |= DYNTOPO_COLLAPSE;
-    }
-    else {
-      out->flag &= ~DYNTOPO_COLLAPSE;
-    }
-  }
-
-  if (inherit & DYNTOPO_CLEANUP) {
-    if (sd->flags & SCULPT_DYNTOPO_CLEANUP) {
-      out->flag |= DYNTOPO_CLEANUP;
-    }
-    else {
-      out->flag &= ~DYNTOPO_CLEANUP;
-    }
-  }
-};
-
 bool BKE_brush_hard_edge_mode_get(const Scene *scene, const Brush *brush)
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 08b427b133a..96ef4a4aa88 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -1199,6 +1199,11 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
 
   ADDCH(deform_target);
 
+  /* stuff for deform_target cloth mode*/
+  ADDCH(cloth_use_collision);
+  ADDCH(cloth_solve_bending);
+  ADDCH(cloth_bending_stiffness);
+  
   switch (tool) {
     case SCULPT_TOOL_CLAY:
       if (set_mappings) {
@@ -1250,8 +1255,6 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
       ADDCH(slide_deform_type);
       break;
     case SCULPT_TOOL_CLOTH:
-      ADDCH(cloth_solve_bending);
-      ADDCH(cloth_bending_stiffness);
       ADDCH(cloth_mass);
       ADDCH(cloth_damping);
       ADDCH(cloth_sim_limit);
@@ -1259,7 +1262,6 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
       ADDCH(cloth_deform_type);
       ADDCH(cloth_force_falloff_type);
       ADDCH(cloth_simulation_area_type);
-      ADDCH(cloth_deform_type);
       ADDCH(cloth_use_collision);
       ADDCH(cloth_pin_simulation_boundary);
       ADDCH(cloth_constraint_softbody_strength);
@@ -1356,6 +1358,12 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
     SHOWWRK(hard_edge_mode);
   }
 
+  if (ELEM(brush->sculpt_tool, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_POSE)) {
+    SHOW_WRK_CTX(cloth_use_collision);
+    SHOW_WRK_CTX(cloth_solve_bending);
+    SHOW_WRK_CTX(cloth_bending_stiffness);
+  }
+
   if (!ELEM(tool,
             SCULPT_TOOL_SNAKE_HOOK,
             SCULPT_TOOL_ARRAY,
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index 247b4e50e5d..f5b695275c0 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -3955,7 +3955,7 @@ static BMVert *pbvh_bmesh_collapse_edge(PBVH *pbvh,
       lnext = l->radial_next;
 
       bool fbad = false;
-#if 1
+#if 0
       do {
 
         if (l2->v == l2->next->v) {
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 13f6c498c31..0f473ed2778 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -2666,6 +2666,25 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 301, 5)) {
+    LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
+      if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_POSE)) {
+        continue;
+      }
+
+      /* check that all needed channels exist */
+      BKE_brush_builtin_patch(brush, brush->sculpt_tool);
+
+      BrushChannel *ch = BRUSHSET_LOOKUP(brush->channels, cloth_use_collision);
+      ch->flag |= BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU | BRUSH_CHANNEL_SHOW_IN_WORKSPACE;
+
+      ch = BRUSHSET_LOOKUP(brush->channels, cloth_solve_bending);
+      ch->flag |= BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU | BRUSH_CHANNEL_SHOW_IN_WORKSPACE;
+
+      ch = BRUSHSET_LOOKUP(brush->channels, cloth_bending_stiffness);
+      ch->flag |= BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU | BRUSH_CHANNEL_SHOW_IN_WORKSPACE;
+    }
+  }
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 74f9dac9239..021ae75f694 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -126,7 +126,13 @@ void bm_id_freelist_take(BMesh *bm, uint id)
 
       // swap with end
       void **endval = BLI_ghash_lookup_p(bm->idmap.free_idx_map, POINTER_FROM_UINT(end));
-      *endval = POINTER_FROM_UINT(i);
+      if (endval) {
+        *endval = POINTER_FROM_UINT(i);
+      }
+      else {
+        printf("%s: end id %d was not in free_idx_map; id was %d\n", __func__, end, id);
+        BLI_ghash_insert(bm->idmap.free_idx_map, POINTER_FROM_UINT(end), POINTER_FROM_UINT(i));
+      }
 
       bm->idmap.freelist[i] = bm->idmap.freelist[bm->idmap.freelist_len - 1];
       bm->idmap.freelist_len--;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 7000cb441b6..8d9853983e7 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3072,17 +3072,12 @@ void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, SculptVertRef v
 
 /* Returns true if the stroke will use dynamic topology, false
  * otherwise.
- *
- * Factors: some brushes like grab cannot do dynamic topology.
- * Others, like smooth, are better without.
- * Same goes for alt-key smoothing. */
+ */
 bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush)
 {
   return (
       (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) &&
 
-      (!ss->cache || (!ss->cache->alt_smooth)) &&
-
       /* Requires mesh restore, which doesn't work with
        * dynamic-topology. */
       !(brush->flag & BRUSH_ANCHORED) && !(brush->flag & BRUSH_DRAG_DOT) &&
@@ -5334,10 +5329,19 @@ void do_brush_action(
     SCULPT_pose_brush_init(sd, ob, ss, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list