forked from bartvdbraak/blender
Add per-brush weight field.
Patch from Jaggz H, thanks! [#31096] Weight-painting: Brush-specific weights http://projects.blender.org/tracker/?func=detail&atid=127&aid=31096&group_id=9 Each brush's weight can now be set individually, can also enable unified setting (same as size and strength have.) Added readfile code to the patch: subversion bumped to 1, brushes get default weight of 0.5, unified weight enabled by default and value from old vgroup_weight field.
This commit is contained in:
parent
44d81faa43
commit
f7ec94cbc6
@ -47,6 +47,8 @@ class UnifiedPaintPanel():
|
|||||||
parent.label(text="Unified Settings:")
|
parent.label(text="Unified Settings:")
|
||||||
parent.prop(ups, "use_unified_size", text="Size")
|
parent.prop(ups, "use_unified_size", text="Size")
|
||||||
parent.prop(ups, "use_unified_strength", text="Strength")
|
parent.prop(ups, "use_unified_strength", text="Strength")
|
||||||
|
if context.weight_paint_object:
|
||||||
|
parent.prop(ups, "use_unified_weight", text="Weight")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
||||||
@ -59,3 +61,9 @@ class UnifiedPaintPanel():
|
|||||||
ups = context.tool_settings.unified_paint_settings
|
ups = context.tool_settings.unified_paint_settings
|
||||||
ptr = ups if ups.use_unified_strength else brush
|
ptr = ups if ups.use_unified_strength else brush
|
||||||
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
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)
|
||||||
|
@ -652,12 +652,14 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
|
|||||||
|
|
||||||
# Weight Paint Mode #
|
# Weight Paint Mode #
|
||||||
elif context.weight_paint_object and brush:
|
elif context.weight_paint_object and brush:
|
||||||
layout.prop(toolsettings, "vertex_group_weight", text="Weight", slider=True)
|
|
||||||
layout.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
|
layout.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
|
||||||
layout.prop(toolsettings, "use_multipaint", text="Multi-Paint")
|
layout.prop(toolsettings, "use_multipaint", text="Multi-Paint")
|
||||||
|
|
||||||
col = layout.column()
|
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)
|
row = col.row(align=True)
|
||||||
self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
|
self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
|
||||||
self.prop_unified_size(row, context, brush, "use_pressure_size")
|
self.prop_unified_size(row, context, brush, "use_pressure_size")
|
||||||
|
@ -42,7 +42,7 @@ extern "C" {
|
|||||||
* and keep comment above the defines.
|
* and keep comment above the defines.
|
||||||
* Use STRINGIFY() rather than defining with quotes */
|
* Use STRINGIFY() rather than defining with quotes */
|
||||||
#define BLENDER_VERSION 263
|
#define BLENDER_VERSION 263
|
||||||
#define BLENDER_SUBVERSION 0
|
#define BLENDER_SUBVERSION 1
|
||||||
|
|
||||||
#define BLENDER_MINVERSION 250
|
#define BLENDER_MINVERSION 250
|
||||||
#define BLENDER_MINSUBVERSION 0
|
#define BLENDER_MINSUBVERSION 0
|
||||||
|
@ -99,6 +99,7 @@ float brush_unprojected_radius(const struct Scene *scene, struct Brush *brush);
|
|||||||
void brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, float value);
|
void brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, float value);
|
||||||
|
|
||||||
float brush_alpha(const struct Scene *scene, struct Brush *brush);
|
float brush_alpha(const struct Scene *scene, struct Brush *brush);
|
||||||
|
float brush_weight(const Scene *scene, struct Brush *brush);
|
||||||
|
|
||||||
int brush_use_locked_size(const struct 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_alpha_pressure(const struct Scene *scene, struct Brush *brush);
|
||||||
|
@ -75,6 +75,7 @@ static void brush_set_defaults(Brush *brush)
|
|||||||
brush->ob_mode = OB_MODE_ALL_PAINT;
|
brush->ob_mode = OB_MODE_ALL_PAINT;
|
||||||
|
|
||||||
/* BRUSH SCULPT TOOL SETTINGS */
|
/* BRUSH SCULPT TOOL SETTINGS */
|
||||||
|
brush->weight= 1.0f; /* weight of brush 0 - 1.0 */
|
||||||
brush->size= 35; /* radius of the brush in pixels */
|
brush->size= 35; /* radius of the brush in pixels */
|
||||||
brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */
|
brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */
|
||||||
brush->autosmooth_factor= 0.0f;
|
brush->autosmooth_factor= 0.0f;
|
||||||
@ -710,6 +711,13 @@ float brush_alpha(const Scene *scene, Brush *brush)
|
|||||||
return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha;
|
return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
/* scale unprojected radius to reflect a change in the brush's 2D size */
|
||||||
void brush_scale_unprojected_radius(float *unprojected_radius,
|
void brush_scale_unprojected_radius(float *unprojected_radius,
|
||||||
int new_brush_size,
|
int new_brush_size,
|
||||||
|
@ -13261,6 +13261,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
|||||||
part->flag |= PART_ROTATIONS;
|
part->flag |= PART_ROTATIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (main->versionfile <= 263 && main->subversionfile == 0) {
|
||||||
|
Scene *scene;
|
||||||
|
Brush *brush;
|
||||||
|
|
||||||
|
/* For weight paint, each brush now gets its own weight;
|
||||||
|
unified paint settings also have weight. Update unified
|
||||||
|
paint settings and brushes with a default weight value. */
|
||||||
|
|
||||||
|
for (scene = main->scene.first; scene; scene = scene->id.next) {
|
||||||
|
ToolSettings *ts = scene->toolsettings;
|
||||||
|
if (ts) {
|
||||||
|
ts->unified_paint_settings.weight = ts->vgroup_weight;
|
||||||
|
ts->unified_paint_settings.flag |= UNIFIED_PAINT_WEIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (brush = main->brush.first; brush; brush = brush->id.next) {
|
||||||
|
brush->weight = 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
|
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
|
||||||
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
|
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
|
||||||
|
|
||||||
|
@ -530,6 +530,9 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
|
|||||||
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
|
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);
|
set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags);
|
||||||
|
|
||||||
|
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", WKEY, KM_PRESS, 0, 0);
|
||||||
|
set_brush_rc_props(kmi->ptr, paint, "weight", "use_unified_weight", flags);
|
||||||
|
|
||||||
if (flags & RC_ROTATION) {
|
if (flags & RC_ROTATION) {
|
||||||
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
|
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);
|
set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags);
|
||||||
|
@ -2348,7 +2348,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
|
|||||||
if (brush->vertexpaint_tool == PAINT_BLEND_BLUR)
|
if (brush->vertexpaint_tool == PAINT_BLEND_BLUR)
|
||||||
paintweight = 0.0f;
|
paintweight = 0.0f;
|
||||||
else
|
else
|
||||||
paintweight = ts->vgroup_weight;
|
paintweight = brush_weight(scene, brush);
|
||||||
|
|
||||||
for (index = 0; index < totindex; index++) {
|
for (index = 0; index < totindex; index++) {
|
||||||
if (indexar[index] && indexar[index] <= me->totpoly) {
|
if (indexar[index] && indexar[index] <= me->totpoly) {
|
||||||
|
@ -65,6 +65,7 @@ typedef struct Brush {
|
|||||||
|
|
||||||
short blend; /* blend mode */
|
short blend; /* blend mode */
|
||||||
short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */
|
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 size; /* brush diameter */
|
||||||
int flag; /* general purpose flag */
|
int flag; /* general purpose flag */
|
||||||
float jitter; /* jitter the position of the brush */
|
float jitter; /* jitter the position of the brush */
|
||||||
@ -83,7 +84,7 @@ typedef struct Brush {
|
|||||||
char sculpt_tool; /* active sculpt tool */
|
char sculpt_tool; /* active sculpt tool */
|
||||||
char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */
|
char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */
|
||||||
char imagepaint_tool; /* active image paint tool */
|
char imagepaint_tool; /* active image paint tool */
|
||||||
char pad3[5];
|
char pad;
|
||||||
|
|
||||||
float autosmooth_factor;
|
float autosmooth_factor;
|
||||||
|
|
||||||
|
@ -851,13 +851,18 @@ typedef struct UnifiedPaintSettings {
|
|||||||
/* unified strength of brush */
|
/* unified strength of brush */
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
||||||
|
/* unified brush weight, [0, 1] */
|
||||||
|
float weight;
|
||||||
|
|
||||||
/* user preferences for sculpt and paint */
|
/* user preferences for sculpt and paint */
|
||||||
int flag;
|
int flag;
|
||||||
|
int pad;
|
||||||
} UnifiedPaintSettings;
|
} UnifiedPaintSettings;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UNIFIED_PAINT_SIZE = (1<<0),
|
UNIFIED_PAINT_SIZE = (1<<0),
|
||||||
UNIFIED_PAINT_ALPHA = (1<<1),
|
UNIFIED_PAINT_ALPHA = (1<<1),
|
||||||
|
UNIFIED_PAINT_WEIGHT = (1<<5),
|
||||||
|
|
||||||
/* only used if unified size is enabled, mirros the brush flags
|
/* only used if unified size is enabled, mirros the brush flags
|
||||||
* BRUSH_LOCK_SIZE and BRUSH_SIZE_PRESSURE */
|
* BRUSH_LOCK_SIZE and BRUSH_SIZE_PRESSURE */
|
||||||
@ -878,7 +883,8 @@ typedef struct ToolSettings {
|
|||||||
Sculpt *sculpt;
|
Sculpt *sculpt;
|
||||||
UvSculpt *uvsculpt; /* uv smooth */
|
UvSculpt *uvsculpt; /* uv smooth */
|
||||||
|
|
||||||
/* Vertex groups */
|
/* Vertex group weight - used only for editmode, not weight
|
||||||
|
paint */
|
||||||
float vgroup_weight;
|
float vgroup_weight;
|
||||||
|
|
||||||
/* Subdivide Settings */
|
/* Subdivide Settings */
|
||||||
|
@ -583,6 +583,13 @@ static void rna_def_brush(BlenderRNA *brna)
|
|||||||
RNA_def_property_ui_text(prop, "Color", "");
|
RNA_def_property_ui_text(prop, "Color", "");
|
||||||
RNA_def_property_update(prop, 0, "rna_Brush_update");
|
RNA_def_property_update(prop, 0, "rna_Brush_update");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
|
||||||
|
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);
|
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
|
||||||
RNA_def_property_float_sdna(prop, NULL, "alpha");
|
RNA_def_property_float_sdna(prop, NULL, "alpha");
|
||||||
RNA_def_property_float_default(prop, 0.5f);
|
RNA_def_property_float_default(prop, 0.5f);
|
||||||
|
@ -1779,6 +1779,11 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
|
|||||||
RNA_def_property_ui_text(prop, "Use Unified Strength",
|
RNA_def_property_ui_text(prop, "Use Unified Strength",
|
||||||
"Instead of per-brush strength, the strength is shared across brushes");
|
"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
|
/* unified paint settings that override the equivalent settings
|
||||||
* from the active brush */
|
* from the active brush */
|
||||||
prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
|
prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
|
||||||
@ -1800,6 +1805,13 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
|
|||||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
|
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");
|
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);
|
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_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_SIZE_PRESSURE);
|
||||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user