Revision: 28339
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28339
Author:   broken
Date:     2010-04-22 08:59:41 +0200 (Thu, 22 Apr 2010)

Log Message:
-----------
Fix [#22097] missing panels in texture tab

Made texture/texture slot context a bit less flaky when dealing with active 
material and 
texture nodes inside a node material in the node editor. Now if the active 
material has 
nodes enabled, and there are no active material/texture nodes inside it, 
nothing will be 
shown in the texture properties (similar to 2.49).

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_texture.py
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/editors/object/object_modifier.c
    trunk/blender/source/blender/editors/space_buttons/buttons_context.c

Modified: trunk/blender/release/scripts/ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_texture.py      2010-04-22 
01:55:10 UTC (rev 28338)
+++ trunk/blender/release/scripts/ui/properties_texture.py      2010-04-22 
06:59:41 UTC (rev 28339)
@@ -70,8 +70,9 @@
 
     def poll(self, context):
         tex = context.texture
+        if not tex or tex == None: return False
         engine = context.scene.render.engine
-        return (tex and (tex.type != 'NONE' or tex.use_nodes) and (engine in 
self.COMPAT_ENGINES))
+        return (tex.type != 'NONE' or tex.use_nodes) and (engine in 
self.COMPAT_ENGINES)
 
 
 class TEXTURE_PT_preview(TextureButtonsPanel):
@@ -82,8 +83,10 @@
         layout = self.layout
 
         tex = context.texture
-        slot = context.texture_slot
-
+        try:
+            slot = context.texture_slot
+        except:
+            slot = None
         idblock = context_tex_datablock(context)
 
         if idblock:
@@ -99,7 +102,10 @@
 
     def poll(self, context):
         engine = context.scene.render.engine
-        return ((context.material or context.world or context.lamp or 
context.brush or context.texture) and (engine in self.COMPAT_ENGINES))
+        try: getattr(context, "texture_slot")
+        except: return False
+        return ((context.material or context.world or context.lamp or 
context.brush or context.texture) 
+            and (engine in self.COMPAT_ENGINES))
 
     def draw(self, context):
         layout = self.layout
@@ -206,9 +212,11 @@
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def poll(self, context):
+        try: getattr(context, "texture_slot")
+        except: return False
+        
         engine = context.scene.render.engine
-        return (context.texture_slot and
-                TextureButtonsPanel.poll(self, context) and (engine in 
self.COMPAT_ENGINES))
+        return TextureButtonsPanel.poll(self, context) and (engine in 
self.COMPAT_ENGINES)
 
 
 class TEXTURE_PT_mapping(TextureSlotPanel):
@@ -219,6 +227,9 @@
         idblock = context_tex_datablock(context)
         if type(idblock) == bpy.types.Brush and not context.sculpt_object:
             return False
+        try: getattr(context, "texture_slot")
+        except: return False
+        
         engine = context.scene.render.engine
         return context.texture_slot and (engine in self.COMPAT_ENGINES)
 
@@ -313,6 +324,8 @@
         idblock = context_tex_datablock(context)
         if type(idblock) == bpy.types.Brush:
             return False
+        try: getattr(context, "texture_slot")
+        except: return False
 
         engine = context.scene.render.engine
         return context.texture_slot and (engine in self.COMPAT_ENGINES)

Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c    2010-04-22 
01:55:10 UTC (rev 28338)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c    2010-04-22 
06:59:41 UTC (rev 28339)
@@ -879,9 +879,15 @@
                }
                else {
                        node= nodeGetActiveID(ma->nodetree, ID_MA);
-                       if(node)
+                       if(node) {
                                ma= (Material*)node->id;
+                               if(ma) {
+                                       mtex= ma->mtex[(int)(ma->texact)];
+                                       if(mtex) tex= mtex->tex;
+                               }
+                       }
                }
+               return tex;
        }
 
        if(ma) {

Modified: trunk/blender/source/blender/editors/object/object_modifier.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_modifier.c       
2010-04-22 01:55:10 UTC (rev 28338)
+++ trunk/blender/source/blender/editors/object/object_modifier.c       
2010-04-22 06:59:41 UTC (rev 28339)
@@ -573,7 +573,7 @@
        ot->prop= prop;
 }
 
-/************************ poll function for operators using mod names and data 
context *********************/
+/************************ generic functions for operators using mod names and 
data context *********************/
 
 static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type)
 {
@@ -593,7 +593,7 @@
 
 static void edit_modifier_properties(wmOperatorType *ot)
 {
-       RNA_def_string(ot->srna, "modifier", "", 32, "Modifier", "Name of the 
modifier to apply");
+       RNA_def_string(ot->srna, "modifier", "", 32, "Modifier", "Name of the 
modifier to edit");
 }
 
 static int edit_modifier_invoke_properties(bContext *C, wmOperator *op)

Modified: trunk/blender/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- trunk/blender/source/blender/editors/space_buttons/buttons_context.c        
2010-04-22 01:55:10 UTC (rev 28338)
+++ trunk/blender/source/blender/editors/space_buttons/buttons_context.c        
2010-04-22 06:59:41 UTC (rev 28339)
@@ -699,11 +699,20 @@
                        Material *ma= ptr->data;
 
                        /* if we have a node material, get slot from material 
in material node */
-                       if(ma && ma->use_nodes && ma->nodetree)
+                       if(ma && ma->use_nodes && ma->nodetree) {
+                               /* if there's an active texture node in the 
node tree,
+                                * then that texture is in context directly, 
without a texture slot */
+                               if (give_current_material_texture_node(ma))
+                                       return 0;
+                               
                                ma= give_node_material(ma);
-
-                       if(ma)
+                               if (ma)
+                                       CTX_data_pointer_set(result, &ma->id, 
&RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
+                               else
+                                       return 0;
+                       } else if(ma) {
                                CTX_data_pointer_set(result, &ma->id, 
&RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
+                       }
                }
                else if((ptr=get_pointer_type(path, &RNA_Lamp))) {
                        Lamp *la= ptr->data;


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to