diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-07-16 10:25:10 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-08-12 05:10:22 +0400 |
commit | cb75f79b8a70fdae806e1ce57015cb8afb14c097 (patch) | |
tree | 50728dd8dc0242f785d19aea978163446312aaae | |
parent | 4e11fcead0f7262bf92e873882bf9141a749ff32 (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.
-rw-r--r-- | source/blender/blenkernel/BKE_linestyle.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/linestyle.c | 33 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_linestyle.c | 2 |
4 files changed, 37 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h index 82667cf78d9..ec13463927d 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 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); +} diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 7643c9c07b6..1cc2e41a570 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 f6f329e6b4d..e70a07b1a2a 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); } |