[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37324] branches/cycles: Cycles: texture tab in properties editor now shows dropdown for selecting

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jun 9 01:36:07 CEST 2011


Revision: 37324
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37324
Author:   blendix
Date:     2011-06-08 23:36:06 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
Cycles: texture tab in properties editor now shows dropdown for selecting
texture users in the context. It's only useful for modifiers and brushes
at the moment, not for shading nodes as using texture datablocks there is
not yet supported.

Modified Paths:
--------------
    branches/cycles/intern/cycles/blender/addon/ui.py
    branches/cycles/source/blender/blenkernel/BKE_modifier.h
    branches/cycles/source/blender/blenkernel/intern/modifier.c
    branches/cycles/source/blender/blenloader/intern/readfile.c
    branches/cycles/source/blender/editors/include/UI_interface.h
    branches/cycles/source/blender/editors/space_buttons/CMakeLists.txt
    branches/cycles/source/blender/editors/space_buttons/buttons_context.c
    branches/cycles/source/blender/editors/space_buttons/buttons_intern.h
    branches/cycles/source/blender/editors/space_buttons/space_buttons.c
    branches/cycles/source/blender/makesdna/DNA_space_types.h
    branches/cycles/source/blender/makesrna/intern/rna_ui_api.c
    branches/cycles/source/blender/modifiers/intern/MOD_armature.c
    branches/cycles/source/blender/modifiers/intern/MOD_array.c
    branches/cycles/source/blender/modifiers/intern/MOD_bevel.c
    branches/cycles/source/blender/modifiers/intern/MOD_boolean.c
    branches/cycles/source/blender/modifiers/intern/MOD_build.c
    branches/cycles/source/blender/modifiers/intern/MOD_cast.c
    branches/cycles/source/blender/modifiers/intern/MOD_cloth.c
    branches/cycles/source/blender/modifiers/intern/MOD_collision.c
    branches/cycles/source/blender/modifiers/intern/MOD_curve.c
    branches/cycles/source/blender/modifiers/intern/MOD_decimate.c
    branches/cycles/source/blender/modifiers/intern/MOD_displace.c
    branches/cycles/source/blender/modifiers/intern/MOD_edgesplit.c
    branches/cycles/source/blender/modifiers/intern/MOD_explode.c
    branches/cycles/source/blender/modifiers/intern/MOD_fluidsim.c
    branches/cycles/source/blender/modifiers/intern/MOD_hook.c
    branches/cycles/source/blender/modifiers/intern/MOD_lattice.c
    branches/cycles/source/blender/modifiers/intern/MOD_mask.c
    branches/cycles/source/blender/modifiers/intern/MOD_meshdeform.c
    branches/cycles/source/blender/modifiers/intern/MOD_mirror.c
    branches/cycles/source/blender/modifiers/intern/MOD_multires.c
    branches/cycles/source/blender/modifiers/intern/MOD_none.c
    branches/cycles/source/blender/modifiers/intern/MOD_particleinstance.c
    branches/cycles/source/blender/modifiers/intern/MOD_particlesystem.c
    branches/cycles/source/blender/modifiers/intern/MOD_screw.c
    branches/cycles/source/blender/modifiers/intern/MOD_shapekey.c
    branches/cycles/source/blender/modifiers/intern/MOD_shrinkwrap.c
    branches/cycles/source/blender/modifiers/intern/MOD_simpledeform.c
    branches/cycles/source/blender/modifiers/intern/MOD_smoke.c
    branches/cycles/source/blender/modifiers/intern/MOD_smooth.c
    branches/cycles/source/blender/modifiers/intern/MOD_softbody.c
    branches/cycles/source/blender/modifiers/intern/MOD_solidify.c
    branches/cycles/source/blender/modifiers/intern/MOD_subsurf.c
    branches/cycles/source/blender/modifiers/intern/MOD_surface.c
    branches/cycles/source/blender/modifiers/intern/MOD_uvproject.c
    branches/cycles/source/blender/modifiers/intern/MOD_warp.c
    branches/cycles/source/blender/modifiers/intern/MOD_wave.c
    branches/cycles/source/blender/nodes/SHD_node.h

Added Paths:
-----------
    branches/cycles/source/blender/editors/space_buttons/buttons_texture.c

Modified: branches/cycles/intern/cycles/blender/addon/ui.py
===================================================================
--- branches/cycles/intern/cycles/blender/addon/ui.py	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/intern/cycles/blender/addon/ui.py	2011-06-08 23:36:06 UTC (rev 37324)
@@ -97,22 +97,22 @@
 		col.prop(cycles, "debug_text_timeout")
 
 class Cycles_PT_post_processing(CyclesButtonsPanel, bpy.types.Panel):
-    bl_label = "Post Processing"
-    bl_options = {'DEFAULT_CLOSED'}
+	bl_label = "Post Processing"
+	bl_options = {'DEFAULT_CLOSED'}
 
-    def draw(self, context):
-        layout = self.layout
+	def draw(self, context):
+		layout = self.layout
 
-        rd = context.scene.render
+		rd = context.scene.render
 
-        split = layout.split()
+		split = layout.split()
 
-        col = split.column()
-        col.prop(rd, "use_compositing")
-        col.prop(rd, "use_sequencer")
+		col = split.column()
+		col.prop(rd, "use_compositing")
+		col.prop(rd, "use_sequencer")
 
-        col = split.column()
-        col.prop(rd, "dither_intensity", text="Dither", slider=True)
+		col = split.column()
+		col.prop(rd, "dither_intensity", text="Dither", slider=True)
 
 class Cycles_PT_camera(CyclesButtonsPanel, bpy.types.Panel):
 	bl_label = "Cycles"
@@ -231,10 +231,10 @@
 	node = find_node(id, output_type)
 	if not node:
 		layout.label(text="No output node.")
+	else:
+		input = find_node_input(node, input_name)
+		layout.template_node_view(id, ntree, node, input);
 
-	input = find_node_input(node, input_name)
-	layout.template_node_view(id, ntree, node, input);
-
 class CyclesLamp_PT_lamp(CyclesButtonsPanel, bpy.types.Panel):
 	bl_label = "Surface"
 	bl_context = "data"
@@ -339,6 +339,41 @@
 		row = layout.row()
 		row.label(text="Light Group:")
 		row.prop(mat, "light_group", text="")
+
+class CyclesTexture_PT_context(CyclesButtonsPanel, bpy.types.Panel):
+	bl_label = ""
+	bl_context = "texture"
+	bl_options = {'HIDE_HEADER'}
+	COMPAT_ENGINES = {'CYCLES'}
+
+	def draw(self, context):
+		layout = self.layout
+
+		tex = context.texture
+		space = context.space_data
+		pin_id = space.pin_id
+		use_pin_id = space.use_pin_id;
+		user = context.texture_user
+
+		if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
+			pin_id = None
+
+		if not pin_id:
+			layout.template_texture_user()
+			layout.separator()
+
+		split = layout.split(percentage=0.65)
+		col = split.column()
+
+		if pin_id:
+			col.template_ID(space, "pin_id")
+		elif user:
+			col.template_ID(user, "texture", new="texture.new")
+
+		if tex:
+			split = layout.split(percentage=0.2)
+			split.label(text="Type:")
+			split.prop(tex, "type", text="")
 	
 def draw_device(self, context):
 	scene = context.scene
@@ -372,7 +407,22 @@
 		bpy.types.DATA_PT_custom_props_camera,
 		bpy.types.DATA_PT_context_lamp,
 		bpy.types.DATA_PT_custom_props_lamp,
-		bpy.types.TEXTURE_PT_context_texture]
+		bpy.types.TEXTURE_PT_clouds,
+		bpy.types.TEXTURE_PT_wood,
+		bpy.types.TEXTURE_PT_marble,
+		bpy.types.TEXTURE_PT_magic,
+		bpy.types.TEXTURE_PT_blend,
+		bpy.types.TEXTURE_PT_stucci,
+		bpy.types.TEXTURE_PT_image,
+		bpy.types.TEXTURE_PT_image_sampling,
+		bpy.types.TEXTURE_PT_image_mapping,
+		bpy.types.TEXTURE_PT_musgrave,
+		bpy.types.TEXTURE_PT_voronoi,
+		bpy.types.TEXTURE_PT_distortednoise,
+		bpy.types.TEXTURE_PT_voxeldata,
+		bpy.types.TEXTURE_PT_pointdensity,
+		bpy.types.TEXTURE_PT_pointdensity_turbulence,
+		bpy.types.TEXTURE_PT_custom_props]
 
 def register():
 	bpy.types.RENDER_PT_render.append(draw_device)

Modified: branches/cycles/source/blender/blenkernel/BKE_modifier.h
===================================================================
--- branches/cycles/source/blender/blenkernel/BKE_modifier.h	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/source/blender/blenkernel/BKE_modifier.h	2011-06-08 23:36:06 UTC (rev 37324)
@@ -101,6 +101,7 @@
 
 typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin);
 typedef void (*IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin);
+typedef void (*TexWalkFunc)(void *userData, struct Object *ob, struct ModifierData *md, const char *propname);
 
 typedef struct ModifierTypeInfo {
 	/* The user visible name for this modifier */
@@ -284,6 +285,16 @@
 	 */
 	void (*foreachIDLink)(struct ModifierData *md, struct Object *ob,
 						  IDWalkFunc walk, void *userData);
+
+	/* Should call the given walk function for each texture that the
+	 * modifier data stores. This is used for finding all textures in
+	 * the context for the UI.
+	 *
+	 * This function is optional. If it is not present, it will be
+	 * assumed the modifier has no textures.
+	 */
+	void (*foreachTexLink)(struct ModifierData *md, struct Object *ob,
+						  TexWalkFunc walk, void *userData);
 } ModifierTypeInfo;
 
 ModifierTypeInfo *modifierType_getInfo (ModifierType type);
@@ -315,6 +326,10 @@
 void          modifiers_foreachIDLink(struct Object *ob,
 									  IDWalkFunc walk,
 									  void *userData);
+void          modifiers_foreachTexLink(struct Object *ob,
+									  TexWalkFunc walk,
+									  void *userData);
+
 struct ModifierData  *modifiers_findByType(struct Object *ob, ModifierType type);
 struct ModifierData  *modifiers_findByName(struct Object *ob, const char *name);
 void          modifiers_clearErrors(struct Object *ob);

Modified: branches/cycles/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/cycles/source/blender/blenkernel/intern/modifier.c	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/source/blender/blenkernel/intern/modifier.c	2011-06-08 23:36:06 UTC (rev 37324)
@@ -195,6 +195,18 @@
 	}
 }
 
+void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
+{
+	ModifierData *md = ob->modifiers.first;
+
+	for (; md; md=md->next) {
+		ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+
+		if(mti->foreachTexLink)
+			mti->foreachTexLink(md, ob, walk, userData);
+	}
+}
+
 void modifier_copyData(ModifierData *md, ModifierData *target)
 {
 	ModifierTypeInfo *mti = modifierType_getInfo(md->type);

Modified: branches/cycles/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/cycles/source/blender/blenloader/intern/readfile.c	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/source/blender/blenloader/intern/readfile.c	2011-06-08 23:36:06 UTC (rev 37324)
@@ -5462,6 +5462,7 @@
 			else if(sl->spacetype==SPACE_BUTS) {
 				SpaceButs *sbuts= (SpaceButs *)sl;
 				sbuts->path= NULL;
+				sbuts->texuser= NULL;
 			}
 			else if(sl->spacetype==SPACE_CONSOLE) {
 				SpaceConsole *sconsole= (SpaceConsole *)sl;

Modified: branches/cycles/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/cycles/source/blender/editors/include/UI_interface.h	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/source/blender/editors/include/UI_interface.h	2011-06-08 23:36:06 UTC (rev 37324)
@@ -728,6 +728,7 @@
 void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type);
 void uiTemplateNodeLink(uiLayout *layout, struct ID *id, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
 void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct ID *id, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
+void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
 
 /* items */
 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);

Modified: branches/cycles/source/blender/editors/space_buttons/CMakeLists.txt
===================================================================
--- branches/cycles/source/blender/editors/space_buttons/CMakeLists.txt	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/source/blender/editors/space_buttons/CMakeLists.txt	2011-06-08 23:36:06 UTC (rev 37324)
@@ -38,6 +38,7 @@
 	buttons_context.c
 	buttons_header.c
 	buttons_ops.c
+	buttons_texture.c
 	space_buttons.c
 
 	buttons_intern.h

Modified: branches/cycles/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- branches/cycles/source/blender/editors/space_buttons/buttons_context.c	2011-06-08 21:18:03 UTC (rev 37323)
+++ branches/cycles/source/blender/editors/space_buttons/buttons_context.c	2011-06-08 23:36:06 UTC (rev 37324)
@@ -55,7 +55,6 @@
 #include "BKE_screen.h"
 #include "BKE_texture.h"
 
-
 #include "RNA_access.h"
 
 #include "ED_armature.h"
@@ -67,13 +66,6 @@
 
 #include "buttons_intern.h"	// own include
 
-typedef struct ButsContextPath {
-	PointerRNA ptr[8];
-	int len;
-	int flag;
-	int tex_ctx;
-} ButsContextPath;
-
 static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
 {
 	PointerRNA *ptr;
@@ -237,11 +229,13 @@
 			RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
 			path->len++;
 			
+#if 0
 			ma= give_node_material(ma);
 			if(ma) {
 				RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
 				path->len++;
 			}			
+#endif
 			return 1;
 		}
 	}
@@ -370,8 +364,42 @@
 	return 0;
 }
 
-static int buttons_context_path_texture(ButsContextPath *path)
+static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct)
 {
+	PointerRNA *ptr= &path->ptr[path->len-1];
+	ID *id;
+
+	/* if we already have a (pinned) texture, we're done */
+	if(RNA_struct_is_a(ptr->type, &RNA_Texture))
+		return 1;
+
+	if(!(ct && ct->user))
+		return 0;
+	
+	id= ct->user->id;
+
+	if(id) {
+		if(GS(id->name) == ID_BR)
+			buttons_context_path_brush(path);
+		else if(GS(id->name) == ID_MA)
+			buttons_context_path_material(path);
+		else if(GS(id->name) == ID_WO)
+			buttons_context_path_world(path);
+		else if(GS(id->name) == ID_LA)
+			buttons_context_path_data(path, OB_LAMP);
+		else if(GS(id->name) == ID_PA)
+			buttons_context_path_particle(path);
+		else if(GS(id->name) == ID_OB)
+			buttons_context_path_object(path);
+	}
+	
+	RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
+	path->len++;
+
+	return 1;
+
+
+#if 0
 	Material *ma;
 	Lamp *la;
 	Brush *br;
@@ -468,6 +496,7 @@
 			return 1;
 		}
 	}
+#endif
 
 	/* no path to a texture possible */
 	return 0;
@@ -527,7 +556,7 @@
 			found= buttons_context_path_material(path);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list