[Bf-blender-cvs] [45f45d9e07b] sculpt-dev: Sculpt: more brush engine stuff
Joseph Eagar
noreply at git.blender.org
Sun Sep 26 11:47:47 CEST 2021
Commit: 45f45d9e07b74c754034a64f2b62e51abb74954c
Author: Joseph Eagar
Date: Sun Sep 26 02:47:01 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB45f45d9e07b74c754034a64f2b62e51abb74954c
Sculpt: more brush engine stuff
* Setting sculpt paint color from
the palette works again.
* Fixed various defaults.
===================================================================
M source/blender/blenkernel/BKE_brush.h
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/intern/brush.c
M source/blender/blenkernel/intern/brush_channel_define.h
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/blenloader/intern/versioning_300.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/editors/sculpt_paint/paint_utils.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_boundary.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index c42bc2e4e0a..d8a398c70ce 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -109,7 +109,10 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br,
const float *BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush);
const float *BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush);
-void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3]);
+void BKE_brush_color_set(struct Scene *scene,
+ struct Brush *brush,
+ const float color[3],
+ const bool use_brush_channels);
int BKE_brush_size_get(const struct Scene *scene,
const struct Brush *brush,
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 2f6ebe1d740..9458f179dc0 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -79,6 +79,13 @@ struct Sculpt;
BKE_brush_channelset_set_int(chset, MAKE_BUILTIN_CH_NAME(channel), val)
#define BRUSHSET_SET_BOOL(chset, channel, val) BRUSHSET_SET_INT(chset, channel, (val) ? 1 : 0)
+#define BRUSHSET_GET_VECTOR(chset, channel, out, mapdata) \
+ BKE_brush_channelset_get_vector(chset, MAKE_BUILTIN_CH_NAME(channel), out, mapdata)
+#define BRUSHSET_SET_VECTOR(chset, channel, out, mapdata) \
+ BKE_brush_channelset_set_vector(chset, MAKE_BUILTIN_CH_NAME(channel), out)
+#define BRUSHSET_GET_FINAL_VECTOR(child, parent, channel, out, mapdata) \
+ BKE_brush_channelset_get_final_vector(child, parent, MAKE_BUILTIN_CH_NAME(channel), out, mapdata)
+
//#define DEBUG_CURVE_MAPPING_ALLOC
#ifdef DEBUG_CURVE_MAPPING_ALLOC
void namestack_push(const char *name);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 24ab010130c..04a6e1347e5 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -2473,10 +2473,32 @@ const float *BKE_brush_secondary_color_get(const struct Scene *scene, const stru
return (ups->flag & UNIFIED_PAINT_COLOR) ? ups->secondary_rgb : brush->secondary_rgb;
}
-void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3])
+void BKE_brush_color_set(struct Scene *scene,
+ struct Brush *brush,
+ const float color[3],
+ const bool use_brush_channels)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+ if (use_brush_channels) {
+ BrushChannel *ch;
+
+ ch = BRUSHSET_LOOKUP(brush->channels, color);
+
+ if ((ch->flag & BRUSH_CHANNEL_INHERIT) && scene->toolsettings->sculpt &&
+ scene->toolsettings->sculpt->channels) {
+ BrushChannel *pch = BRUSHSET_LOOKUP(scene->toolsettings->sculpt->channels, color);
+
+ if (pch) {
+ ch = pch;
+ }
+ }
+
+ if (ch) {
+ copy_v3_v3(ch->vector, color);
+ }
+ }
+
if (ups->flag & UNIFIED_PAINT_COLOR) {
copy_v3_v3(ups->rgb, color);
}
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 57a1d4e598a..f553d74f9e2 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -291,7 +291,7 @@ MAKE_BOOL(cloth_pin_simulation_boundary, "Pin Simulation Boundary",
"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)
+ "Offset of the boundary origin in relation to the brush radius", 0.05f, 0.0f, 10.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", ""},
@@ -431,6 +431,17 @@ MAKE_BOOL(mtex_use_rake, "Rake", "", false)
MAKE_BOOL(mtex_use_random, "Random", "", false)
MAKE_FLOAT(mtex_random_angle, "Random Angle", "Brush texture random angle", 0.0f, 0.0f, M_PI*2.0f)
MAKE_FLOAT(mtex_angle, "Angle", "", 0.0f, 0.0f, M_PI*2.0f)
+MAKE_FLOAT_EX(height, "Brush Height", "Affectable height of brush (layer height for layer tool, i.e.)", 0.05f, 0.0f, 1.0f, 0.0f, 0.2f, false)
+MAKE_BOOL(use_space_attenuation, "Adjust Strength for Spacing",
+ "Automatically adjust strength to give consistent results for different spacings", true)
+MAKE_ENUM(elastic_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_ELASTIC_DEFORM_GRAB_TRISCALE, _({
+ {BRUSH_ELASTIC_DEFORM_GRAB, "GRAB", "NONE", "Grab", ""},
+ {BRUSH_ELASTIC_DEFORM_GRAB_BISCALE, "GRAB_BISCALE", "NONE", "Bi-Scale Grab", ""},
+ {BRUSH_ELASTIC_DEFORM_GRAB_TRISCALE, "GRAB_TRISCALE", "NONE", "Tri-Scale Grab", ""},
+ {BRUSH_ELASTIC_DEFORM_SCALE, "SCALE", "NONE", "Scale", ""},
+ {BRUSH_ELASTIC_DEFORM_TWIST, "TWIST", "NONE", "Twist", ""},
+ {-1}
+}))
//MAKE_FLOAT3_EX
/* clang-format on */
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 7f80f366e3b..e6a55af2fd3 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -1135,6 +1135,9 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
}
}
}
+ else {
+ copy_v4_v4(out, ch->vector);
+ }
return size;
}
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 13812067140..21a1180044e 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -319,6 +319,8 @@ static BrushSettingsMap brush_settings_map[] = {
DEF(snake_hook_deform_type, snake_hook_deform_type, INT, INT)
DEF(tip_roundness, tip_roundness, FLOAT, FLOAT)
DEF(tip_scale_x, tip_scale_x, FLOAT, FLOAT)
+ DEF(height, height, FLOAT, FLOAT)
+ DEF(elastic_deform_type, elastic_deform_type, INT, INT)
};
static const int brush_settings_map_len = ARRAY_SIZE(brush_settings_map);
@@ -382,6 +384,7 @@ BrushFlagMap brush_flags_map[] = {
DEF(flag2, use_pose_ik_anchored, BRUSH_POSE_IK_ANCHORED)
DEF(flag2, use_connected_only, BRUSH_USE_CONNECTED_ONLY)
DEF(flag2, use_pose_lock_rotation, BRUSH_POSE_USE_LOCK_ROTATION)
+ DEF(flag, use_space_attenuation, BRUSH_SPACE_ATTEN)
};
int brush_flags_map_len = ARRAY_SIZE(brush_flags_map);
@@ -789,14 +792,15 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
ADDCH(concave_mask_factor);
ADDCH(dyntopo_disabled);
- ADDCH(dyntopo_detail_mode)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_mode)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_detail_range)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_detail_percent)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_detail_size)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_constant_detail)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_spacing)->flag |= BRUSH_CHANNEL_INHERIT;
- ADDCH(dyntopo_radius_scale)->flag |= BRUSH_CHANNEL_INHERIT;
+
+ ADDCH(dyntopo_detail_mode);
+ ADDCH(dyntopo_mode)->flag;
+ ADDCH(dyntopo_detail_range);
+ ADDCH(dyntopo_detail_percent);
+ ADDCH(dyntopo_detail_size);
+ ADDCH(dyntopo_constant_detail);
+ ADDCH(dyntopo_spacing);
+ ADDCH(dyntopo_radius_scale);
ADDCH(accumulate);
ADDCH(original_normal);
@@ -807,6 +811,10 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
ADDCH(preserve_faceset_boundary);
ADDCH(hard_edge_mode);
ADDCH(grab_silhouette);
+ ADDCH(height);
+ ADDCH(use_persistent);
+
+ ADDCH(use_space_attenuation);
ADDCH(projection);
ADDCH(boundary_smooth);
@@ -972,6 +980,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
SHOWWRK(surface_smooth_shape_preservation);
SHOWWRK(surface_smooth_current_vertex);
SHOWWRK(surface_smooth_iterations);
+ SHOWWRK(projection);
break;
case SCULPT_TOOL_SCRAPE:
case SCULPT_TOOL_FILL:
@@ -993,6 +1002,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
break;
case SCULPT_TOOL_LAYER:
SHOWWRK(use_persistent);
+ SHOWWRK(height);
break;
case SCULPT_TOOL_CLOTH:
SHOWWRK(cloth_deform_type);
@@ -1006,13 +1016,14 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
SHOWWRK(cloth_constraint_softbody_strength);
SHOWWRK(cloth_use_collision);
SHOWWRK(cloth_pin_simulation_boundary);
+ SHOWWRK(elastic_deform_type);
break;
case SCULPT_TOOL_BOUNDARY:
SHOWWRK(boundary_offset);
SHOWWRK(boundary_deform_type);
SHOWWRK(boundary_falloff_type);
-
+ SHOWWRK(deform_target);
break;
case SCULPT_TOOL_CREASE:
SHOWWRK(crease_pinch_factor);
@@ -1021,6 +1032,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
SHOWWRK(crease_pinch_factor);
SHOWWRK(rake_factor);
SHOWWRK(snake_hook_deform_type);
+ SHOWWRK(elastic_deform_type);
break;
case SCULPT_TOOL_PAINT:
SHOWWRK(color);
@@ -1046,6 +1058,8 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
SHOWWRK(use_pose_lock_rotation);
SHOWWRK(pose_deform_type);
SHOWWRK(pose_origin_type);
+ SHOWWRK(deform_target);
+ SHOWWRK(elastic_deform_type);
break;
}
@@ -1067,6 +1081,15 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
BKE_brush_builtin_patch(brush, tool);
+ GETCH(dyntopo_detail_mode)->flag |= BRUSH_CHANNEL_INHERIT;
+ GETCH(dyntopo_mode)->flag |= BRUSH_CHANNEL_INHERIT;
+ GETCH(dyntopo_detail_range)->flag |= BRUSH_CHANNEL_INHERIT;
+ GETCH(dyntopo_detail_percent)->flag |= BRUSH_CHANNEL_INHERIT;
+ GETCH(dyntopo_detail_size)->flag |= BRUSH_CHANNEL_INHERIT;
+ GETCH(dyntopo_constant_detail)->flag |= B
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list