[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43387] trunk/blender: Fix all remaining unified paint settings uses of current Scene.

Nicholas Bishop nicholasbishop at gmail.com
Sun Jan 15 00:54:59 CET 2012


Revision: 43387
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43387
Author:   nicholasbishop
Date:     2012-01-14 23:54:51 +0000 (Sat, 14 Jan 2012)
Log Message:
-----------
Fix all remaining unified paint settings uses of current Scene.

Things like brush size and strength accessors now take a scene
parameter rather than guessing about which Scene's unified paint
settings to use.

Setting the size/strength through RNA can now be done separately for
the brush or the UnifiedPaintSettings.

The UI python code required updating to check whether the
size/strength controls should use brush or UnifiedPaintSettings RNA.

Radial control also required some updates to switch between the two
RNA sources.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    trunk/blender/source/blender/blenkernel/BKE_brush.h
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/editors/physics/physics_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/makesrna/intern/rna_brush.c
    trunk/blender/source/blender/makesrna/intern/rna_scene.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-01-14 22:59:51 UTC (rev 43386)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-01-14 23:54:51 UTC (rev 43387)
@@ -476,16 +476,16 @@
         parent.prop(ups, "use_unified_strength", text="Strength")
 
     @staticmethod
-    def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text=""):
+    def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
         ups = context.tool_settings.unified_paint_settings
         ptr = ups if ups.use_unified_size else brush
-        parent.prop(ptr, prop_name, icon=icon, text=text)
+        parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
 
     @staticmethod
-    def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text=""):
+    def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
         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)
+        parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
 
 class VIEW3D_PT_tools_brush(PaintPanel, Panel):
     bl_label = "Brush"
@@ -545,10 +545,10 @@
             if ((ups.use_unified_size and ups.use_locked_size) or
                 ((not ups.use_unified_size) and brush.use_locked_size)):
                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
-                row.prop(brush, "unprojected_radius", text="Radius", slider=True)
+                self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
             else:
                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
-                row.prop(brush, "size", slider=True)
+                self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
 
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
@@ -563,12 +563,12 @@
                     else:
                         row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED')
 
-                row.prop(brush, "strength", text="Strength", slider=True)
+                self.prop_unified_strength(row, context, brush, "strength")
                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             if tool == 'ROTATE':
                 row = col.row(align=True)
-                row.prop(brush, "strength", text="Strength", slider=True)
+                self.prop_unified_strength(row, context, brush, "strength")
                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             if tool != 'SMOOTH':
@@ -656,11 +656,11 @@
             col.prop(brush, "color", text="")
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", text="Strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "strength")
             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             row = col.row(align=True)
@@ -682,11 +682,11 @@
             col = layout.column()
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", text="Strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "strength")
             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             row = col.row(align=True)
@@ -700,11 +700,11 @@
             col.prop(brush, "color", text="")
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", text="Strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "strength")
             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             # XXX - TODO

Modified: trunk/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_brush.h	2012-01-14 22:59:51 UTC (rev 43386)
+++ trunk/blender/source/blender/blenkernel/BKE_brush.h	2012-01-14 23:54:51 UTC (rev 43387)
@@ -59,7 +59,8 @@
 int brush_clone_image_delete(struct Brush *brush);
 
 /* jitter */
-void brush_jitter_pos(struct Brush *brush, float *pos, float *jitterpos);
+void brush_jitter_pos(const struct Scene *scene, struct Brush *brush,
+					  float *pos, float *jitterpos);
 
 /* brush curve */
 void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset);
@@ -67,8 +68,8 @@
 float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
 
 /* sampling */
-void brush_sample_tex(struct Brush *brush, const float xy[2], float rgba[4], const int thread);
-void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
+void brush_sample_tex(const struct Scene *scene, struct Brush *brush, const float xy[2], float rgba[4], const int thread);
+void brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size,
 	struct ImBuf **imbuf, int use_color_correction);
 
 /* painting */
@@ -92,18 +93,27 @@
 
 /* unified strength and size */
 
-int  brush_size(struct Brush *brush);
-void brush_set_size(struct Brush *brush, int value);
+int  brush_size(const struct Scene *scene, struct Brush *brush);
+void brush_set_size(struct Scene *scene, struct Brush *brush, int value);
 
+float brush_unprojected_radius(const struct Scene *scene, struct Brush *brush);
+void  brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, float value);
+
+float brush_alpha(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_size_pressure(const struct Scene *scene, struct Brush *brush);
 
-float brush_unprojected_radius(struct Brush *brush);
-void  brush_set_unprojected_radius(struct Brush *brush, float value);
+/* 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,
+									int old_brush_size);
 
-float brush_alpha(struct Brush *brush);
-void  brush_set_alpha(struct Brush *brush, float value);
+/* scale brush size to reflect a change in the brush's unprojected radius */
+void brush_scale_size(int *brush_size,
+					  float new_unprojected_radius,
+					  float old_unprojected_radius);
 
 /* debugging only */
 void brush_debug_print_state(struct Brush *br);

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c	2012-01-14 22:59:51 UTC (rev 43386)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c	2012-01-14 23:54:51 UTC (rev 43387)
@@ -487,14 +487,14 @@
 }
 
 /* Brush Sampling */
-void brush_sample_tex(Brush *brush, const float xy[2], float rgba[4], const int thread)
+void brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread)
 {
 	MTex *mtex= &brush->mtex;
 
 	if (mtex && mtex->tex) {
 		float co[3], tin, tr, tg, tb, ta;
 		int hasrgb;
-		const int radius= brush_size(brush);
+		const int radius= brush_size(scene, brush);
 
 		co[0]= xy[0]/radius;
 		co[1]= xy[1]/radius;
@@ -521,14 +521,14 @@
 }
 
 /* TODO, use define for 'texfall' arg */
-void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction)
+void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction)
 {
 	ImBuf *ibuf;
 	float xy[2], rgba[4], *dstf;
 	int x, y, rowbytes, xoff, yoff, imbflag;
-	const int radius= brush_size(brush);
+	const int radius= brush_size(scene, brush);
 	char *dst, crgb[3];
-	const float alpha= brush_alpha(brush);
+	const float alpha= brush_alpha(scene, brush);
 	float brush_rgb[3];
     
 	imbflag= (flt)? IB_rectfloat: IB_rect;
@@ -559,10 +559,10 @@
 					dstf[3]= alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius);
 				}
 				else if (texfall == 1) {
-					brush_sample_tex(brush, xy, dstf, 0);
+					brush_sample_tex(scene, brush, xy, dstf, 0);
 				}
 				else {
-					brush_sample_tex(brush, xy, rgba, 0);
+					brush_sample_tex(scene, brush, xy, rgba, 0);
 					mul_v3_v3v3(dstf, rgba, brush_rgb);
 					dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius);
 				}
@@ -589,14 +589,14 @@
 					dst[3] = FTOCHAR(alpha_f);
 				}
 				else if (texfall == 1) {
-					brush_sample_tex(brush, xy, rgba, 0);
+					brush_sample_tex(scene, brush, xy, rgba, 0);
 					dst[0] = FTOCHAR(rgba[0]);
 					dst[1] = FTOCHAR(rgba[1]);
 					dst[2] = FTOCHAR(rgba[2]);
 					dst[3] = FTOCHAR(rgba[3]);
 				}
 				else if (texfall == 2) {
-					brush_sample_tex(brush, xy, rgba, 0);
+					brush_sample_tex(scene, brush, xy, rgba, 0);
 					mul_v3_v3(rgba, brush->rgb);
 					alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius);
 
@@ -606,7 +606,7 @@
 					dst[3] = FTOCHAR(alpha_f);
 				}
 				else {
-					brush_sample_tex(brush, xy, rgba, 0);
+					brush_sample_tex(scene, brush, xy, rgba, 0);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list