* 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.
This commit is contained in:
parent
b2bb9ca39a
commit
c0fae59c99
@ -162,6 +162,7 @@ void nodeVerifyType(struct bNodeTree *ntree, struct bNode *node);
|
||||
void nodeAddToPreview(struct bNode *, float *, int, int);
|
||||
|
||||
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
|
||||
void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
|
||||
void nodeAddSockets(struct bNode *node, struct bNodeType *ntype);
|
||||
struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type, struct bNodeTree *ngroup, struct ID *id);
|
||||
void nodeRegisterType(struct ListBase *typelist, const struct bNodeType *ntype) ;
|
||||
|
@ -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);
|
||||
|
@ -10037,6 +10037,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
sce= sce->id.next;
|
||||
}
|
||||
}
|
||||
{
|
||||
/* ensure all nodes have unique names */
|
||||
bNodeTree *ntree= main->nodetree.first;
|
||||
while(ntree) {
|
||||
bNode *node=ntree->nodes.first;
|
||||
|
||||
while(node) {
|
||||
nodeUniqueName(ntree, node);
|
||||
node= node->next;
|
||||
}
|
||||
|
||||
ntree= ntree->id.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
|
||||
|
@ -341,6 +341,13 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_NODE:
|
||||
switch(wmn->action) {
|
||||
case NA_EDITED:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
|
@ -417,6 +417,13 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_NODE:
|
||||
switch(wmn->action) {
|
||||
case NA_EDITED:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
|
@ -432,6 +432,13 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_NODE:
|
||||
switch(wmn->action) {
|
||||
case NA_EDITED:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
|
@ -719,12 +719,14 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
else
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
|
||||
if(node->flag & NODE_MUTED)
|
||||
sprintf(showname, "[%s]", node->name);
|
||||
else if(node->username[0])
|
||||
sprintf(showname, "(%s) %s", node->username, node->name);
|
||||
if(node->flag & NODE_CUSTOM_NAME)
|
||||
BLI_strncpy(showname, node->name, 32);
|
||||
else
|
||||
BLI_strncpy(showname, node->name, 128);
|
||||
/* todo: auto name display for node types */
|
||||
BLI_strncpy(showname, node->name, 32);
|
||||
|
||||
//if(node->flag & NODE_MUTED)
|
||||
// sprintf(showname, "[%s]", showname);
|
||||
|
||||
uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(rct->ymax-NODE_DY),
|
||||
(int)(iconofs - rct->xmin-18.0f), NODE_DY, NULL, 0, 0, 0, 0, "");
|
||||
@ -878,12 +880,15 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
||||
|
||||
if(node->miniwidth>0.0f) {
|
||||
|
||||
if(node->flag & NODE_MUTED)
|
||||
sprintf(showname, "[%s]", node->name);
|
||||
else if(node->username[0])
|
||||
sprintf(showname, "(%s)%s", node->username, node->name);
|
||||
else
|
||||
|
||||
if(node->flag & NODE_CUSTOM_NAME)
|
||||
BLI_strncpy(showname, node->name, 128);
|
||||
else
|
||||
/* todo: auto name display */
|
||||
BLI_strncpy(showname, node->name, 128);
|
||||
|
||||
//if(node->flag & NODE_MUTED)
|
||||
// sprintf(showname, "[%s]", showname);
|
||||
|
||||
uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(centy-10),
|
||||
(int)(rct->xmax - rct->xmin-18.0f -12.0f), NODE_DY, NULL, 0, 0, 0, 0, "");
|
||||
@ -1021,12 +1026,8 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
/* backdrop title */
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
|
||||
if(gnode->username[0]) {
|
||||
strcpy(showname,"(");
|
||||
strcat(showname, gnode->username);
|
||||
strcat(showname,") ");
|
||||
strcat(showname, ngroup->id.name+2);
|
||||
}
|
||||
if (gnode->flag & NODE_CUSTOM_NAME)
|
||||
strcat(showname, gnode->name);
|
||||
else
|
||||
strcpy(showname, ngroup->id.name+2);
|
||||
|
||||
|
@ -1251,6 +1251,8 @@ void NODE_OT_resize(wmOperatorType *ot)
|
||||
|
||||
/* ******************** rename ******************* */
|
||||
|
||||
|
||||
/* should go through RNA */
|
||||
void node_rename(SpaceNode *snode)
|
||||
{
|
||||
bNode *node, *rename_node;
|
||||
@ -1266,7 +1268,7 @@ void node_rename(SpaceNode *snode)
|
||||
|
||||
if(found_node) {
|
||||
rename_node= nodeGetActive(snode->edittree);
|
||||
node_rename_but((char *)rename_node->username);
|
||||
node_rename_but((char *)rename_node->name);
|
||||
|
||||
// allqueue(REDRAWNODE, 1);
|
||||
}
|
||||
|
@ -110,7 +110,6 @@ typedef struct bNode {
|
||||
struct bNode *next, *prev, *new_node;
|
||||
|
||||
char name[32];
|
||||
char username[32]; /* custom name defined by user */
|
||||
short type, flag;
|
||||
short done, level; /* both for dependency and sorting */
|
||||
short lasty, menunr; /* lasty: check preview render status, menunr: browse ID blocks */
|
||||
@ -152,6 +151,7 @@ typedef struct bNode {
|
||||
#define NODE_TEST 256
|
||||
/* composite: don't do node but pass on buffer(s) */
|
||||
#define NODE_MUTED 512
|
||||
#define NODE_CUSTOM_NAME 1024
|
||||
|
||||
typedef struct bNodeLink {
|
||||
struct bNodeLink *next, *prev;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -133,8 +133,8 @@ typedef struct wmNotifier {
|
||||
#define NC_WORLD (13<<24)
|
||||
#define NC_ANIMATION (14<<24)
|
||||
#define NC_SPACE (15<<24)
|
||||
#define NC_NODE (15<<24)
|
||||
#define NC_GEOM (16<<24)
|
||||
#define NC_NODE (17<<24)
|
||||
|
||||
/* data type, 256 entries is enough, it can overlap */
|
||||
#define NOTE_DATA 0x00FF0000
|
||||
@ -211,6 +211,10 @@ typedef struct wmNotifier {
|
||||
#define ND_SELECT (80<<16)
|
||||
#define ND_DATA (81<<16)
|
||||
|
||||
/* NC_NODE Nodes */
|
||||
#define ND_NODE_SELECT (1<<16)
|
||||
|
||||
|
||||
/* NC_SPACE */
|
||||
#define ND_SPACE_CONSOLE (1<<16) /* general redraw */
|
||||
#define ND_SPACE_CONSOLE_REPORT (2<<16) /* update for reports, could specify type */
|
||||
|
Loading…
Reference in New Issue
Block a user