diff options
author | Matt Ebb <matt@mke3.net> | 2009-11-11 12:11:21 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2009-11-11 12:11:21 +0300 |
commit | c0fae59c99fdcb802b055c81d51ece6cf9ce5518 (patch) | |
tree | e6bb9f3a302e3e222a4fc84b2c1ca746946a9199 /source/blender/blenkernel/intern/node.c | |
parent | b2bb9ca39a687efc5dd1014e78650e39452d7cbf (diff) |
* Fixed nodetree animation by giving nodes unique names
Now the rna path to nodes happens via the node name, which is ensured to be unique via RNA.
As part of this, the node->username string has been removed, upon renaming the node itself it takes care of making sure it's unique (like bones, constraints, etc). There's currently no interactive rename tool, but you can do it via the datablocks editor.
- plus a few notifier tweaks, using the newer NC_NODE notifier to refresh graph editor etc.
Diffstat (limited to 'source/blender/blenkernel/intern/node.c')
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 708ef9829e1..1b0f1f28d2c 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -32,6 +32,7 @@ #endif #include <stdlib.h> +#include <stddef.h> #include <string.h> #include "DNA_ID.h" @@ -903,7 +904,11 @@ void nodeAddSockets(bNode *node, bNodeType *ntype) } } } - +/* Find the first available, non-duplicate name for a given node */ +void nodeUniqueName(bNodeTree *ntree, bNode *node) +{ + BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), 32); +} bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) { @@ -937,6 +942,9 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) } else BLI_strncpy(node->name, ntype->name, NODE_MAXSTR); + + nodeUniqueName(ntree, node); + node->type= ntype->type; node->flag= NODE_SELECT|ntype->flag; node->width= ntype->width; @@ -989,6 +997,8 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) bNodeSocket *sock, *oldsock; *nnode= *node; + nodeUniqueName(ntree, nnode); + BLI_addtail(&ntree->nodes, nnode); BLI_duplicatelist(&nnode->inputs, &node->inputs); |