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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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): Bob Holcomb, Xavier Thomas
27 * ***** END GPL LICENSE BLOCK *****
30 #ifndef DNA_NODE_TYPES_H
31 #define DNA_NODE_TYPES_H
33 /** \file DNA_node_types.h
38 #include "DNA_vec_types.h"
39 #include "DNA_listBase.h"
51 #define NODE_MAXSTR 32
53 typedef struct bNodeStack {
57 short hasinput; /* when input has link, tagged before executing */
58 short hasoutput; /* when output is linked, tagged before executing */
59 short datatype; /* type of data pointer */
60 short sockettype; /* type of socket stack comes from, to remap linking different sockets */
61 short is_copy; /* data is a copy of external data (no freeing) */
62 short external; /* data is used by external nodes (no freeing) */
66 /* ns->datatype, shadetree only */
67 #define NS_OSA_VECTORS 1
68 #define NS_OSA_VALUES 2
70 typedef struct bNodeSocket {
71 struct bNodeSocket *next, *prev, *new_sock;
75 void *storage; /* custom storage */
78 short limit; /* max. number of links */
83 void *default_value; /* default input value used for unlinked sockets */
86 short stack_index; /* local stack index */
87 short stack_type; /* deprecated, kept for forward compatibility */
89 void *cache; /* cached data from execution */
91 /* internal data to retrieve relations and groups */
92 int own_index; /* group socket identifiers, to find matching pairs after reading files */
93 int to_index; /* XXX deprecated, only used for restoring old group node links */
94 struct bNodeSocket *groupsock;
96 struct bNodeLink *link; /* a link pointer, set in ntreeUpdateTree */
98 /* DEPRECATED only needed for do_versions */
99 bNodeStack ns; /* custom data for inputs, only UI writes in this */
104 #define SOCK_VECTOR 1
106 #define SOCK_SHADER 3
107 #define SOCK_BOOLEAN 4
110 #define NUM_SOCKET_TYPES 7 /* must be last! */
112 /* socket side (input/output) */
116 /* sock->flag, first bit is select */
117 /* hidden is user defined, to hide unused */
118 #define SOCK_HIDDEN 2
119 /* only used now for groups... */
120 #define SOCK_IN_USE 4 /* XXX deprecated */
121 /* unavailable is for dynamic sockets */
122 #define SOCK_UNAVAIL 8
123 /* dynamic socket (can be modified by user) */
124 #define SOCK_DYNAMIC 16
125 /* group socket should not be exposed */
126 #define SOCK_INTERNAL 32
127 /* socket collapsed in UI */
128 #define SOCK_COLLAPSED 64
129 /* hide socket value, if it gets auto default */
130 #define SOCK_HIDE_VALUE 128
132 typedef struct bNodePreview {
138 /* limit data in bNode to what we want to see saved? */
139 typedef struct bNode {
140 struct bNode *next, *prev, *new_node;
144 short done, level; /* both for dependency and sorting */
145 short lasty, menunr; /* lasty: check preview render status, menunr: browse ID blocks */
146 short stack_index; /* for groupnode, offset in global caller stack */
147 short nr; /* number of this node in list, used for UI exec events */
149 ListBase inputs, outputs;
150 struct bNode *parent; /* parent node */
151 struct ID *id; /* optional link to libdata */
152 void *storage; /* custom data, must be struct, for storage in file */
154 float locx, locy; /* root offset for drawing */
155 float width, height; /* node custom width and height */
156 float miniwidth; /* node width if hidden */
158 char label[32]; /* custom user-defined label */
159 short custom1, custom2; /* to be abused for buttons */
160 float custom3, custom4;
162 short need_exec, exec; /* need_exec is set as UI execution event, exec is flag during exec */
163 void *threaddata; /* optional extra storage for use in thread (read only then!) */
165 rctf totr; /* entire boundbox */
166 rctf butr; /* optional buttons area */
167 rctf prvr; /* optional preview area */
168 bNodePreview *preview; /* optional preview image */
169 struct uiBlock *block; /* runtime during drawing */
171 struct bNodeType *typeinfo; /* lookup of callbacks and defaults */
175 #define NODE_SELECT 1
176 #define NODE_OPTIONS 2
177 #define NODE_PREVIEW 4
178 #define NODE_HIDDEN 8
179 #define NODE_ACTIVE 16
180 #define NODE_ACTIVE_ID 32
181 #define NODE_DO_OUTPUT 64
182 #define NODE_GROUP_EDIT 128
183 /* free test flag, undefined */
184 #define NODE_TEST 256
185 /* composite: don't do node but pass on buffer(s) */
186 #define NODE_MUTED 512
187 #define NODE_CUSTOM_NAME 1024 /* deprecated! */
188 /* group node types: use const outputs by default */
189 #define NODE_CONST_OUTPUT (1<<11)
190 /* node is always behind others */
191 #define NODE_BACKGROUND (1<<12)
192 /* automatic flag for nodes included in transforms */
193 #define NODE_TRANSFORM (1<<13)
195 typedef struct bNodeLink {
196 struct bNodeLink *next, *prev;
198 bNode *fromnode, *tonode;
199 bNodeSocket *fromsock, *tosock;
206 #define NODE_LINKFLAG_HILITE 1 /* link has been successfully validated */
207 #define NODE_LINK_VALID 2
209 /* the basis for a Node tree, all links and nodes reside internal here */
210 /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */
211 typedef struct bNodeTree {
213 struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
215 struct bGPdata *gpd; /* grease pencil data */
217 ListBase nodes, links;
219 int type, init; /* set init on fileread */
220 int cur_index; /* sockets in groups have unique identifiers, adding new sockets always
221 will increase this counter */
223 int update; /* update flags */
225 int nodetype; /* specific node type this tree is used for */
227 ListBase inputs, outputs; /* external sockets for group nodes */
230 /* XXX It would be preferable to completely move this data out of the underlying node tree,
231 * so node tree execution could finally run independent of the tree itself. This would allow node trees
232 * to be merely linked by other data (materials, textures, etc.), as ID data is supposed to.
233 * Execution data is generated from the tree once at execution start and can then be used
234 * as long as necessary, even while the tree is being modified.
236 struct bNodeTreeExec *execdata;
239 void (*progress)(void *, float progress);
240 void (*stats_draw)(void *, char *str);
241 int (*test_break)(void *);
242 void *tbh, *prh, *sdh;
246 /* ntree->type, index */
247 #define NTREE_SHADER 0
248 #define NTREE_COMPOSIT 1
249 #define NTREE_TEXTURE 2
250 #define NUM_NTREE_TYPES 3
252 /* ntree->init, flag */
253 #define NTREE_TYPE_INIT 1
256 #define NTREE_DS_EXPAND 1 /* for animation editors */
257 /* XXX not nice, but needed as a temporary flags
258 * for group updates after library linking.
260 #define NTREE_DO_VERSIONS_GROUP_EXPOSE 1024
263 #define NTREE_UPDATE 0xFFFF /* generic update flag (includes all others) */
264 #define NTREE_UPDATE_LINKS 1 /* links have been added or removed */
265 #define NTREE_UPDATE_NODES 2 /* nodes or sockets have been added or removed */
266 #define NTREE_UPDATE_GROUP_IN 16 /* group inputs have changed */
267 #define NTREE_UPDATE_GROUP_OUT 32 /* group outputs have changed */
268 #define NTREE_UPDATE_GROUP 48 /* group has changed (generic flag including all other group flags) */
271 /* socket value structs for input buttons */
273 typedef struct bNodeSocketValueInt {
274 int subtype; /* RNA subtype */
277 } bNodeSocketValueInt;
279 typedef struct bNodeSocketValueFloat {
280 int subtype; /* RNA subtype */
283 } bNodeSocketValueFloat;
285 typedef struct bNodeSocketValueBoolean {
288 } bNodeSocketValueBoolean;
290 typedef struct bNodeSocketValueVector {
291 int subtype; /* RNA subtype */
294 } bNodeSocketValueVector;
296 typedef struct bNodeSocketValueRGBA {
298 } bNodeSocketValueRGBA;
301 /* data structs, for node->storage */
303 /* this one has been replaced with ImageUser, keep it for do_versions() */
304 typedef struct NodeImageAnim {
305 int frames, sfra, nr;
310 typedef struct NodeBlurData {
312 short samples, maxspeed, minspeed, relative, aspect;
314 float fac, percentx, percenty;
317 int image_in_width, image_in_height; /* needed for absolute/relative conversions */
320 typedef struct NodeDBlurData {
321 float center_x, center_y, distance, angle, spin, zoom;
326 typedef struct NodeBilateralBlurData {
327 float sigma_color, sigma_space;
329 } NodeBilateralBlurData;
331 typedef struct NodeHueSat {
335 typedef struct NodeImageFile {
337 short imtype, subimtype, quality, codec;
341 typedef struct NodeChroma {
343 float fsize,fstrength,falpha;
345 short algorithm, channel;
348 typedef struct NodeTwoXYs {
349 short x1, x2, y1, y2;
350 float fac_x1, fac_x2, fac_y1, fac_y2;
353 typedef struct NodeTwoFloats {
357 typedef struct NodeGeometry {
362 typedef struct NodeVertexCol {
366 /* qdn: Defocus blur node */
367 typedef struct NodeDefocus {
368 char bktype, rotation, preview, gamco;
369 short samples, no_zbuf;
370 float fstop, maxblur, bthresh, scale;
373 typedef struct NodeScriptDict {
374 void *dict; /* for PyObject *dict */
375 void *node; /* for BPy_Node *node */
378 /* qdn: glare node */
379 typedef struct NodeGlare {
380 char quality, type, iter;
381 char angle, angle_ofs, size, pad[2];
382 float colmod, mix, threshold, fade;
385 /* qdn: tonemap node */
386 typedef struct NodeTonemap {
387 float key, offset, gamma;
392 /* qdn: lens distortion node */
393 typedef struct NodeLensDist {
394 short jit, proj, fit, pad;
397 typedef struct NodeColorBalance {
403 /* for ui representation */
408 /* temp storage for inverted lift */
413 typedef struct NodeColorspill {
414 short limchan, unspill;
416 float uspillr, uspillg, uspillb;
420 typedef struct TexNodeOutput {
424 /* comp channel matte */
425 #define CMP_NODE_CHANNEL_MATTE_CS_RGB 1
426 #define CMP_NODE_CHANNEL_MATTE_CS_HSV 2
427 #define CMP_NODE_CHANNEL_MATTE_CS_YUV 3
428 #define CMP_NODE_CHANNEL_MATTE_CS_YCC 4
430 #define CMP_NODE_BLUR_ASPECT_NONE 0
431 #define CMP_NODE_BLUR_ASPECT_Y 1
432 #define CMP_NODE_BLUR_ASPECT_X 2