[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46090] trunk/blender: Add per-brush weight field.
Nicholas Bishop
nicholasbishop at gmail.com
Sun Apr 29 22:04:26 CEST 2012
Revision: 46090
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46090
Author: nicholasbishop
Date: 2012-04-29 20:04:25 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
trunk/blender/source/blender/blenkernel/BKE_blender.h
trunk/blender/source/blender/blenkernel/BKE_brush.h
trunk/blender/source/blender/blenkernel/intern/brush.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
trunk/blender/source/blender/makesdna/DNA_brush_types.h
trunk/blender/source/blender/makesdna/DNA_scene_types.h
trunk/blender/source/blender/makesrna/intern/rna_brush.c
trunk/blender/source/blender/makesrna/intern/rna_scene.c
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py 2012-04-29 20:04:25 UTC (rev 46090)
@@ -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)
Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2012-04-29 20:04:25 UTC (rev 46090)
@@ -652,13 +652,15 @@
# Weight Paint Mode #
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_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")
Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h 2012-04-29 20:04:25 UTC (rev 46090)
@@ -42,7 +42,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 263
-#define BLENDER_SUBVERSION 0
+#define BLENDER_SUBVERSION 1
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
Modified: trunk/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_brush.h 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/blenkernel/BKE_brush.h 2012-04-29 20:04:25 UTC (rev 46090)
@@ -99,6 +99,7 @@
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_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);
Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c 2012-04-29 20:04:25 UTC (rev 46090)
@@ -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,13 @@
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 */
void brush_scale_unprojected_radius(float *unprojected_radius,
int new_brush_size,
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2012-04-29 20:04:25 UTC (rev 46090)
@@ -13261,6 +13261,27 @@
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 2!: Userdef struct init has to be in editors/interface/resources.c! */
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c 2012-04-29 20:04:25 UTC (rev 46090)
@@ -530,6 +530,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", WKEY, 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);
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2012-04-29 20:04:25 UTC (rev 46090)
@@ -2348,7 +2348,7 @@
if (brush->vertexpaint_tool == PAINT_BLEND_BLUR)
paintweight = 0.0f;
else
- paintweight = ts->vgroup_weight;
+ paintweight = brush_weight(scene, brush);
for (index = 0; index < totindex; index++) {
if (indexar[index] && indexar[index] <= me->totpoly) {
Modified: trunk/blender/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_brush_types.h 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/makesdna/DNA_brush_types.h 2012-04-29 20:04:25 UTC (rev 46090)
@@ -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 */
@@ -83,7 +84,7 @@
char sculpt_tool; /* active sculpt tool */
char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */
char imagepaint_tool; /* active image paint tool */
- char pad3[5];
+ char pad;
float autosmooth_factor;
Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h 2012-04-29 20:04:25 UTC (rev 46090)
@@ -851,13 +851,18 @@
/* unified strength of brush */
float alpha;
+ /* unified brush weight, [0, 1] */
+ float weight;
+
/* 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),
/* only used if unified size is enabled, mirros the brush flags
* BRUSH_LOCK_SIZE and BRUSH_SIZE_PRESSURE */
@@ -878,7 +883,8 @@
Sculpt *sculpt;
UvSculpt *uvsculpt; /* uv smooth */
- /* Vertex groups */
+ /* Vertex group weight - used only for editmode, not weight
+ paint */
float vgroup_weight;
/* Subdivide Settings */
Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_brush.c 2012-04-29 20:04:12 UTC (rev 46089)
+++ trunk/blender/source/blender/makesrna/intern/rna_brush.c 2012-04-29 20:04:25 UTC (rev 46090)
@@ -583,6 +583,13 @@
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_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);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list