[Bf-blender-cvs] [cb75f79] master: Freestyle: Add BKE_linestyle_default_shader() for creating the default line style shader node tree.

Tamito Kajiyama noreply at git.blender.org
Tue Aug 12 03:17:22 CEST 2014


Commit: cb75f79b8a70fdae806e1ce57015cb8afb14c097
Author: Tamito Kajiyama
Date:   Wed Jul 16 15:25:10 2014 +0900
Branches: master
https://developer.blender.org/rBcb75f79b8a70fdae806e1ce57015cb8afb14c097

Freestyle: Add BKE_linestyle_default_shader() for creating the default line style shader node tree.

Changes to ED_node_shader_default() were reverted since the code there was actually
not suitable for setting up the default line style node tree properly.

===================================================================

M	source/blender/blenkernel/BKE_linestyle.h
M	source/blender/blenkernel/intern/linestyle.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/makesrna/intern/rna_linestyle.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h
index 82667cf..ec13463 100644
--- a/source/blender/blenkernel/BKE_linestyle.h
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@ -43,6 +43,7 @@
 struct Main;
 struct Object;
 struct ColorBand;
+struct bContext;
 
 FreestyleLineStyle *BKE_linestyle_new(const char *name, struct Main *main);
 void                BKE_linestyle_free(FreestyleLineStyle *linestyle);
@@ -75,4 +76,6 @@ char *BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, struct Col
 
 void BKE_linestyle_target_object_unlink(FreestyleLineStyle *linestyle, struct Object *ob);
 
+void BKE_linestyle_default_shader(const struct bContext *C, FreestyleLineStyle *linestyle);
+
 #endif  /* __BKE_LINESTYLE_H__ */
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 58ffe78..71e34e4 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -43,6 +43,7 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_context.h"
 #include "BKE_freestyle.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
@@ -52,6 +53,8 @@
 #include "BKE_colortools.h"
 #include "BKE_animsys.h"
 
+#include "RNA_access.h"
+
 static const char *modifier_name[LS_MODIFIER_NUM] = {
 	NULL,
 	"Along Stroke",
@@ -1150,3 +1153,33 @@ void BKE_linestyle_target_object_unlink(FreestyleLineStyle *linestyle, struct Ob
 		}
 	}
 }
+
+void BKE_linestyle_default_shader(const bContext *C, FreestyleLineStyle *linestyle)
+{
+	Scene *scene = CTX_data_scene(C);
+	bNode *input_texure, *output_linestyle;
+	bNodeSocket *fromsock, *tosock;
+	bNodeTree *ntree;
+
+	BLI_assert(linestyle->nodetree == NULL);
+
+	ntree = ntreeAddTree(NULL, "default_shader", "ShaderNodeTree");
+
+	linestyle->nodetree = ntree;
+
+	input_texure = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE);
+	input_texure->locx = 10.0f;
+	input_texure->locy = 300.0f;
+
+	output_linestyle = nodeAddStaticNode(C, ntree, SH_NODE_OUTPUT_LINESTYLE);
+	output_linestyle->locx = 300.0f;
+	output_linestyle->locy = 300.0f;
+
+	nodeSetActive(ntree, input_texure);
+
+	fromsock = (bNodeSocket *)BLI_findlink(&input_texure->outputs, 0); // Color
+	tosock = (bNodeSocket *)BLI_findlink(&output_linestyle->outputs, 0); // Color
+	nodeAddLink(ntree, input_texure, fromsock, output_linestyle, tosock);
+
+	ntreeUpdateTree(CTX_data_main(C), ntree);
+}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 7643c9c..1cc2e41 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -434,18 +434,6 @@ void ED_node_shader_default(const bContext *C, ID *id)
 				strength = 1.0f;
 			break;
 		}
-		case ID_LS:
-		{
-			FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
-			linestyle->nodetree = ntree;
-
-			output_type = SH_NODE_OUTPUT_LINESTYLE;
-			shader_type = SH_NODE_TEX_IMAGE;
-
-			copy_v3_v3(color, &linestyle->r);
-			strength = 1.0f;
-			break;
-		}
 		default:
 			printf("ED_node_shader_default called on wrong ID type.\n");
 			return;
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
index f6f329e..e70a07b 100644
--- a/source/blender/makesrna/intern/rna_linestyle.c
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -290,7 +290,7 @@ static void rna_LineStyle_use_nodes_update(bContext *C, PointerRNA *ptr)
 	FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->data;
 
 	if (linestyle->use_nodes && linestyle->nodetree == NULL)
-		ED_node_shader_default(C, &linestyle->id);
+		BKE_linestyle_default_shader(C, linestyle);
 
 	rna_LineStyle_update(CTX_data_main(C), CTX_data_scene(C), ptr);
 }




More information about the Bf-blender-cvs mailing list