[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43328] trunk/blender: Move unified paint fields from ToolSettings into their own UnifiedPaintSettings struct .

Nicholas Bishop nicholasbishop at gmail.com
Thu Jan 12 18:22:40 CET 2012


Revision: 43328
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43328
Author:   nicholasbishop
Date:     2012-01-12 17:22:32 +0000 (Thu, 12 Jan 2012)
Log Message:
-----------
Move unified paint fields from ToolSettings into their own UnifiedPaintSettings struct.

File subversion is bumped to two in order to copy over the old fields.

This removes two RNA properties, sculpt_paint_use_unified_size and
sculpt_paint_use_unified_strength.

Code review link:
http://codereview.appspot.com/5529077

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/makesrna/intern/rna_scene.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-12 17:13:56 UTC (rev 43327)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-01-12 17:22:32 UTC (rev 43328)
@@ -468,7 +468,14 @@
 
         return None
 
+    @staticmethod
+    def unified_paint_settings(parent, context):
+        ups = context.tool_settings.unified_paint_settings
+        parent.label(text="Unified Settings:")
+        parent.prop(ups, "use_unified_size", text="Size")
+        parent.prop(ups, "use_unified_strength", text="Strength")
 
+
 class VIEW3D_PT_tools_brush(PaintPanel, Panel):
     bl_label = "Brush"
 
@@ -950,9 +957,7 @@
         layout.prop(sculpt, "show_brush")
         layout.prop(sculpt, "use_deform_only")
 
-        layout.label(text="Unified Settings:")
-        layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
-        layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
+        self.unified_paint_settings(layout, context)
 
 
 class VIEW3D_PT_sculpt_symmetry(PaintPanel, Panel):
@@ -1041,7 +1046,7 @@
         col.operator("object.vertex_group_fix", text="Fix Deforms")
 
 
-class VIEW3D_PT_tools_weightpaint_options(View3DPanel, Panel):
+class VIEW3D_PT_tools_weightpaint_options(PaintPanel, Panel):
     bl_context = "weightpaint"
     bl_label = "Options"
 
@@ -1062,9 +1067,7 @@
             col.prop(mesh, "use_mirror_x")
             col.prop(mesh, "use_mirror_topology")
 
-        col.label(text="Unified Settings:")
-        col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
-        col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
+        self.unified_paint_settings(col, context)
 
 # Commented out because the Apply button isn't an operator yet, making these settings useless
 #		col.label(text="Gamma:")
@@ -1078,7 +1081,7 @@
 # ********** default tools for vertex-paint ****************
 
 
-class VIEW3D_PT_tools_vertexpaint(View3DPanel, Panel):
+class VIEW3D_PT_tools_vertexpaint(PaintPanel, Panel):
     bl_context = "vertexpaint"
     bl_label = "Options"
 
@@ -1094,9 +1097,7 @@
         col.prop(vpaint, "use_normal")
         col.prop(vpaint, "use_spray")
 
-        col.label(text="Unified Settings:")
-        col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
-        col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
+        self.unified_paint_settings(col, context)
 
 # Commented out because the Apply button isn't an operator yet, making these settings useless
 #		col.label(text="Gamma:")
@@ -1187,9 +1188,7 @@
         tool_settings = context.tool_settings
 
         col = layout.column()
-        col.label(text="Unified Settings:")
-        col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size")
-        col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength")
+        self.unified_paint_settings(col, context)
 
 
 class VIEW3D_MT_tools_projectpaint_clone(Menu):

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h	2012-01-12 17:13:56 UTC (rev 43327)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h	2012-01-12 17:22:32 UTC (rev 43328)
@@ -42,7 +42,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION			261
-#define BLENDER_SUBVERSION		1
+#define BLENDER_SUBVERSION		2
 
 #define BLENDER_MINVERSION		250
 #define BLENDER_MINSUBVERSION	0

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c	2012-01-12 17:13:56 UTC (rev 43327)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c	2012-01-12 17:22:32 UTC (rev 43328)
@@ -1231,9 +1231,9 @@
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
 			if (value)
-				sce->toolsettings->sculpt_paint_settings |= flag;
+				sce->toolsettings->unified_paint_settings.flag |= flag;
 			else
-				sce->toolsettings->sculpt_paint_settings &= ~flag;
+				sce->toolsettings->unified_paint_settings.flag &= ~flag;
 		}
 	}
 }
@@ -1249,7 +1249,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			return sce->toolsettings->sculpt_paint_settings;
+			return sce->toolsettings->unified_paint_settings.flag;
 		}
 	}
 
@@ -1280,7 +1280,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			sce->toolsettings->sculpt_paint_unified_size= value;
+			sce->toolsettings->unified_paint_settings.size= value;
 		}
 	}
 }
@@ -1296,7 +1296,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			return sce->toolsettings->sculpt_paint_unified_size;
+			return sce->toolsettings->unified_paint_settings.size;
 		}
 	}
 
@@ -1314,7 +1314,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			sce->toolsettings->sculpt_paint_unified_alpha= value;
+			sce->toolsettings->unified_paint_settings.alpha= value;
 		}
 	}
 }
@@ -1330,7 +1330,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			return sce->toolsettings->sculpt_paint_unified_alpha;
+			return sce->toolsettings->unified_paint_settings.alpha;
 		}
 	}
 
@@ -1348,7 +1348,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			sce->toolsettings->sculpt_paint_unified_unprojected_radius= value;
+			sce->toolsettings->unified_paint_settings.unprojected_radius= value;
 		}
 	}
 }
@@ -1364,7 +1364,7 @@
 			    paint_brush(&(sce->toolsettings->wpaint->paint)),
 			    paint_brush(&(sce->toolsettings->sculpt->paint))))
 		{
-			return sce->toolsettings->sculpt_paint_unified_unprojected_radius;
+			return sce->toolsettings->unified_paint_settings.unprojected_radius;
 		}
 	}
 

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2012-01-12 17:13:56 UTC (rev 43327)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2012-01-12 17:22:32 UTC (rev 43328)
@@ -12940,7 +12940,7 @@
 		}
 	}
 
-	/* put compatibility code here until next subversion bump */
+	if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2))
 	{
 		{
 			/* convert Camera Actuator values to defines */
@@ -12959,7 +12959,25 @@
 				}
 			}
 		}
+
+		{
+			/* convert deprecated sculpt_paint_unified_* fields to
+			   UnifiedPaintSettings */
+			Scene *scene;
+			for(scene= main->scene.first; scene; scene= scene->id.next) {
+				ToolSettings *ts= scene->toolsettings;
+				UnifiedPaintSettings *ups= &ts->unified_paint_settings;
+				ups->size= ts->sculpt_paint_unified_size;
+				ups->unprojected_radius= ts->sculpt_paint_unified_unprojected_radius;
+				ups->alpha= ts->sculpt_paint_unified_alpha;
+				ups->flag= ts->sculpt_paint_settings;
+			}
+		}
 	}
+	
+	/* put compatibility code here until next subversion bump */
+	{
+	}
 
 	/* 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/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h	2012-01-12 17:13:56 UTC (rev 43327)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h	2012-01-12 17:22:32 UTC (rev 43328)
@@ -815,6 +815,38 @@
 } TransformOrientation;
 
 /* *************************************************************** */
+/* Unified Paint Settings */
+
+/* These settings can override the equivalent fields in the active
+   Brush for any paint mode; the flag field controls whether these
+   values are used */
+typedef struct UnifiedPaintSettings {
+	/* unified radius of brush in pixels */
+	int size;
+
+	/* unified radius of brush in Blender units */
+	float unprojected_radius;
+
+	/* unified strength of brush */
+	float alpha;
+
+	/* user preferences for sculpt and paint */
+	int flag;
+} UnifiedPaintSettings;
+
+typedef enum {
+	SCULPT_PAINT_USE_UNIFIED_SIZE        = (1<<0),
+	SCULPT_PAINT_USE_UNIFIED_ALPHA       = (1<<1),
+
+	/* only used if unified size is enabled */
+	SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE = (1<<2),
+	SCULPT_PAINT_UNIFIED_SIZE_PRESSURE   = (1<<3),
+
+	/* only used if unified alpha is enabled */
+	SCULPT_PAINT_UNIFIED_ALPHA_PRESSURE  = (1<<4)
+} UnifiedPaintSettingsFlags;
+
+/* *************************************************************** */
 /* Tool Settings */
 
 typedef struct ToolSettings {
@@ -936,11 +968,16 @@
 	char auto_normalize; /*auto normalizing mode in wpaint*/
 	char multipaint; /* paint multiple bones in wpaint */
 
-	short sculpt_paint_settings; /* user preferences for sculpt and paint */
+	/* XXX: these sculpt_paint_* fields are deprecated, use the
+	   unified_paint_settings field instead! */
+	short sculpt_paint_settings DNA_DEPRECATED;
 	short pad1;
-	int sculpt_paint_unified_size; /* unified radius of brush in pixels */
-	float sculpt_paint_unified_unprojected_radius;/* unified radius of brush in Blender units */
-	float sculpt_paint_unified_alpha; /* unified strength of brush */
+	int sculpt_paint_unified_size DNA_DEPRECATED;
+	float sculpt_paint_unified_unprojected_radius DNA_DEPRECATED;
+	float sculpt_paint_unified_alpha DNA_DEPRECATED;
+
+	/* Unified Paint Settings */
+	struct UnifiedPaintSettings unified_paint_settings;
 } ToolSettings;
 
 /* *************************************************************** */
@@ -1367,13 +1404,6 @@
 	SCULPT_ONLY_DEFORM = (1<<8),
 } SculptFlags;
 
-/* sculpt_paint_settings */
-#define SCULPT_PAINT_USE_UNIFIED_SIZE        (1<<0)
-#define SCULPT_PAINT_USE_UNIFIED_ALPHA       (1<<1)
-#define SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE (1<<2)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list