[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30138] branches/soc-2010-jwilkins: == Unified Size and Strength Option ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Fri Jul 9 07:04:54 CEST 2010


Revision: 30138
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30138
Author:   jwilkins
Date:     2010-07-09 07:04:52 +0200 (Fri, 09 Jul 2010)

Log Message:
-----------
== Unified Size and Strength Option ==

Under brush options can choose to use the same strength and/or the same brush size across all brushes.

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_userpref.py
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_brush.h
    branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
    branches/soc-2010-jwilkins/source/blender/editors/interface/resources.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/makesdna/DNA_userdef_types.h
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_userdef.c

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_userpref.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_userpref.py	2010-07-09 04:47:07 UTC (rev 30137)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_userpref.py	2010-07-09 05:04:52 UTC (rev 30138)
@@ -338,9 +338,8 @@
         sculpt = context.tool_settings.sculpt
         col = row.column()
         col.label(text="Paint and Sculpt:")
-        col.prop(edit, "use_unified_radius_and_strength", text="Unified Size and Strength")
-        col.prop(edit, "sculpt_paint_pixel_radius", text="Unified Pixel Radius")
-        col.prop(edit, "sculpt_paint_strength", text="Unified Strength")
+        col.prop(edit, "sculpt_paint_use_unified_size", text="Unify Size")
+        col.prop(edit, "sculpt_paint_use_unified_alpha", text="Unify Strength")
         col.prop(sculpt, "use_openmp", text="Threaded Sculpt")
         col.prop(sculpt, "fast_navigate")
         col.prop(sculpt, "show_brush")

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-07-09 04:47:07 UTC (rev 30137)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-07-09 05:04:52 UTC (rev 30138)
@@ -553,35 +553,32 @@
             col = layout.column()
 
 
-
             col.separator()
 
             row = col.row(align=True)
 
-            if brush.lock_brush_size:
-                row.prop(brush, "lock_brush_size", toggle=True, text="", icon='LOCKED')
-            else:
-                row.prop(brush, "lock_brush_size", toggle=True, text="", icon='UNLOCKED')
+            if edit.sculpt_paint_use_unified_size:
+                if edit.sculpt_paint_unified_lock_brush_size:
+                    row.prop(edit, "sculpt_paint_unified_lock_brush_size", toggle=True, text="", icon='LOCKED')
+                    row.prop(edit, "sculpt_paint_unified_unprojected_radius", text="Unified Radius", slider=True)
+                else:
+                    row.prop(edit, "sculpt_paint_unified_lock_brush_size", toggle=True, text="", icon='UNLOCKED')
+                    row.prop(edit, "sculpt_paint_unified_size", text="Unified Radius", slider=True)
 
-            if brush.lock_brush_size:
-                row.prop(brush, "unprojected_radius", text="Radius", slider=True)
             else:
-                if bpy.context.user_preferences.edit.use_unified_radius_and_strength:
-                    row.prop(edit, "sculpt_paint_pixel_radius", text="Radius", slider=True)
+                if brush.lock_brush_size:
+                    row.prop(brush, "lock_brush_size", toggle=True, text="", icon='LOCKED')
+                    row.prop(brush, "unprojected_radius", text="Radius", slider=True)
                 else:
+                    row.prop(brush, "lock_brush_size", toggle=True, text="", icon='UNLOCKED')
                     row.prop(brush, "size", text="Radius", slider=True)
 
             row.prop(brush, "use_size_pressure", toggle=True, text="")
 
 
-
             if brush.sculpt_tool not in ('SNAKE_HOOK', 'GRAB', 'ROTATE'):
                 col.separator()
 
-                #row = col.row(align=True)
-                #row.prop(edit, "use_unified_radius_and_strength")
-
-
                 row = col.row(align=True)
 
                 if brush.use_space and brush.sculpt_tool not in ('SMOOTH'):
@@ -590,10 +587,10 @@
                     else:
                         row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED')
 
-                if edit.use_unified_radius_and_strength:
-                    row.prop(edit, "sculpt_paint_strength", slider=True)
+                if edit.sculpt_paint_use_unified_strength:
+                    row.prop(edit, "sculpt_paint_unified_strength", text="Unified Strength", slider=True)
                 else:
-                    row.prop(brush, "strength", slider=True)
+                    row.prop(brush, "strength", text="Strength", slider=True)
 
                 row.prop(brush, "use_strength_pressure", text="")
 
@@ -958,7 +955,7 @@
 
             row = col.row()
             row.active = brush.use_space
-            row.prop(brush, "spacing", text="Spacing", slider=True)
+            row.prop(brush, "spacing", text="Spacing")
 
             #col.prop(brush, "use_space_atten", text="Adaptive Strength")
             #col.prop(brush, "use_adaptive_space", text="Adaptive Spacing")
@@ -1007,11 +1004,15 @@
         settings = self.paint_settings(context)
         brush = settings.brush
 
-        col = layout.column();
+        col = layout.column()
 
-        #edit = context.user_preferences.edit
-        #col.prop(edit, "use_unified_radius_and_strength", text="Unified Size and Strength")
+        edit = context.user_preferences.edit
+        col.label(text="Unified Settings:")
+        col.prop(edit, "sculpt_paint_use_unified_size", text="Size")
+        col.prop(edit, "sculpt_paint_use_unified_strength", text="Strength")
 
+        col.separator()
+
         split = self.layout.split()
 
         col = split.column()

Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_brush.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_brush.h	2010-07-09 04:47:07 UTC (rev 30137)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_brush.h	2010-07-09 05:04:52 UTC (rev 30138)
@@ -84,5 +84,15 @@
 void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br, float size_weight);
 int brush_radial_control_exec(struct wmOperator *op, struct Brush *br, float size_weight);
 
+/* unified strength and size */
+int sculpt_get_brush_size(struct Brush *brush);
+void sculpt_set_brush_size(struct Brush *brush, int size);
+int sculpt_get_lock_brush_size(struct Brush *brush);
+float sculpt_get_brush_unprojected_radius(struct Brush *brush);
+void sculpt_set_brush_unprojected_radius(struct Brush *brush, float unprojected_radius);
+float sculpt_get_brush_alpha(struct Brush *brush);
+void sculpt_set_brush_alpha(struct Brush *brush, float alpha);
+
+
 #endif
 

Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c	2010-07-09 04:47:07 UTC (rev 30137)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c	2010-07-09 05:04:52 UTC (rev 30138)
@@ -55,8 +55,6 @@
 #include "BKE_texture.h"
 #include "BKE_icons.h"
 
-
-
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
@@ -1054,14 +1052,15 @@
 	const float conv = 0.017453293;
 
 	if(mode == WM_RADIALCONTROL_SIZE)
-		if (br->flag & BRUSH_LOCK_SIZE) {
+		if (sculpt_get_lock_brush_size(br)) {
 			float initial_value = RNA_float_get(op->ptr, "initial_value");
-			br->unprojected_radius *= new_value/initial_value * size_weight;
+			const float unprojected_radius = sculpt_get_brush_unprojected_radius(br);
+			sculpt_set_brush_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight);
 		}
 		else
-			br->size = new_value * size_weight;
+			sculpt_set_brush_size(br, new_value * size_weight);
 	else if(mode == WM_RADIALCONTROL_STRENGTH)
-		br->alpha = new_value;
+		sculpt_set_brush_alpha(br, new_value);
 	else if(mode == WM_RADIALCONTROL_ANGLE) {
 		MTex *mtex = brush_active_texture(br);
 		if(mtex)

Modified: branches/soc-2010-jwilkins/source/blender/editors/interface/resources.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/interface/resources.c	2010-07-09 04:47:07 UTC (rev 30137)
+++ branches/soc-2010-jwilkins/source/blender/editors/interface/resources.c	2010-07-09 05:04:52 UTC (rev 30138)
@@ -1521,6 +1521,16 @@
 	/* this timer uses U */
 // XXX	reset_autosave();
 
+	/*  Sculpt Paint Unified Settings */
+
+	if (U.sculpt_paint_unified_alpha == 0)
+		U.sculpt_paint_unified_alpha = 0.5f;
+
+	if (U.sculpt_paint_unified_unprojected_radius == 0) 
+		U.sculpt_paint_unified_unprojected_radius = 0.125f; // same as for brush do_version
+
+	if (U.sculpt_paint_unified_size == 0)
+		U.sculpt_paint_unified_size = 25;
 }
 
 

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-07-09 04:47:07 UTC (rev 30137)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-07-09 05:04:52 UTC (rev 30138)
@@ -222,7 +222,7 @@
 		mtex->size[1] == snap->size[1] &&
 		mtex->size[2] == snap->size[2] &&
 		mtex->rot == snap->rot &&
-		brush->size <= snap->brush_size && // make brush smaller shouldn't cause a resample
+		sculpt_get_brush_size(brush) <= snap->brush_size && // make brush smaller shouldn't cause a resample
 		vc->ar->winx == snap->winx &&
 		vc->ar->winy == snap->winy &&
 		mtex->brush_map_mode == snap->brush_map_mode;
@@ -233,7 +233,7 @@
 	copy_v3_v3(snap->ofs, brush->mtex.ofs);
 	copy_v3_v3(snap->size, brush->mtex.size);
 	snap->rot = brush->mtex.rot;
-	snap->brush_size = brush->size;
+	snap->brush_size = sculpt_get_brush_size(brush);
 	snap->winx = vc->ar->winx;
 	snap->winy = vc->ar->winy;
 	snap->brush_map_mode = brush->mtex.brush_map_mode;
@@ -274,7 +274,7 @@
 		make_snap(&snap, br, vc);
 
 		if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
-			int s = br->size;
+			int s = sculpt_get_brush_size(br);
 			int r = 1;
 
 			for (s >>= 1; s > 0; s >>= 1)
@@ -312,7 +312,7 @@
 				// largely duplicated from tex_strength
 
 				const float rotation = -br->mtex.rot;
-				float diameter = br->size;
+				float diameter = sculpt_get_brush_size(br);
 				int index = j*size + i;
 				float x;
 				float avg;
@@ -451,43 +451,6 @@
 	return len_v2v2(p1, p2);
 }
 
-static void sculpt_set_brush_radius(bContext* C, Brush *brush, int value)
-{
-	
-	brush->size = value;
-	//printf("resize radius \n");
-	//U.sculpt_paint_pixel_radius = value;
-
-	//PointerRNA brushptr;
-	//PropertyRNA *size;
-
-	///* brush.size = value */
-
-	//RNA_id_pointer_create(&brush->id, &brushptr);
-
-	//size= RNA_struct_find_property(&brushptr, "size");
-	//RNA_property_int_set(&brushptr, size, value);
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list