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:
-rw-r--r--source/blender/blenkernel/BKE_linestyle.h3
-rw-r--r--source/blender/blenkernel/intern/linestyle.c33
-rw-r--r--source/blender/editors/space_node/node_edit.c12
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c2
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);
}