diff options
author | Robin Allen <roblovski@gmail.com> | 2009-08-17 22:37:58 +0400 |
---|---|---|
committer | Robin Allen <roblovski@gmail.com> | 2009-08-17 22:37:58 +0400 |
commit | 55b6230464a140c62ec4cea4e11a4a05c8910d13 (patch) | |
tree | 54c9b5dff1a1f20388275f9e450969406f2af864 /source/blender/nodes/intern/TEX_nodes | |
parent | 6aeb2f687ae1d41715351ef265a0e0a9af06121a (diff) |
Made texture nodes accessible in the interface.
* Exposed Tex.use_nodes, Tex.nodetree, MTex.which_output in RNA
* Added node controls to texture buttons (Use Nodes and Use Output)
* Made new texture outputs have unique names by default, though unique names still aren't required.
Note: The preview window in the texture buttons only takes which_output into account when in "material" mode, and in the material half of "both" mode; the plain texture display ignores the user's output choice.
This is because ED_preview_draw draws a Tex* and not an MTex* -- still some work to do here.
Diffstat (limited to 'source/blender/nodes/intern/TEX_nodes')
-rw-r--r-- | source/blender/nodes/intern/TEX_nodes/TEX_output.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 060ea8d7e67..d0538d11900 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -64,11 +64,64 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) } } -static void init(bNode* node) +static void unique_name(bNode *node) { - TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); - strcpy(tno->name, "Default"); - node->storage= tno; + TexNodeOutput *tno = (TexNodeOutput *)node->storage; + char *new_name = 0; + int new_len; + int suffix; + bNode *i; + char *name = tno->name; + + i = node; + while(i->prev) i = i->prev; + for(; i; i=i->next) { + if( + i == node || + i->type != TEX_NODE_OUTPUT || + strcmp(name, ((TexNodeOutput*)(i->storage))->name) + ) + continue; + + if(!new_name) { + int len = strlen(name); + if(len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { + new_len = len; + } else { + suffix = 0; + new_len = len + 4; + if(new_len > 31) + new_len = 31; + } + + new_name = malloc(new_len + 1); + strcpy(new_name, name); + name = new_name; + } + sprintf(new_name + new_len - 4, ".%03d", ++suffix); + } + + if(new_name) { + strcpy(tno->name, new_name); + free(new_name); + } +} + +static void init(bNode *node) +{ + TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); + node->storage= tno; + + strcpy(tno->name, "Default"); + unique_name(node); + ntreeTexAssignIndex(0, node); +} + +static void copy(bNode *orig, bNode *new) +{ + node_copy_standard_storage(orig, new); + unique_name(new); + ntreeTexAssignIndex(0, new); } @@ -85,6 +138,6 @@ bNodeType tex_node_output= { /* butfunc */ NULL, /* initfunc */ init, /* freestoragefunc */ node_free_standard_storage, - /* copystoragefunc */ node_copy_standard_storage, + /* copystoragefunc */ copy, /* id */ NULL }; |