Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-07-16 10:25:10 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-08-12 05:10:22 +0400
commitcb75f79b8a70fdae806e1ce57015cb8afb14c097 (patch)
tree50728dd8dc0242f785d19aea978163446312aaae /source/blender/blenkernel/intern/linestyle.c
parent4e11fcead0f7262bf92e873882bf9141a749ff32 (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/linestyle.c')
-rw-r--r--source/blender/blenkernel/intern/linestyle.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 58ffe783178..71e34e4f1a7 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);
+}