Index: source/blender/editors/sculpt_paint/paint_ops.c =================================================================== --- source/blender/editors/sculpt_paint/paint_ops.c (revision 45888) +++ source/blender/editors/sculpt_paint/paint_ops.c (working copy) @@ -524,6 +524,9 @@ kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags); + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + set_brush_rc_props(kmi->ptr, paint, "weight", "use_unified_weight", flags); + if (flags & RC_ROTATION) { kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags); Index: source/blender/editors/sculpt_paint/paint_vertex.c =================================================================== --- source/blender/editors/sculpt_paint/paint_vertex.c (revision 45888) +++ source/blender/editors/sculpt_paint/paint_vertex.c (working copy) @@ -2253,10 +2253,13 @@ const float brush_size_pressure = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f); const float brush_alpha_value = brush_alpha(scene, brush); const float brush_alpha_pressure = brush_alpha_value * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f); + const float brush_weight_value = brush_weight(scene, brush); /* intentionally don't initialize as NULL, make sure we initialize all members below */ WeightPaintInfo wpi; + //printf("Using brush_weight_value = %f\n", brush_weight_value); + /* cannot paint if there is no stroke data */ if (wpd == NULL) { /* XXX: force a redraw here, since even though we can't paint, @@ -2348,7 +2351,9 @@ if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) paintweight = 0.0f; else - paintweight = ts->vgroup_weight; + //paintweight = ts->vgroup_weight; /* Original used vgroup weight for brush. This line is no longer used. */ + // paintweight = brush->weight; + paintweight = brush_weight_value; for (index = 0; index < totindex; index++) { if (indexar[index] && indexar[index] <= me->totpoly) { @@ -2408,6 +2413,7 @@ mval, brush_size_pressure, brush_alpha_pressure); if (alpha) { do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight); + //printf("do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight = %f)\n", paintweight); } me->dvert[vidx].flag = 0; } Index: source/blender/blenkernel/BKE_brush.h =================================================================== --- source/blender/blenkernel/BKE_brush.h (revision 45888) +++ source/blender/blenkernel/BKE_brush.h (working copy) @@ -100,6 +100,9 @@ float brush_alpha(const struct Scene *scene, struct Brush *brush); +void brush_set_weight(struct Scene *scene, struct Brush *brush, float weight); +float brush_weight(const Scene *scene, struct Brush *brush); + int brush_use_locked_size(const struct Scene *scene, struct Brush *brush); int brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush); int brush_use_size_pressure(const struct Scene *scene, struct Brush *brush); Index: source/blender/blenkernel/intern/brush.c =================================================================== --- source/blender/blenkernel/intern/brush.c (revision 45888) +++ source/blender/blenkernel/intern/brush.c (working copy) @@ -75,6 +75,7 @@ brush->ob_mode = OB_MODE_ALL_PAINT; /* BRUSH SCULPT TOOL SETTINGS */ + brush->weight= 1.0f; /* weight of brush 0 - 1.0 */ brush->size= 35; /* radius of the brush in pixels */ brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ brush->autosmooth_factor= 0.0f; @@ -710,6 +711,26 @@ return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha; } +void brush_set_weight(struct Scene *scene, struct Brush *brush, float weight) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + + if (ups->flag & UNIFIED_PAINT_WEIGHT) { + //printf("Setting unified weight (ups->weight)=%f\n", weight); + ups->weight= weight; + } else { + //printf("Setting non-unified weight (brush->weight)=%f\n", weight); + brush->weight= weight; + } +} + +float brush_weight(const Scene *scene, Brush *brush) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + + return (ups->flag & UNIFIED_PAINT_WEIGHT) ? ups->weight : brush->weight; +} + /* scale unprojected radius to reflect a change in the brush's 2D size */ void brush_scale_unprojected_radius(float *unprojected_radius, int new_brush_size, @@ -773,8 +794,10 @@ float startalpha; float startjitter; float startspacing; + float startweight; BrushPainterCache cache; + int pad; }; BrushPainter *brush_painter_new(Scene *scene, Brush *brush) @@ -788,6 +811,7 @@ painter->startsize = brush_size(scene, brush); painter->startalpha = brush_alpha(scene, brush); + painter->startweight = brush_weight(scene, brush); painter->startjitter = brush->jitter; painter->startspacing = brush->spacing; @@ -822,6 +846,7 @@ brush_set_size(painter->scene, brush, painter->startsize); brush_set_alpha(painter->scene, brush, painter->startalpha); + brush_set_weight(painter->scene, brush, painter->startweight); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -1220,6 +1245,7 @@ painter->lastmousepos[1]= pos[1]; painter->lastpressure= pressure; + brush_set_weight(scene, brush, painter->startweight); brush_set_alpha(scene, brush, painter->startalpha); brush_set_size(scene, brush, painter->startsize); brush->jitter = painter->startjitter; Index: source/blender/makesdna/DNA_brush_types.h =================================================================== --- source/blender/makesdna/DNA_brush_types.h (revision 45888) +++ source/blender/makesdna/DNA_brush_types.h (working copy) @@ -65,6 +65,7 @@ short blend; /* blend mode */ short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */ + float weight; /* brush weight */ int size; /* brush diameter */ int flag; /* general purpose flag */ float jitter; /* jitter the position of the brush */ @@ -99,6 +100,7 @@ float add_col[3]; float sub_col[3]; + int pad; } Brush; /* Brush.flag */ Index: source/blender/makesdna/DNA_scene_types.h =================================================================== --- source/blender/makesdna/DNA_scene_types.h (revision 45888) +++ source/blender/makesdna/DNA_scene_types.h (working copy) @@ -738,6 +738,8 @@ short step, invert, count; /* for specific brushes only */ int flag; float strength; + float weight; + int pad; } ParticleBrushData; /* Particle Edit Mode Settings */ @@ -841,6 +843,7 @@ * values are used */ typedef struct UnifiedPaintSettings { /* unified radius of brush in pixels */ + float weight; int size; /* unified radius of brush in Blender units */ @@ -851,11 +854,13 @@ /* user preferences for sculpt and paint */ int flag; + int pad; } UnifiedPaintSettings; typedef enum { UNIFIED_PAINT_SIZE = (1<<0), UNIFIED_PAINT_ALPHA = (1<<1), + UNIFIED_PAINT_WEIGHT = (1<<5), /* Can these be reunumbered? */ /* only used if unified size is enabled, mirros the brush flags * BRUSH_LOCK_SIZE and BRUSH_SIZE_PRESSURE */ Index: source/blender/makesrna/intern/rna_sculpt_paint.c =================================================================== --- source/blender/makesrna/intern/rna_sculpt_paint.c (revision 45888) +++ source/blender/makesrna/intern/rna_sculpt_paint.c (working copy) @@ -328,6 +328,13 @@ prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_ONLYVGROUP); RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to verts already apart of the vertex group"); + + /* Used for brush-specific weights. */ + /* Or maybe not used. Remove? + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.001, 1.0); + RNA_def_property_ui_text(prop, "Weight", "Brush weight"); + */ } static void rna_def_image_paint(BlenderRNA *brna) @@ -524,6 +531,13 @@ RNA_def_property_range(prop, 0.001, 1.0); RNA_def_property_ui_text(prop, "Strength", "Brush strength"); + /* New weight unused with Particle brush. Remove this section. */ + /* + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.001, 1.0); + RNA_def_property_ui_text(prop, "Weight", "Brush weight"); + */ + prop = RNA_def_property(srna, "count", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 1000); RNA_def_property_ui_range(prop, 1, 100, 10, 3); Index: source/blender/makesrna/intern/rna_scene.c =================================================================== --- source/blender/makesrna/intern/rna_scene.c (revision 45888) +++ source/blender/makesrna/intern/rna_scene.c (working copy) @@ -1362,6 +1362,18 @@ } } +/* Unused. Remove */ +/* static void rna_UnifiedPaintSettings_weight_set(PointerRNA *ptr, float value) +{ + UnifiedPaintSettings* ups = ptr->data; + + /* scale unprojected radius so it stays consistent with brush weight */ /* + brush_scale_unprojected_radius(&ups->unprojected_radius, + value, ups->weight); + ups->weight = value; +} +*/ + static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value) { UnifiedPaintSettings* ups = ptr->data; @@ -1779,6 +1791,11 @@ RNA_def_property_ui_text(prop, "Use Unified Strength", "Instead of per-brush strength, the strength is shared across brushes"); + prop = RNA_def_property(srna, "use_unified_weight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_WEIGHT); + RNA_def_property_ui_text(prop, "Use Unified weight", + "Instead of per-brush weight, the weight is shared across brushes"); + /* unified paint settings that override the equivalent settings * from the active brush */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); @@ -1800,6 +1817,13 @@ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied"); + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); + RNA_def_property_ui_text(prop, "Weight", "Weight to assign in vertex groups"); + prop = RNA_def_property(srna, "use_pressure_size", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_SIZE_PRESSURE); RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); Index: source/blender/makesrna/intern/rna_brush.c =================================================================== --- source/blender/makesrna/intern/rna_brush.c (revision 45888) +++ source/blender/makesrna/intern/rna_brush.c (working copy) @@ -216,6 +216,12 @@ return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); } +static int rna_SculptCapabilities_has_weight_get(PointerRNA *ptr) +{ + Brush *br = (Brush*)ptr->data; + return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); +} + static PointerRNA rna_Brush_sculpt_capabilities_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_SculptCapabilities, ptr->id.data); @@ -428,6 +434,7 @@ BRUSH_CAPABILITY(has_space_attenuation, "Has Space Attenuation"); BRUSH_CAPABILITY(has_spacing, "Has Spacing"); BRUSH_CAPABILITY(has_strength, "Has Strength"); + BRUSH_CAPABILITY(has_weight, "Has Weight"); #undef SCULPT_CAPABILITY } @@ -583,6 +590,14 @@ RNA_def_property_ui_text(prop, "Color", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); + RNA_def_property_ui_text(prop, "Weight", "Vertex weight when brush is applied"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "alpha"); RNA_def_property_float_default(prop, 0.5f); Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (revision 45888) +++ source/blender/blenloader/intern/readfile.c (working copy) @@ -12116,6 +12116,10 @@ if (brush->unprojected_radius == 0) brush->unprojected_radius = 0.125f; + // Weight of 0 might be okay, if not, set this to some positive float <= 1.0. + // if (brush->weight == 0) + // brush->weight = 0.0; + // unusable size if (brush->size == 0) brush->size = 35; @@ -13129,6 +13133,7 @@ ups->size= ts->sculpt_paint_unified_size; ups->unprojected_radius= ts->sculpt_paint_unified_unprojected_radius; ups->alpha= ts->sculpt_paint_unified_alpha; + /* ups->weight= ts->sculpt_paint_unified_weight; Weight didn't exist before deprecation */ ups->flag= ts->sculpt_paint_settings; } } Index: release/scripts/startup/bl_ui/properties_paint_common.py =================================================================== --- release/scripts/startup/bl_ui/properties_paint_common.py (revision 45888) +++ release/scripts/startup/bl_ui/properties_paint_common.py (working copy) @@ -47,6 +47,8 @@ parent.label(text="Unified Settings:") parent.prop(ups, "use_unified_size", text="Size") parent.prop(ups, "use_unified_strength", text="Strength") + if context.weight_paint_object: + parent.prop(ups, "use_unified_weight", text="Weight") @staticmethod def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False): @@ -59,3 +61,9 @@ ups = context.tool_settings.unified_paint_settings ptr = ups if ups.use_unified_strength else brush parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider) + + @staticmethod + def prop_unified_weight(parent, context, brush, prop_name, icon='NONE', text="", slider=False): + ups = context.tool_settings.unified_paint_settings + ptr = ups if ups.use_unified_weight else brush + parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider) Index: release/scripts/startup/bl_ui/space_image.py =================================================================== --- release/scripts/startup/bl_ui/space_image.py (revision 45888) +++ release/scripts/startup/bl_ui/space_image.py (working copy) @@ -671,6 +671,9 @@ col.template_color_wheel(brush, "color", value_slider=True) col.prop(brush, "color", text="") + # Unused: row = col.row(align=True) + # Unused: self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight") + row = col.row(align=True) self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") self.prop_unified_size(row, context, brush, "use_pressure_size") @@ -820,6 +823,9 @@ if brush: col = layout.column() + # Unused: row = col.row(align=True) + # Unused: self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight") + row = col.row(align=True) self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") self.prop_unified_size(row, context, brush, "use_pressure_size") Index: release/scripts/startup/bl_ui/space_view3d_toolbar.py =================================================================== --- release/scripts/startup/bl_ui/space_view3d_toolbar.py (revision 45888) +++ release/scripts/startup/bl_ui/space_view3d_toolbar.py (working copy) @@ -652,13 +652,18 @@ # Weight Paint Mode # elif context.weight_paint_object and brush: - layout.prop(toolsettings, "vertex_group_weight", text="Weight", slider=True) + # T->Weight moved to a per-brush setting (below) + layout.prop(toolsettings, "vertex_group_weight", text="Vertex Group Weight", slider=True) + layout.prop(toolsettings, "use_auto_normalize", text="Auto Normalize") layout.prop(toolsettings, "use_multipaint", text="Multi-Paint") col = layout.column() row = col.row(align=True) + self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight") + + row = col.row(align=True) self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") self.prop_unified_size(row, context, brush, "use_pressure_size")