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.
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
struct Main;
|
struct Main;
|
||||||
struct Object;
|
struct Object;
|
||||||
struct ColorBand;
|
struct ColorBand;
|
||||||
|
struct bContext;
|
||||||
|
|
||||||
FreestyleLineStyle *BKE_linestyle_new(const char *name, struct Main *main);
|
FreestyleLineStyle *BKE_linestyle_new(const char *name, struct Main *main);
|
||||||
void BKE_linestyle_free(FreestyleLineStyle *linestyle);
|
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_target_object_unlink(FreestyleLineStyle *linestyle, struct Object *ob);
|
||||||
|
|
||||||
|
void BKE_linestyle_default_shader(const struct bContext *C, FreestyleLineStyle *linestyle);
|
||||||
|
|
||||||
#endif /* __BKE_LINESTYLE_H__ */
|
#endif /* __BKE_LINESTYLE_H__ */
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
|
#include "BKE_context.h"
|
||||||
#include "BKE_freestyle.h"
|
#include "BKE_freestyle.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_library.h"
|
#include "BKE_library.h"
|
||||||
@@ -52,6 +53,8 @@
|
|||||||
#include "BKE_colortools.h"
|
#include "BKE_colortools.h"
|
||||||
#include "BKE_animsys.h"
|
#include "BKE_animsys.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
static const char *modifier_name[LS_MODIFIER_NUM] = {
|
static const char *modifier_name[LS_MODIFIER_NUM] = {
|
||||||
NULL,
|
NULL,
|
||||||
"Along Stroke",
|
"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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -434,18 +434,6 @@ void ED_node_shader_default(const bContext *C, ID *id)
|
|||||||
strength = 1.0f;
|
strength = 1.0f;
|
||||||
break;
|
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:
|
default:
|
||||||
printf("ED_node_shader_default called on wrong ID type.\n");
|
printf("ED_node_shader_default called on wrong ID type.\n");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ static void rna_LineStyle_use_nodes_update(bContext *C, PointerRNA *ptr)
|
|||||||
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->data;
|
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->data;
|
||||||
|
|
||||||
if (linestyle->use_nodes && linestyle->nodetree == NULL)
|
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);
|
rna_LineStyle_update(CTX_data_main(C), CTX_data_scene(C), ptr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user