diff options
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 44 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node_shaders.c | 56 |
4 files changed, 56 insertions, 58 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ad41e9a7fb7..33e253aa232 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -530,9 +530,10 @@ ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */ return 0; } -static void get_flags_for_id(ID *id, char *buf) { +static void get_flags_for_id(ID *id, char *buf) +{ int isfake= id->flag & LIB_FAKEUSER; - + int isnode=0; /* Writeout the flags for the entry, note there * is a small hack that writes 5 spaces instead * of 4 if no flags are displayed... this makes @@ -540,10 +541,15 @@ static void get_flags_for_id(ID *id, char *buf) { * to have that explicit, oh well - zr */ + if(GS(id->name)==ID_MA) + isnode= ((Material *)id)->use_nodes; + if (id->us<0) sprintf(buf, "-1W "); - else if (!id->lib && !isfake && id->us) + else if (!id->lib && !isfake && id->us && !isnode) sprintf(buf, " "); + else if(isnode) + sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); else sprintf(buf, "%c%c%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); } @@ -575,6 +581,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor sprintf(buf, "%%x%d", i+1); BLI_dynstr_append(pupds, buf); + /* icon */ switch(GS(id->name)) { case ID_MA: /* fall through */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 5054774f339..44420bc44b9 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -588,6 +588,7 @@ Material *get_active_matlayer(Material *ma) if(node && node->id) { return (Material *)node->id; } + return NULL; } else { MaterialLayer *ml; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index fbaa0b35c5e..c47572ffc43 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -35,6 +35,7 @@ #include "BKE_blender.h" #include "BKE_node.h" +#include "BKE_texture.h" #include "BKE_utildefines.h" #include "BLI_arithb.h" @@ -56,7 +57,7 @@ static bNodeType *nodeGetType(bNodeTree *ntree, int type) void ntreeInitTypes(bNodeTree *ntree) { - bNode *node; + bNode *node, *next; if(ntree->type==NTREE_SHADER) ntree->alltypes= node_all_shaders; @@ -65,10 +66,13 @@ void ntreeInitTypes(bNodeTree *ntree) printf("Error: no type definitions for nodes\n"); } - for(node= ntree->nodes.first; node; node= node->next) { + for(node= ntree->nodes.first; node; node= next) { + next= node->next; node->typeinfo= nodeGetType(ntree, node->type); - if(node->typeinfo==NULL) - printf("Error: no typeinfo for node %s\n", node->name); + if(node->typeinfo==NULL) { + printf("Error: Node type %s doesn't exist anymore, removed\n", node->name); + nodeFreeNode(ntree, node); + } } ntree->init |= NTREE_TYPE_INIT; @@ -199,7 +203,8 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type) node->type= ntype->type; node->flag= NODE_SELECT|ntype->flag; node->width= ntype->width; - + node->miniwidth= 15.0f; /* small value only, allows print of first chars */ + if(ntype->inputs) { stype= ntype->inputs; while(stype->type != -1) { @@ -214,6 +219,15 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type) stype++; } } + + /* need init handler later? */ + if(ntree->type==NTREE_SHADER) { + if(type==SH_NODE_MATERIAL) + node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC; + else if(node->type==SH_NODE_VALTORGB) + node->storage= add_colorband(1); + } + return node; } @@ -445,6 +459,26 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype) return node; } +/* two active flags, ID nodes have special flag for buttons display */ +void nodeSetActive(bNodeTree *ntree, bNode *node) +{ + bNode *tnode; + + /* make sure only one node is active, and only one per ID type */ + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { + tnode->flag &= ~NODE_ACTIVE; + + if(node->id && tnode->id) { + if(GS(node->id->name) == GS(tnode->id->name)) + tnode->flag &= ~NODE_ACTIVE_ID; + } + } + + node->flag |= NODE_ACTIVE; + if(node->id) + node->flag |= NODE_ACTIVE_ID; +} + /* ************** dependency stuff *********** */ /* node is guaranteed to be not checked before */ diff --git a/source/blender/blenkernel/intern/node_shaders.c b/source/blender/blenkernel/intern/node_shaders.c index f2ece280d58..220605fae53 100644 --- a/source/blender/blenkernel/intern/node_shaders.c +++ b/source/blender/blenkernel/intern/node_shaders.c @@ -63,29 +63,6 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(ShadeInput *, ShadeResult node_shader_lamp_loop= lamp_loop_func; } -/* **************** input node ************ */ - -static void node_shader_exec_input(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - if(data) { - ShadeResult *shr= ((ShaderCallData *)data)->shr; - ShadeInput *shi= ((ShaderCallData *)data)->shi; - float col[4]; - - /* stack order output sockets: color, alpha, normal */ - VecAddf(col, shr->diff, shr->spec); - col[3]= shr->alpha; - - VECCOPY(out[0]->vec, col); - out[1]->vec[0]= shr->alpha; - VECCOPY(out[2]->vec, shi->vn); - - if(shi->do_preview) - nodeAddToPreview(node, col, shi->xs, shi->ys); - - } -} - /* **************** output node ************ */ @@ -275,26 +252,6 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) /* Verification rule: If name changes, a saved socket and its links will be removed! Type changes are OK */ -/* *************** INPUT ********************* */ -static bNodeSocketType sh_node_input_out[]= { - { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { SOCK_VALUE, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static bNodeType sh_node_input= { - /* type code */ SH_NODE_INPUT, - /* name */ "Input", - /* width+range */ 80, 60, 200, - /* class+opts */ NODE_CLASS_INPUT, NODE_PREVIEW, - /* input sock */ NULL, - /* output sock */ sh_node_input_out, - /* storage */ "", - /* execfunc */ node_shader_exec_input, - -}; - /* **************** OUTPUT ******************** */ static bNodeSocketType sh_node_output_in[]= { { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, @@ -331,7 +288,7 @@ static bNodeSocketType sh_node_material_out[]= { static bNodeType sh_node_material= { /* type code */ SH_NODE_MATERIAL, /* name */ "Material", - /* width+range */ 120, 60, 200, + /* width+range */ 120, 80, 240, /* class+opts */ NODE_CLASS_GENERATOR, NODE_OPTIONS|NODE_PREVIEW, /* input sock */ sh_node_material_in, /* output sock */ sh_node_material_out, @@ -351,7 +308,7 @@ static bNodeSocketType sh_node_texture_out[]= { static bNodeType sh_node_texture= { /* type code */ SH_NODE_TEXTURE, /* name */ "Texture", - /* width+range */ 120, 60, 200, + /* width+range */ 120, 80, 240, /* class+opts */ NODE_CLASS_GENERATOR, NODE_OPTIONS|NODE_PREVIEW, /* input sock */ NULL, /* output sock */ sh_node_texture_out, @@ -380,7 +337,7 @@ static bNodeType sh_node_value= { /* **************** RGB ******************** */ static bNodeSocketType sh_node_rgb_out[]= { - { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Color", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; @@ -399,8 +356,8 @@ static bNodeType sh_node_rgb= { /* **************** MIX RGB ******************** */ static bNodeSocketType sh_node_mix_rgb_in[]= { { SOCK_VALUE, 1, "Fac", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 1, "Color1", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 1, "Color2", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, "Color1", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, "Color2", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; static bNodeSocketType sh_node_mix_rgb_out[]= { @@ -462,7 +419,7 @@ static bNodeType sh_node_rgbtobw= { /* class+opts */ NODE_CLASS_OPERATOR, 0, /* input sock */ sh_node_rgbtobw_in, /* output sock */ sh_node_rgbtobw_out, - /* storage */ "ColorBand", + /* storage */ "", /* execfunc */ node_shader_exec_rgbtobw, }; @@ -471,7 +428,6 @@ static bNodeType sh_node_rgbtobw= { /* ****************** types array for all shaders ****************** */ bNodeType *node_all_shaders[]= { - &sh_node_input, &sh_node_output, &sh_node_material, &sh_node_value, |