Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-12-29 21:08:01 +0300
committerTon Roosendaal <ton@blender.org>2005-12-29 21:08:01 +0300
commit8d352139909653e881c99205e71f34f689ff6292 (patch)
tree67422d1dd33125eca2c064a10448f5829af0fc46 /source/blender/blenkernel/intern/node.c
parentfa24217b2c49f293b18d52db1bc7eb6b7c78a54e (diff)
More node goodies!
First note; this is a WIP project, some commits might change things that make formerly saved situations not to work identically... like now! ------ New Material integration ------ Until now, the Node system worked on top of the 'current' Material, just like how the Material Layers worked. That's quite confusing in practice, especially to see what Material is a Node, or what is the "base material" Best solution is to completely separate the two. This has been implemented as follows now; - The confusing "Input" node has been removed. - When choosing a Material in Blender, you can define this Material to be either 'normal' (default) or be the root of a Node tree. - If a Material is a Node tree, you have to add Nodes in the tree to see something happen. An empty Node tree doesn't do anything (black). - If a Material is a Node Tree, the 'data browse' menus show it with an 'N' mark before the name. The 'data block' buttons display it with the suffix 'NT' (instead of 'MA'). - In a Node Tree, any Material can be inserted, including itself. Only in that case the Material is being used itself for shading. UI changes: Added a new Panel "Links", which shows: - where the Material is linked to (Object, Mesh, etc) - if the Material is a NodeTree or not - the actual active Material in the Tree The "Node" Panel itself now only shows buttons from the other nodes, when they are active. Further the Material Nodes themselves allow browsing and renaming or adding new Materials now too. Second half of today's work was cleaning up selection when the Nodes overlap... it was possible to drag links from invisible sockets, or click headers for invisible nodes, etc. This because the mouse input code was not checking for visibility yet. Works now even for buttons. :)
Diffstat (limited to 'source/blender/blenkernel/intern/node.c')
-rw-r--r--source/blender/blenkernel/intern/node.c44
1 files changed, 39 insertions, 5 deletions
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 */