[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41041] branches/cycles/source/blender: Cycles: more tweaks to get old/new shading systems working better together , for

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Oct 15 22:43:45 CEST 2011


Revision: 41041
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41041
Author:   blendix
Date:     2011-10-15 20:43:45 +0000 (Sat, 15 Oct 2011)
Log Message:
-----------
Cycles: more tweaks to get old/new shading systems working better together, for
now also made non-material/world/lamp stuff use old texture datablocks, no time
to get this fully working now. Still some python tweaks to do to ensure the right
panels show.

Modified Paths:
--------------
    branches/cycles/source/blender/editors/include/ED_node.h
    branches/cycles/source/blender/editors/object/object_add.c
    branches/cycles/source/blender/editors/render/render_shading.c
    branches/cycles/source/blender/editors/space_buttons/buttons_context.c
    branches/cycles/source/blender/editors/space_buttons/buttons_texture.c
    branches/cycles/source/blender/editors/space_node/node_draw.c
    branches/cycles/source/blender/editors/space_node/node_edit.c
    branches/cycles/source/blender/makesrna/intern/rna_ID.c
    branches/cycles/source/blender/makesrna/intern/rna_lamp.c
    branches/cycles/source/blender/makesrna/intern/rna_material.c
    branches/cycles/source/blender/makesrna/intern/rna_nodetree.c
    branches/cycles/source/blender/makesrna/intern/rna_render.c
    branches/cycles/source/blender/makesrna/intern/rna_texture.c
    branches/cycles/source/blender/makesrna/intern/rna_world.c
    branches/cycles/source/blender/nodes/texture/node_texture_tree.c
    branches/cycles/source/blender/render/intern/source/render_texture.c

Modified: branches/cycles/source/blender/editors/include/ED_node.h
===================================================================
--- branches/cycles/source/blender/editors/include/ED_node.h	2011-10-15 20:13:35 UTC (rev 41040)
+++ branches/cycles/source/blender/editors/include/ED_node.h	2011-10-15 20:43:45 UTC (rev 41041)
@@ -53,7 +53,7 @@
 void ED_node_generic_update(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
 
 /* node_edit.c */
-void ED_node_shader_default(struct ID *id);
+void ED_node_shader_default(struct Scene *scene, struct ID *id);
 void ED_node_composit_default(struct Scene *sce);
 void ED_node_texture_default(struct Tex *tex);
 void ED_node_link_intersect_test(struct ScrArea *sa, int test);

Modified: branches/cycles/source/blender/editors/object/object_add.c
===================================================================
--- branches/cycles/source/blender/editors/object/object_add.c	2011-10-15 20:13:35 UTC (rev 41040)
+++ branches/cycles/source/blender/editors/object/object_add.c	2011-10-15 20:43:45 UTC (rev 41041)
@@ -77,6 +77,7 @@
 #include "BKE_particle.h"
 #include "BKE_report.h"
 #include "BKE_sca.h"
+#include "BKE_scene.h"
 #include "BKE_speaker.h"
 #include "BKE_texture.h"
 
@@ -701,6 +702,7 @@
 
 static int object_lamp_add_exec(bContext *C, wmOperator *op)
 {
+	Scene *scene= CTX_data_scene(C);
 	Object *ob;
 	Lamp *la;
 	int type= RNA_enum_get(op->ptr, "type");
@@ -719,8 +721,10 @@
 	rename_id(&ob->id, get_lamp_defname(type));
 	rename_id(&la->id, get_lamp_defname(type));
 
-	ED_node_shader_default(&la->id);
-	la->use_nodes= 1;
+	if(scene_use_new_shading_nodes(scene)) {
+		ED_node_shader_default(scene, &la->id);
+		la->use_nodes= 1;
+	}
 	
 	return OPERATOR_FINISHED;
 }

Modified: branches/cycles/source/blender/editors/render/render_shading.c
===================================================================
--- branches/cycles/source/blender/editors/render/render_shading.c	2011-10-15 20:13:35 UTC (rev 41040)
+++ branches/cycles/source/blender/editors/render/render_shading.c	2011-10-15 20:43:45 UTC (rev 41041)
@@ -366,6 +366,7 @@
 
 static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
+	Scene *scene= CTX_data_scene(C);
 	Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
 	PointerRNA ptr, idptr;
 	PropertyRNA *prop;
@@ -376,8 +377,11 @@
 	}
 	else {
 		ma= add_material("Material");
-		ED_node_shader_default(&ma->id);
-		ma->use_nodes= 1;
+
+		if(scene_use_new_shading_nodes(scene)) {
+			ED_node_shader_default(scene, &ma->id);
+			ma->use_nodes= 1;
+		}
 	}
 
 	/* hook into UI */
@@ -421,14 +425,10 @@
 	PropertyRNA *prop;
 
 	/* add or copy texture */
-	if(tex) {
+	if(tex)
 		tex= copy_texture(tex);
-	}
-	else {
+	else
 		tex= add_texture("Texture");
-		ED_node_shader_default(&tex->id);
-		tex->use_nodes= 1;
-	}
 
 	/* hook into UI */
 	uiIDContextProperty(C, &ptr, &prop);
@@ -466,6 +466,7 @@
 
 static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
 {
+	Scene *scene= CTX_data_scene(C);
 	World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
 	PointerRNA ptr, idptr;
 	PropertyRNA *prop;
@@ -476,8 +477,11 @@
 	}
 	else {
 		wo= add_world("World");
-		ED_node_shader_default(&wo->id);
-		wo->use_nodes= 1;
+
+		if(scene_use_new_shading_nodes(scene)) {
+			ED_node_shader_default(scene, &wo->id);
+			wo->use_nodes= 1;
+		}
 	}
 
 	/* hook into UI */

Modified: branches/cycles/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- branches/cycles/source/blender/editors/space_buttons/buttons_context.c	2011-10-15 20:13:35 UTC (rev 41040)
+++ branches/cycles/source/blender/editors/space_buttons/buttons_context.c	2011-10-15 20:43:45 UTC (rev 41041)
@@ -234,13 +234,11 @@
 			if(for_texture && give_current_material_texture_node(ma))
 				return 1;
 			
-#if 0
 			ma= give_node_material(ma);
 			if(ma) {
 				RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
 				path->len++;
 			}			
-#endif
 			return 1;
 		}
 	}
@@ -371,139 +369,141 @@
 
 static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct)
 {
-	PointerRNA *ptr= &path->ptr[path->len-1];
-	ID *id;
+	if(ct) {
+		/* new shading system */
+		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 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(!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, 0);
-		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);
-	}
-	
-	if(ct->texture) {
-		RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
-		path->len++;
-	}
-
-	return 1;
-
-
-#if 0
-	Material *ma;
-	Lamp *la;
-	Brush *br;
-	World *wo;
-	ParticleSystem *psys;
-	Tex *tex;
-	PointerRNA *ptr= &path->ptr[path->len-1];
-	int orig_len = path->len;
-
-	/* if we already have a (pinned) texture, we're done */
-	if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
-		return 1;
-	}
-	/* try brush */
-	if((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) {
-		br= path->ptr[path->len-1].data;
+		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, 0);
+			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);
+		}
 		
-		if(br) {
-			tex= give_current_brush_texture(br);
-
-			RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+		if(ct->texture) {
+			RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
 			path->len++;
-			return 1;
 		}
+
+		return 1;
 	}
-	/* try world */
-	if((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
-		wo= path->ptr[path->len-1].data;
+	else {
+		/* old shading system */
+		Material *ma;
+		Lamp *la;
+		Brush *br;
+		World *wo;
+		ParticleSystem *psys;
+		Tex *tex;
+		PointerRNA *ptr= &path->ptr[path->len-1];
+		int orig_len = path->len;
 
-		if(wo && GS(wo->id.name)==ID_WO) {
-			tex= give_current_world_texture(wo);
-
-			RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
-			path->len++;
+		/* if we already have a (pinned) texture, we're done */
+		if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
 			return 1;
 		}
-	}
-	/* try particles */
-	if((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
-		if(path->ptr[path->len-1].type == &RNA_ParticleSettings) {
-			ParticleSettings *part = path->ptr[path->len-1].data;
+		/* try brush */
+		if((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) {
+			br= path->ptr[path->len-1].data;
+			
+			if(br) {
+				tex= give_current_brush_texture(br);
 
-			tex= give_current_particle_texture(part);
-			RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
-			path->len++;
-			return 1;
+				RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+				path->len++;
+				return 1;
+			}
 		}
-		else {
-			psys= path->ptr[path->len-1].data;
+		/* try world */
+		if((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
+			wo= path->ptr[path->len-1].data;
 
-			if(psys && psys->part && GS(psys->part->id.name)==ID_PA) {
-				tex= give_current_particle_texture(psys->part);
+			if(wo && GS(wo->id.name)==ID_WO) {
+				tex= give_current_world_texture(wo);
 
 				RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 				path->len++;
 				return 1;
 			}
 		}
-	}
-	/* try material */
-	if(buttons_context_path_material(path, 1)) {
-		ma= path->ptr[path->len-1].data;
+		/* try particles */
+		if((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
+			if(path->ptr[path->len-1].type == &RNA_ParticleSettings) {
+				ParticleSettings *part = path->ptr[path->len-1].data;
 
-		if(ma) {
-			tex= give_current_material_texture(ma);
+				tex= give_current_particle_texture(part);
+				RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+				path->len++;
+				return 1;
+			}
+			else {
+				psys= path->ptr[path->len-1].data;
 
-			RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
-			path->len++;
-			return 1;
+				if(psys && psys->part && GS(psys->part->id.name)==ID_PA) {
+					tex= give_current_particle_texture(psys->part);
+
+					RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+					path->len++;
+					return 1;
+				}
+			}
 		}
-	}
-	/* try lamp */
-	if(buttons_context_path_data(path, OB_LAMP)) {
-		la= path->ptr[path->len-1].data;
+		/* try material */
+		if(buttons_context_path_material(path, 1)) {
+			ma= path->ptr[path->len-1].data;
 
-		if(la) {
-			tex= give_current_lamp_texture(la);
+			if(ma) {
+				tex= give_current_material_texture(ma);
 
-			RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
-			path->len++;
-			return 1;
+				RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+				path->len++;
+				return 1;
+			}
 		}
-	}
-	/* try brushes again in case of no material, lamp, etc */
-	path->len = orig_len;
-	if(buttons_context_path_brush(path)) {
-		br= path->ptr[path->len-1].data;
-		
-		if(br) {
-			tex= give_current_brush_texture(br);
+		/* try lamp */
+		if(buttons_context_path_data(path, OB_LAMP)) {
+			la= path->ptr[path->len-1].data;
+
+			if(la) {
+				tex= give_current_lamp_texture(la);
+
+				RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+				path->len++;
+				return 1;
+			}
+		}
+		/* try brushes again in case of no material, lamp, etc */
+		path->len = orig_len;
+		if(buttons_context_path_brush(path)) {
+			br= path->ptr[path->len-1].data;
 			
-			RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
-			path->len++;
-			return 1;
+			if(br) {
+				tex= give_current_brush_texture(br);
+				
+				RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+				path->len++;
+				return 1;
+			}
 		}
 	}
-#endif
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list