[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27660] trunk/blender/release/scripts/ui/ properties_material.py: Fix node material properties not showing correct, the code here should not

Brecht Van Lommel brecht at blender.org
Mon Mar 22 16:50:16 CET 2010


Revision: 27660
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27660
Author:   blendix
Date:     2010-03-22 16:50:16 +0100 (Mon, 22 Mar 2010)

Log Message:
-----------
Fix node material properties not showing correct, the code here should not
be removed, because some panels use the parent materials while others use
the nested materials.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_material.py

Modified: trunk/blender/release/scripts/ui/properties_material.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_material.py	2010-03-22 13:24:41 UTC (rev 27659)
+++ trunk/blender/release/scripts/ui/properties_material.py	2010-03-22 15:50:16 UTC (rev 27660)
@@ -23,7 +23,19 @@
 narrowui = 180
 
 
+def active_node_mat(mat):
+    # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
+    # which settings from node-materials are used
+    if mat:
+        mat_node = mat.active_node_material
+        if mat_node:
+            return mat_node
+        else:
+            return mat
 
+    return None
+
+
 class MATERIAL_MT_sss_presets(bpy.types.Menu):
     bl_label = "SSS Presets"
     preset_subdir = "sss"
@@ -136,14 +148,14 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         wide_ui = context.region.width > narrowui
 
         if mat.type in ('SURFACE', 'WIRE'):
@@ -247,14 +259,14 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
@@ -293,14 +305,14 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
@@ -330,14 +342,14 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         wide_ui = context.region.width > narrowui
 
         split = layout.split()
@@ -401,14 +413,14 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         wide_ui = context.region.width > narrowui
 
         layout.active = (not mat.shadeless)
@@ -471,12 +483,12 @@
     COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
     def draw_header(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         sss = mat.subsurface_scattering
 
         self.layout.active = (not mat.shadeless)
@@ -485,7 +497,7 @@
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         sss = mat.subsurface_scattering
         wide_ui = context.region.width > narrowui
 
@@ -523,19 +535,19 @@
     COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
     def draw_header(self, context):
-        raym = context.material.raytrace_mirror
+        raym = active_node_mat(context.material).raytrace_mirror
 
         self.layout.prop(raym, "enabled", text="")
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         raym = mat.raytrace_mirror
         wide_ui = context.region.width > narrowui
 
@@ -582,19 +594,19 @@
     COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
     def draw_header(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
 
         self.layout.prop(mat, "transparency", text="")
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         rayt = mat.raytrace_transparency
         wide_ui = context.region.width > narrowui
 
@@ -649,19 +661,19 @@
     COMPAT_ENGINES = {'BLENDER_GAME'}
 
     def poll(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
         engine = context.scene.render.engine
         return mat  and (engine in self.COMPAT_ENGINES)
 
     def draw_header(self, context):
-        mat = context.material
+        mat = active_node_mat(context.material)
 
         self.layout.prop(mat, "transparency", text="")
 
     def draw(self, context):
         layout = self.layout
 
-        mat = context.material
+        mat = active_node_mat(context.material)
         rayt = mat.raytrace_transparency
         wide_ui = context.region.width > narrowui
 





More information about the Bf-blender-cvs mailing list