4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2005 Blender Foundation.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
30 #ifndef DNA_NODE_TYPES_H
31 #define DNA_NODE_TYPES_H
33 #include "DNA_vec_types.h"
34 #include "DNA_listBase.h"
43 #define NODE_MAXSTR 32
46 typedef struct bNodeStack {
48 float min, max; /* min/max for values (UI writes it, execute might use it) */
50 short hasinput; /* when input has link, tagged before executing */
51 short hasoutput; /* when output is linked, tagged before executing */
52 short datatype; /* type of data pointer */
56 /* ns->datatype, shadetree only */
57 #define NS_OSA_VECTORS 1
58 #define NS_OSA_VALUES 2
60 typedef struct bNodeSocket {
61 struct bNodeSocket *next, *prev;
64 bNodeStack ns; /* custom data for inputs, only UI writes in this */
66 short type, flag; /* type is copy from socket type struct */
67 short limit, stack_index; /* limit for dependency sort, stack_index for exec */
68 short intern; /* intern = tag for group nodes */
69 short stack_index_ext; /* for groups, to find the caller stack index */
74 /* internal data to retrieve relations and groups */
76 int own_index, to_index; /* group socket identifiers, to find matching pairs after reading files */
78 struct bNodeSocket *tosock; /* group-node sockets point to the internal group counterpart sockets, set after read file */
79 struct bNodeLink *link; /* a link pointer, set in nodeSolveOrder() */
89 /* sock->flag, first bit is select */
91 /* only used now for groups... */
96 typedef struct bNodePreview {
102 /* limit data in bNode to what we want to see saved? */
103 typedef struct bNode {
104 struct bNode *next, *prev, *new;
108 short done, level; /* both for dependency and sorting */
109 short lasty, menunr; /* lasty: check preview render status, menunr: browse ID blocks */
110 short stack_index; /* for groupnode, offset in global caller stack */
113 ListBase inputs, outputs;
114 struct ID *id; /* optional link to libdata */
115 void *storage; /* custom data, must be struct, for storage in file */
116 struct uiBlock *block; /* each node has own block */
118 float locx, locy; /* root offset for drawing */
119 float width, miniwidth;
120 short custom1, custom2; /* to be abused for buttons */
123 rctf totr; /* entire boundbox */
124 rctf butr; /* optional buttons area */
125 rctf prvr; /* optional preview area */
126 bNodePreview *preview; /* optional preview image */
128 struct bNodeType *typeinfo; /* lookup of callbacks and defaults */
133 #define NODE_SELECT 1
134 #define NODE_OPTIONS 2
135 #define NODE_PREVIEW 4
136 #define NODE_HIDDEN 8
137 #define NODE_ACTIVE 16
138 #define NODE_ACTIVE_ID 32
139 #define NODE_DO_OUTPUT 64
140 #define NODE_GROUP_EDIT 128
142 typedef struct bNodeLink {
143 struct bNodeLink *next, *prev;
145 bNode *fromnode, *tonode;
146 bNodeSocket *fromsock, *tosock;
150 /* the basis for a Node tree, all links and nodes reside internal here */
151 /* only re-usable node trees are in the library though, materials allocate own tree struct */
152 typedef struct bNodeTree {
155 ListBase nodes, links;
157 bNodeStack *stack; /* stack is only while executing, no read/write in file */
158 bNodeStack *stack1; /* for other thread, easy to expand though... */
160 int type, init; /* set init on fileread */
161 int stacksize; /* amount of elements in stack */
162 int cur_index; /* sockets in groups have unique identifiers, adding new sockets always will increase this counter */
163 struct bNodeType **alltypes; /* type definitions, set on fileread, no read/write */
164 struct bNodeType *owntype; /* for groups or dynamic trees, no read/write */
168 /* ntree->type, index */
169 #define NTREE_SHADER 0
170 #define NTREE_COMPOSIT 1
172 /* ntree->init, flag */
173 #define NTREE_TYPE_INIT 1
174 #define NTREE_EXEC_INIT 2