[Bf-blender-cvs] [c6a51c12590] sculpt-dev: Sculpt: move more brush settings to brush channels

Joseph Eagar noreply at git.blender.org
Thu Sep 23 12:41:24 CEST 2021


Commit: c6a51c1259043a3d8c13dc3358c0b5d9a3d9e1b4
Author: Joseph Eagar
Date:   Thu Sep 23 02:13:00 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBc6a51c1259043a3d8c13dc3358c0b5d9a3d9e1b4

Sculpt: move more brush settings to brush channels

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

M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/brush_channel_define.h
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_boundary.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_undo.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 3ccd2f32821..3accc74af59 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -95,7 +95,7 @@ typedef struct BrushMappingData {
 typedef struct BrushEnumDef {
   int value;
   const char identifier[64];
-  char icon[32];
+  char icon[32];  // don't forget when writing literals that icon here is a string, not an int!
   const char name[64];
   const char description[512];
 } BrushEnumDef;
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 9949408d77b..b07e8e8be15 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -340,6 +340,12 @@ typedef struct SculptClothSimulation {
   float damping;
   float softbody_strength;
 
+  // cache some values here to avoid
+  // brush channel lookups inside of inner loops
+  float sim_limit;
+  int simulation_area_type;
+  float sim_falloff;
+
   float (*acceleration)[3];
   float (*pos)[3];
   float (*init_pos)[3];
@@ -476,6 +482,8 @@ typedef struct SculptBoundary {
     float (*origin)[3];
     float *radius;
   } circle;
+
+  int deform_target;
 } SculptBoundary;
 
 /* Array Brush. */
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 0e1c440c5c7..b26a1370cc6 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -538,7 +538,7 @@ void BKE_pbvh_bmesh_regen_node_verts(PBVH *pbvh);
 void BKE_pbvh_bmesh_mark_node_regen(PBVH *pbvh, PBVHNode *node);
 
 // now generated PBVHTris
-void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh);
+void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh, bool force_balance);
 
 /* Update Bounding Box/Redraw and clear flags */
 
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 1dd58279db0..8a57caf3349 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -216,32 +216,28 @@ MAKE_FLOAT(multiplane_scrape_angle, "Plane Angle", "Angle between the planes of
 
 MAKE_BOOL(use_persistent, "Persistent", "Sculpt on a persistent layer of the mesh", false)
 MAKE_ENUM(cloth_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_CLOTH_DEFORM_DRAG, _({
-      {BRUSH_CLOTH_DEFORM_DRAG, "DRAG", 0, "Drag", ""},
-      {BRUSH_CLOTH_DEFORM_PUSH, "PUSH", 0, "Push", ""},
-      {BRUSH_CLOTH_DEFORM_PINCH_POINT, "PINCH_POINT", 0, "Pinch Point", ""},
-      {BRUSH_CLOTH_DEFORM_PINCH_PERPENDICULAR,
-       "PINCH_PERPENDICULAR",
-       0,
-       "Pinch Perpendicular",
-       ""},
-      {BRUSH_CLOTH_DEFORM_INFLATE, "INFLATE", 0, "Inflate", ""},
-      {BRUSH_CLOTH_DEFORM_GRAB, "GRAB", 0, "Grab", ""},
-      {BRUSH_CLOTH_DEFORM_EXPAND, "EXPAND", 0, "Expand", ""},
-      {BRUSH_CLOTH_DEFORM_SNAKE_HOOK, "SNAKE_HOOK", 0, "Snake Hook", ""},
-      {BRUSH_CLOTH_DEFORM_ELASTIC_DRAG, "ELASTIC", 0, "Elastic Drag", ""},
+      {BRUSH_CLOTH_DEFORM_DRAG, "DRAG", "NONE", "Drag", ""},
+      {BRUSH_CLOTH_DEFORM_PUSH, "PUSH", "NONE", "Push", ""},
+      {BRUSH_CLOTH_DEFORM_PINCH_POINT, "PINCH_POINT", "NONE", "Pinch Point", ""},
+      {BRUSH_CLOTH_DEFORM_PINCH_PERPENDICULAR, "PINCH_PERPENDICULAR", "NONE", "Pinch Perpendicular", ""},
+      {BRUSH_CLOTH_DEFORM_INFLATE, "INFLATE", "NONE", "Inflate", ""},
+      {BRUSH_CLOTH_DEFORM_GRAB, "GRAB", "NONE", "Grab", ""},
+      {BRUSH_CLOTH_DEFORM_EXPAND, "EXPAND", "NONE", "Expand", ""},
+      {BRUSH_CLOTH_DEFORM_SNAKE_HOOK, "SNAKE_HOOK", "NONE", "Snake Hook", ""},
+      {BRUSH_CLOTH_DEFORM_ELASTIC_DRAG, "ELASTIC", "NONE", "Elastic Drag", ""},
       {-1}
 }))
 
 MAKE_ENUM(cloth_simulation_area_type, "Simulation Area", "Part of the mesh that is going to be simulated when the stroke is active", BRUSH_CLOTH_SIMULATION_AREA_LOCAL, _({
   {BRUSH_CLOTH_SIMULATION_AREA_LOCAL,
     "LOCAL",
-    0,
+    "NONE",
     "Local",
     "Simulates only a specific area around the brush limited by a fixed radius"},
-  {BRUSH_CLOTH_SIMULATION_AREA_GLOBAL, "GLOBAL", 0, "Global", "Simulates the entire mesh"},
+  {BRUSH_CLOTH_SIMULATION_AREA_GLOBAL, "GLOBAL", "NONE", "Global", "Simulates the entire mesh"},
   {BRUSH_CLOTH_SIMULATION_AREA_DYNAMIC,
     "DYNAMIC",
-    0,
+    "NONE",
     "Dynamic",
     "The active simulation area moves with the brush"},
   {-1}
@@ -249,8 +245,8 @@ MAKE_ENUM(cloth_simulation_area_type, "Simulation Area", "Part of the mesh that
 
 MAKE_ENUM(cloth_force_falloff_type, "Force Falloff", "Shape used in the brush to apply force to the cloth",
   BRUSH_CLOTH_FORCE_FALLOFF_RADIAL, _({
-      {BRUSH_CLOTH_FORCE_FALLOFF_RADIAL, "RADIAL", 0, "Radial", ""},
-      {BRUSH_CLOTH_FORCE_FALLOFF_PLANE, "PLANE", 0, "Plane", ""},
+      {BRUSH_CLOTH_FORCE_FALLOFF_RADIAL, "RADIAL", "NONE", "Radial", ""},
+      {BRUSH_CLOTH_FORCE_FALLOFF_PLANE, "PLANE", "NONE", "Plane", ""},
       {-1}
 }))
 
@@ -262,7 +258,64 @@ MAKE_FLOAT(cloth_sim_falloff, "Simulation Falloff",
                            "Area to apply deformation falloff to the effects of the simulation", 0.75f, 0.0f, 1.0f)
 MAKE_FLOAT(cloth_constraint_softbody_strength,  "Soft Body Plasticity",
       "How much the cloth preserves the original shape, acting as a soft body", 0.0f, 0.0f, 1.0f)
+MAKE_BOOL(cloth_use_collision,  "Enable Collision", "Collide with objects during the simulation", false)
+
 MAKE_BOOL(use_frontface, "Use Front-Face", "Brush only affects vertexes that face the viewer", false)
+MAKE_BOOL(cloth_pin_simulation_boundary, "Pin Simulation Boundary",
+      "Lock the position of the vertices in the simulation falloff area to avoid artifacts and "
+      "create a softer transition with unaffected areas", false)
+
+MAKE_FLOAT(boundary_offset, "Boundary Origin Offset",
+                           "Offset of the boundary origin in relation to the brush radius", 0.05f, 0.0f, 1.0f)
+MAKE_ENUM(boundary_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_BOUNDARY_DEFORM_BEND, _({
+      {BRUSH_BOUNDARY_DEFORM_BEND, "BEND", "NONE", "Bend", ""},
+      {BRUSH_BOUNDARY_DEFORM_EXPAND, "EXPAND", "NONE", "Expand", ""},
+      {BRUSH_BOUNDARY_DEFORM_INFLATE, "INFLATE", "NONE", "Inflate", ""},
+      {BRUSH_BOUNDARY_DEFORM_GRAB, "GRAB", "NONE", "Grab", ""},
+      {BRUSH_BOUNDARY_DEFORM_TWIST, "TWIST", "NONE", "Twist", ""},
+      {BRUSH_BOUNDARY_DEFORM_SMOOTH, "SMOOTH", "NONE", "Smooth", ""},
+      {BRUSH_BOUNDARY_DEFORM_CIRCLE, "CIRCLE", "NONE", "Circle", ""},
+      {-1}
+}))
+
+MAKE_ENUM(boundary_falloff_type, "Boundary Falloff", "How the brush falloff is applied across the boundary", BRUSH_BOUNDARY_FALLOFF_CONSTANT, _({
+      {BRUSH_BOUNDARY_FALLOFF_CONSTANT,
+       "CONSTANT",
+       "NONE",
+       "Constant",
+       "Applies the same deformation in the entire boundary"},
+      {BRUSH_BOUNDARY_FALLOFF_RADIUS,
+       "RADIUS",
+       "NONE",
+       "Brush Radius",
+       "Applies the deformation in a localized area limited by the brush radius"},
+      {BRUSH_BOUNDARY_FALLOFF_LOOP,
+       "LOOP",
+       "NONE",
+       "Loop",
+       "Applies the brush falloff in a loop pattern"},
+      {BRUSH_BOUNDARY_FALLOFF_LOOP_INVERT,
+       "LOOP_INVERT",
+       "NONE",
+       "Loop and Invert",
+       "Applies the falloff radius in a loop pattern, inverting the displacement direction in "
+       "each pattern repetition"},
+      {-1}
+}))
+
+MAKE_ENUM(deform_target, "Deformation Target", "How the deformation of the brush will affect the object", BRUSH_DEFORM_TARGET_GEOMETRY, _({
+{BRUSH_DEFORM_TARGET_GEOMETRY,
+    "GEOMETRY",
+    "NONE",
+    "Geometry",
+    "Brush deformation displaces the vertices of the mesh"},
+    {BRUSH_DEFORM_TARGET_CLOTH_SIM,
+    "CLOTH_SIM",
+    "NONE",
+    "Cloth Simulation",
+    "Brush deforms the mesh by deforming the constraints of a cloth simulation"},
+    {-1}
+}))
 
 /* clang-format on */
 #if defined(BRUSH_CHANNEL_DEFINE_TYPES) || defined(BRUSH_CHANNEL_DEFINE_EXTERNAL)
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 9d83e3e6b3b..90ac27b51e3 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -160,6 +160,7 @@ That includes per-brush enums and bitflags!
 
 BrushChannelType brush_builtin_channels[] = {    
 #include "brush_channel_define.h"
+
 };
 
 /* clang-format on */
@@ -270,6 +271,10 @@ static BrushSettingsMap brush_settings_map[] = {
   DEF(cloth_sim_limit, cloth_sim_limit, FLOAT, FLOAT)
   DEF(cloth_sim_falloff, cloth_sim_falloff, FLOAT, FLOAT)
   DEF(cloth_constraint_softbody_strength, cloth_constraint_softbody_strength, FLOAT, FLOAT)
+  DEF(boundary_offset, boundary_offset, FLOAT, FLOAT)
+  DEF(boundary_deform_type, boundary_deform_type, INT, INT)
+  DEF(boundary_falloff_type, boundary_falloff_type, INT, INT)
+  DEF(deform_target, deform_target, INT, INT)
 };
 
 static const int brush_settings_map_len = ARRAY_SIZE(brush_settings_map);
@@ -325,6 +330,8 @@ BrushFlagMap brush_flags_map[] =  {
   DEF(flag2, show_multiplane_scrape_planes_preview, BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW)
   DEF(flag, use_persistent, BRUSH_PERSISTENT)
   DEF(flag, use_frontface, BRUSH_FRONTFACE)
+  DEF(flag2, cloth_use_collision, BRUSH_CLOTH_USE_COLLISION)
+  DEF(flag2, cloth_pin_simulation_boundary, BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY)
 };
 
 int brush_flags_map_len = ARRAY_SIZE(brush_flags_map);
@@ -669,15 +676,23 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
   ADDCH(fset_slide);
 
   ADDCH(direction);
+  ADDCH(dash_ratio);
+  ADDCH(smooth_stroke_factor);
+  ADDCH(smooth_stroke_radius);
 
   switch (tool) {
-    case SCULPT_TOOL_DRAW: {
+    case SCULPT_TOOL_DRAW:
       break;
-    }
-
     case SCULPT_TOOL_PAINT: {
       ADDCH(color);
       ADDCH(secondary_color);
+      ADDCH(wet_mix);
+      ADDCH(wet_persistence);
+      ADDCH(density);
+      ADDCH(tip_scale_x);
+      ADDCH(flow);
+      ADDCH(rate);
+
       break;
     }
     case SCULPT_TOOL_SLIDE_RELAX:
@@ -692,7 +70

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list