[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46650] trunk/blender: Code/UI cleanup: improvements for sculpt brush texture settings.

Nicholas Bishop nicholasbishop at gmail.com
Tue May 15 06:50:48 CEST 2012


Revision: 46650
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46650
Author:   nicholasbishop
Date:     2012-05-15 04:50:47 +0000 (Tue, 15 May 2012)
Log Message:
-----------
Code/UI cleanup: improvements for sculpt brush texture settings.

Settings are shown in both the View3D toolbar and texture properties
panel; code is now in shared sculpt_brush_texture_settings() function
in properties_paint_common.py.

Also added a few new properties to the SculptCapabilities RNA to
replace "X in {Y, Z}" tests in the Python code.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
    trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
    trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    trunk/blender/source/blender/makesrna/intern/rna_brush.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-05-15 04:44:20 UTC (rev 46649)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py	2012-05-15 04:50:47 UTC (rev 46650)
@@ -67,3 +67,37 @@
         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)
+
+
+# Used in both the View3D toolbar and texture properties
+def sculpt_brush_texture_settings(layout, brush):
+    tex_slot = brush.texture_slot
+
+    layout.label(text="Brush Mapping:")
+
+    # map_mode
+    layout.row().prop(tex_slot, "map_mode", text="")
+    layout.separator()
+
+    # angle and texture_angle_source
+    col = layout.column()
+    col.active = brush.sculpt_capabilities.has_texture_angle_source
+    col.label(text="Angle:")
+    if brush.sculpt_capabilities.has_random_texture_angle:
+        col.prop(brush, "texture_angle_source_random", text="")
+    else:
+        col.prop(brush, "texture_angle_source_no_random", text="")
+
+    col = layout.column()
+    col.active = brush.sculpt_capabilities.has_texture_angle
+    col.prop(tex_slot, "angle", text="")
+
+    # scale and offset
+    split = layout.split()
+    split.prop(tex_slot, "offset")
+    split.prop(tex_slot, "scale")
+
+    # texture_sample_bias
+    col = layout.column(align=True)
+    col.label(text="Sample Bias:")
+    col.prop(brush, "texture_sample_bias", slider=True, text="")

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_texture.py	2012-05-15 04:44:20 UTC (rev 46649)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_texture.py	2012-05-15 04:50:47 UTC (rev 46650)
@@ -29,7 +29,9 @@
 
 from rna_prop_ui import PropertyPanel
 
+from bl_ui.properties_paint_common import sculpt_brush_texture_settings
 
+
 class TEXTURE_MT_specials(Menu):
     bl_label = "Texture Specials"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -856,12 +858,7 @@
 
         if isinstance(idblock, Brush):
             if context.sculpt_object:
-                layout.label(text="Brush Mapping:")
-                layout.prop(tex, "map_mode", expand=True)
-
-                row = layout.row()
-                row.active = tex.map_mode in {'FIXED', 'TILED'}
-                row.prop(tex, "angle")
+                sculpt_brush_texture_settings(layout, idblock)
         else:
             if isinstance(idblock, Material):
                 split = layout.split(percentage=0.3)
@@ -884,9 +881,9 @@
                 row.prop(tex, "mapping_y", text="")
                 row.prop(tex, "mapping_z", text="")
 
-        row = layout.row()
-        row.column().prop(tex, "offset")
-        row.column().prop(tex, "scale")
+            row = layout.row()
+            row.column().prop(tex, "offset")
+            row.column().prop(tex, "scale")
 
 
 class TEXTURE_PT_influence(TextureSlotPanel, Panel):

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-05-15 04:44:20 UTC (rev 46649)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-05-15 04:50:47 UTC (rev 46650)
@@ -20,6 +20,7 @@
 import bpy
 from bpy.types import Menu, Panel
 from bl_ui.properties_paint_common import UnifiedPaintPanel
+from bl_ui.properties_paint_common import sculpt_brush_texture_settings
 
 
 class View3DPanel():
@@ -719,45 +720,11 @@
             col.prop(brush, "use_fixed_texture")
 
         if context.sculpt_object:
-            #XXX duplicated from properties_texture.py
+            sculpt_brush_texture_settings(col, brush)
 
-            col.label(text="Brush Mapping:")
-            col.row().prop(tex_slot, "map_mode", expand=True)
-
-            col.separator()
-
-            col = layout.column()
-            col.active = tex_slot.map_mode in {'FIXED'}
-            col.label(text="Angle:")
-            if brush.sculpt_capabilities.has_random_texture_angle:
-                col.prop(brush, "texture_angle_source_random", text="")
-            else:
-                col.prop(brush, "texture_angle_source_no_random", text="")
-
-            #row = col.row(align=True)
-            #row.label(text="Angle:")
-            #row.active = tex_slot.map_mode in {'FIXED', 'TILED'}
-
-            #row = col.row(align=True)
-
-            #col = row.column()
-            #col.active = tex_slot.map_mode in {'FIXED'}
-            #col.prop(brush, "use_rake", toggle=True, icon='PARTICLEMODE', text="")
-
-            col = layout.column()
-            col.active = tex_slot.map_mode in {'FIXED', 'TILED'}
-            col.prop(tex_slot, "angle", text="")
-
-            split = layout.split()
-            split.prop(tex_slot, "offset")
-            split.prop(tex_slot, "scale")
-
+            # use_texture_overlay and texture_overlay_alpha
             col = layout.column(align=True)
-            col.label(text="Sample Bias:")
-            col.prop(brush, "texture_sample_bias", slider=True, text="")
-
-            col = layout.column(align=True)
-            col.active = tex_slot.map_mode in {'FIXED', 'TILED'}
+            col.active = brush.sculpt_capabilities.has_overlay
             col.label(text="Overlay:")
 
             row = col.row()
@@ -766,7 +733,6 @@
             else:
                 row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
             sub = row.row()
-            sub.active = tex_slot.map_mode in {'FIXED', 'TILED'} and brush.use_texture_overlay
             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
 
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_brush.c	2012-05-15 04:44:20 UTC (rev 46649)
+++ trunk/blender/source/blender/makesrna/intern/rna_brush.c	2012-05-15 04:50:47 UTC (rev 46650)
@@ -142,6 +142,14 @@
 	return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
 }
 
+static int rna_SculptCapabilities_has_overlay_get(PointerRNA *ptr)
+{
+	Brush *br = (Brush *)ptr->data;
+	return ELEM(br->mtex.brush_map_mode,
+				MTEX_MAP_MODE_VIEW,
+				MTEX_MAP_MODE_TILED);
+}
+
 static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr)
 {
 	Brush *br = (Brush *)ptr->data;
@@ -222,6 +230,20 @@
 	return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
 }
 
+static int rna_SculptCapabilities_has_texture_angle_get(PointerRNA *ptr)
+{
+	Brush *br = (Brush *)ptr->data;
+	return ELEM(br->mtex.brush_map_mode,
+				MTEX_MAP_MODE_VIEW,
+				MTEX_MAP_MODE_TILED);
+}
+
+static int rna_SculptCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
+{
+	Brush *br = (Brush *)ptr->data;
+	return br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW;
+}
+
 static PointerRNA rna_Brush_sculpt_capabilities_get(PointerRNA *ptr)
 {
 	return rna_pointer_inherit_refine(ptr, &RNA_SculptCapabilities, ptr->id.data);
@@ -441,6 +463,7 @@
 	BRUSH_CAPABILITY(has_height, "Has Height");
 	BRUSH_CAPABILITY(has_jitter, "Has Jitter");
 	BRUSH_CAPABILITY(has_normal_weight, "Has Crease/Pinch Factor");
+	BRUSH_CAPABILITY(has_overlay, "Has Overlay");
 	BRUSH_CAPABILITY(has_persistence, "Has Persistence");
 	BRUSH_CAPABILITY(has_pinch_factor, "Has Pinch Factor");
 	BRUSH_CAPABILITY(has_plane_offset, "Has Plane Offset");
@@ -451,6 +474,8 @@
 	BRUSH_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
 	BRUSH_CAPABILITY(has_spacing, "Has Spacing");
 	BRUSH_CAPABILITY(has_strength, "Has Strength");
+	BRUSH_CAPABILITY(has_texture_angle, "Has Texture Angle");
+	BRUSH_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source");
 
 #undef SCULPT_CAPABILITY
 }




More information about the Bf-blender-cvs mailing list