2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2005-12-18 13:46:01 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-12-18 13:46:01 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
2009-09-10 04:12:22 +00:00
|
|
|
* Contributor(s): Bob Holcomb.
|
2005-12-18 13:46:01 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/node.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
2011-02-21 13:47:49 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2005-12-18 13:46:01 +00:00
|
|
|
#include <stdlib.h>
|
2009-11-11 09:11:21 +00:00
|
|
|
#include <stddef.h>
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
#include <string.h>
|
2011-02-25 11:25:11 +00:00
|
|
|
#include <limits.h>
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2011-11-02 19:24:30 +00:00
|
|
|
#include "DNA_action_types.h"
|
2010-01-27 05:42:17 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2012-12-03 16:21:43 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
2011-02-21 13:47:49 +00:00
|
|
|
#include "DNA_node_types.h"
|
2011-11-02 19:24:30 +00:00
|
|
|
#include "DNA_node_types.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2012-12-03 16:21:43 +00:00
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
#include "DNA_world_types.h"
|
2011-02-21 13:47:49 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BLI_string.h"
|
|
|
|
#include "BLI_math.h"
|
2011-02-21 13:47:49 +00:00
|
|
|
#include "BLI_listbase.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BLI_path_util.h"
|
|
|
|
#include "BLI_utildefines.h"
|
2010-01-27 05:42:17 +00:00
|
|
|
|
2012-03-17 14:42:44 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
2010-12-29 11:51:53 +00:00
|
|
|
#include "BKE_animsys.h"
|
|
|
|
#include "BKE_action.h"
|
2010-01-27 05:42:17 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BKE_global.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "BKE_idprop.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2011-02-07 09:33:36 +00:00
|
|
|
#include "BKE_node.h"
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "BLI_ghash.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "RNA_access.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "RNA_define.h"
|
2007-03-24 18:41:54 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "NOD_socket.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "NOD_common.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "NOD_composite.h"
|
|
|
|
#include "NOD_shader.h"
|
|
|
|
#include "NOD_texture.h"
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
/* Fallback types for undefined tree, nodes, sockets */
|
|
|
|
bNodeTreeType NodeTreeTypeUndefined;
|
|
|
|
bNodeType NodeTypeUndefined;
|
|
|
|
bNodeSocketType NodeSocketTypeUndefined;
|
|
|
|
|
2007-03-26 15:07:38 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocketTemplate *sockdef;
|
|
|
|
/* bNodeSocket *sock; */ /* UNUSED */
|
|
|
|
|
|
|
|
if (ntype->inputs) {
|
|
|
|
sockdef = ntype->inputs;
|
|
|
|
while (sockdef->type != -1) {
|
|
|
|
/* sock = */ node_add_socket_from_template(ntree, node, sockdef, SOCK_IN);
|
|
|
|
|
|
|
|
sockdef++;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntype->outputs) {
|
|
|
|
sockdef = ntype->outputs;
|
|
|
|
while (sockdef->type != -1) {
|
|
|
|
/* sock = */ node_add_socket_from_template(ntree, node, sockdef, SOCK_OUT);
|
|
|
|
|
|
|
|
sockdef++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: This function is called to initialize node data based on the type.
|
|
|
|
* The bNodeType may not be registered at creation time of the node,
|
|
|
|
* so this can be delayed until the node type gets registered.
|
|
|
|
*/
|
|
|
|
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
|
|
|
bNodeType *ntype = node->typeinfo;
|
2013-03-19 13:40:16 +00:00
|
|
|
if (ntype == &NodeTypeUndefined)
|
2013-03-18 16:34:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* only do this once */
|
|
|
|
if (node->flag & NODE_INIT)
|
|
|
|
return;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-05-29 15:14:09 +00:00
|
|
|
node->flag = NODE_SELECT | NODE_OPTIONS | ntype->flag;
|
2013-03-18 16:34:57 +00:00
|
|
|
node->width = ntype->width;
|
|
|
|
node->miniwidth = 42.0f;
|
|
|
|
node->height = ntype->height;
|
|
|
|
node->color[0] = node->color[1] = node->color[2] = 0.608; /* default theme color */
|
|
|
|
|
|
|
|
/* initialize the node name with the node label.
|
|
|
|
* note: do this after the initfunc so nodes get their data set which may be used in naming
|
|
|
|
* (node groups for example) */
|
2013-03-26 14:33:53 +00:00
|
|
|
/* XXX Do not use nodeLabel() here, it returns translated content for UI, which should *only* be used
|
|
|
|
* in UI, *never* in data... Data have their own translation option!
|
2013-03-18 16:34:57 +00:00
|
|
|
* This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
|
2013-03-26 14:33:53 +00:00
|
|
|
* than adding "do_translate" flags to this func (and labelfunc() as well). */
|
|
|
|
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
|
2013-03-18 16:34:57 +00:00
|
|
|
nodeUniqueName(ntree, node);
|
|
|
|
|
|
|
|
node_add_sockets_from_type(ntree, node, ntype);
|
|
|
|
|
|
|
|
if (ntype->initfunc != NULL)
|
|
|
|
ntype->initfunc(ntree, node);
|
|
|
|
|
|
|
|
/* extra init callback */
|
|
|
|
if (ntype->initfunc_api) {
|
|
|
|
PointerRNA ptr;
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
|
|
|
|
|
|
|
|
/* XXX Warning: context can be NULL in case nodes are added in do_versions.
|
|
|
|
* Delayed init is not supported for nodes with context-based initfunc_api atm.
|
|
|
|
*/
|
|
|
|
BLI_assert(C != NULL);
|
|
|
|
ntype->initfunc_api(C, &ptr);
|
|
|
|
}
|
|
|
|
|
2013-06-12 11:26:44 +00:00
|
|
|
if (node->id)
|
|
|
|
id_us_plus(node->id);
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node->flag |= NODE_INIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo)
|
|
|
|
{
|
|
|
|
if (typeinfo) {
|
2013-03-19 13:40:16 +00:00
|
|
|
ntree->typeinfo = typeinfo;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* deprecated integer type */
|
|
|
|
ntree->type = typeinfo->type;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-03-19 13:40:16 +00:00
|
|
|
ntree->typeinfo = &NodeTreeTypeUndefined;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree->init &= ~NTREE_TYPE_INIT;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_set_typeinfo(const struct bContext *C, bNodeTree *ntree, bNode *node, bNodeType *typeinfo)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
if (typeinfo) {
|
2013-03-19 13:40:16 +00:00
|
|
|
node->typeinfo = typeinfo;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* deprecated integer type */
|
|
|
|
node->type = typeinfo->type;
|
|
|
|
|
|
|
|
/* initialize the node if necessary */
|
|
|
|
node_init(C, ntree, node);
|
|
|
|
}
|
|
|
|
else {
|
2013-03-19 13:40:16 +00:00
|
|
|
node->typeinfo = &NodeTypeUndefined;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree->init &= ~NTREE_TYPE_INIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_socket_set_typeinfo(bNodeTree *ntree, bNodeSocket *sock, bNodeSocketType *typeinfo)
|
|
|
|
{
|
|
|
|
if (typeinfo) {
|
2013-03-19 13:40:16 +00:00
|
|
|
sock->typeinfo = typeinfo;
|
2013-04-02 11:59:27 +00:00
|
|
|
|
|
|
|
/* deprecated integer type */
|
|
|
|
sock->type = typeinfo->type;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (sock->default_value == NULL) {
|
|
|
|
/* initialize the default_value pointer used by standard socket types */
|
|
|
|
node_socket_init_default_value(sock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-03-19 13:40:16 +00:00
|
|
|
sock->typeinfo = &NodeSocketTypeUndefined;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree->init &= ~NTREE_TYPE_INIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set specific typeinfo pointers in all node trees on register/unregister */
|
|
|
|
static void update_typeinfo(Main *bmain, const struct bContext *C, bNodeTreeType *treetype, bNodeType *nodetype, bNodeSocketType *socktype, bool unregister)
|
|
|
|
{
|
|
|
|
if (!bmain)
|
|
|
|
return;
|
|
|
|
|
|
|
|
FOREACH_NODETREE(bmain, ntree, id) {
|
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
|
|
|
|
ntree->init |= NTREE_TYPE_INIT;
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
if (treetype && STREQ(ntree->idname, treetype->idname))
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree_set_typeinfo(ntree, unregister ? NULL : treetype);
|
|
|
|
|
|
|
|
/* initialize nodes */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (nodetype && STREQ(node->idname, nodetype->idname))
|
2013-03-18 16:34:57 +00:00
|
|
|
node_set_typeinfo(C, ntree, node, unregister ? NULL : nodetype);
|
|
|
|
|
|
|
|
/* initialize node sockets */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next)
|
|
|
|
if (socktype && STREQ(sock->idname, socktype->idname))
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next)
|
|
|
|
if (socktype && STREQ(sock->idname, socktype->idname))
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize tree sockets */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = ntree->inputs.first; sock; sock = sock->next)
|
|
|
|
if (socktype && STREQ(sock->idname, socktype->idname))
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = ntree->outputs.first; sock; sock = sock->next)
|
|
|
|
if (socktype && STREQ(sock->idname, socktype->idname))
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
|
|
|
|
}
|
|
|
|
FOREACH_NODETREE_END
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to initialize all typeinfo in a node tree.
|
|
|
|
* NB: In general undefined typeinfo is a perfectly valid case, the type may just be registered later.
|
|
|
|
* In that case the update_typeinfo function will set typeinfo on registration
|
|
|
|
* and do necessary updates.
|
|
|
|
*/
|
|
|
|
void ntreeSetTypes(const struct bContext *C, bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
|
|
|
|
ntree->init |= NTREE_TYPE_INIT;
|
|
|
|
|
|
|
|
ntree_set_typeinfo(ntree, ntreeTypeFind(ntree->idname));
|
|
|
|
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
node_set_typeinfo(C, ntree, node, nodeTypeFind(node->idname));
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next)
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next)
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = ntree->inputs.first; sock; sock = sock->next)
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = ntree->outputs.first; sock; sock = sock->next)
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
static GHash *nodetreetypes_hash = NULL;
|
|
|
|
static GHash *nodetypes_hash = NULL;
|
|
|
|
static GHash *nodesockettypes_hash = NULL;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
bNodeTreeType *ntreeTypeFind(const char *idname)
|
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
bNodeTreeType *nt;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
if (idname[0]) {
|
2013-03-18 18:25:05 +00:00
|
|
|
nt = BLI_ghash_lookup(nodetreetypes_hash, idname);
|
|
|
|
if (nt)
|
2013-03-18 16:34:57 +00:00
|
|
|
return nt;
|
|
|
|
}
|
|
|
|
|
2011-02-21 13:47:49 +00:00
|
|
|
return NULL;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
void ntreeTypeAdd(bNodeTreeType *nt)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
|
|
|
BLI_ghash_insert(nodetreetypes_hash, (void *)nt->idname, nt);
|
|
|
|
/* XXX pass Main to register function? */
|
|
|
|
update_typeinfo(G.main, NULL, nt, NULL, NULL, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* callback for hash value free function */
|
|
|
|
static void ntree_free_type(void *treetype_v)
|
|
|
|
{
|
|
|
|
bNodeTreeType *treetype = treetype_v;
|
|
|
|
/* XXX pass Main to unregister function? */
|
|
|
|
update_typeinfo(G.main, NULL, treetype, NULL, NULL, true);
|
|
|
|
MEM_freeN(treetype);
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
void ntreeTypeFreeLink(bNodeTreeType *nt)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
|
|
|
BLI_ghash_remove(nodetreetypes_hash, nt->idname, NULL, ntree_free_type);
|
|
|
|
}
|
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
bool ntreeIsRegistered(bNodeTree *ntree)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
2013-03-19 13:40:16 +00:00
|
|
|
return (ntree->typeinfo != &NodeTreeTypeUndefined);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
GHashIterator *ntreeTypeGetIterator(void)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-19 13:40:16 +00:00
|
|
|
return BLI_ghashIterator_new(nodetreetypes_hash);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeType *nodeTypeFind(const char *idname)
|
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
bNodeType *nt;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
if (idname[0]) {
|
2013-03-18 18:25:05 +00:00
|
|
|
nt = BLI_ghash_lookup(nodetypes_hash, idname);
|
|
|
|
if (nt)
|
2013-03-18 16:34:57 +00:00
|
|
|
return nt;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_dynamic_typeinfo(bNodeType *ntype)
|
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
if (ntype->type == NODE_DYNAMIC) {
|
|
|
|
if (ntype->inputs) {
|
2013-03-18 16:34:57 +00:00
|
|
|
MEM_freeN(ntype->inputs);
|
|
|
|
}
|
2013-03-18 18:25:05 +00:00
|
|
|
if (ntype->outputs) {
|
2013-03-18 16:34:57 +00:00
|
|
|
MEM_freeN(ntype->outputs);
|
|
|
|
}
|
2013-03-18 18:25:05 +00:00
|
|
|
if (ntype->ui_name) {
|
2013-03-18 16:34:57 +00:00
|
|
|
MEM_freeN((void *)ntype->ui_name);
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* callback for hash value free function */
|
|
|
|
static void node_free_type(void *nodetype_v)
|
|
|
|
{
|
|
|
|
bNodeType *nodetype = nodetype_v;
|
|
|
|
/* XXX pass Main to unregister function? */
|
|
|
|
update_typeinfo(G.main, NULL, NULL, nodetype, NULL, true);
|
|
|
|
|
|
|
|
/* XXX deprecated */
|
2013-03-18 18:25:05 +00:00
|
|
|
if (nodetype->type == NODE_DYNAMIC)
|
2013-03-18 16:34:57 +00:00
|
|
|
free_dynamic_typeinfo(nodetype);
|
|
|
|
|
|
|
|
if (nodetype->needs_free)
|
|
|
|
MEM_freeN(nodetype);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nodeRegisterType(bNodeType *nt)
|
|
|
|
{
|
|
|
|
/* debug only: basic verification of registered types */
|
|
|
|
BLI_assert(nt->idname[0] != '\0');
|
|
|
|
BLI_assert(nt->poll != NULL);
|
|
|
|
|
|
|
|
BLI_ghash_insert(nodetypes_hash, (void *)nt->idname, nt);
|
|
|
|
/* XXX pass Main to register function? */
|
|
|
|
update_typeinfo(G.main, NULL, NULL, nt, NULL, false);
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
void nodeUnregisterType(bNodeType *nt)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
|
|
|
BLI_ghash_remove(nodetypes_hash, nt->idname, NULL, node_free_type);
|
|
|
|
}
|
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
bool nodeIsRegistered(bNode *node)
|
|
|
|
{
|
|
|
|
return (node->typeinfo != &NodeTypeUndefined);
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
GHashIterator *nodeTypeGetIterator(void)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
|
|
|
return BLI_ghashIterator_new(nodetypes_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeSocketType *nodeSocketTypeFind(const char *idname)
|
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
bNodeSocketType *st;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
if (idname[0]) {
|
2013-03-18 18:25:05 +00:00
|
|
|
st = BLI_ghash_lookup(nodesockettypes_hash, idname);
|
|
|
|
if (st)
|
2013-03-18 16:34:57 +00:00
|
|
|
return st;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
return NULL;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* callback for hash value free function */
|
|
|
|
static void node_free_socket_type(void *socktype_v)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocketType *socktype = socktype_v;
|
|
|
|
/* XXX pass Main to unregister function? */
|
|
|
|
update_typeinfo(G.main, NULL, NULL, NULL, socktype, true);
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
MEM_freeN(socktype);
|
|
|
|
}
|
2008-02-09 23:17:15 +00:00
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
void nodeRegisterSocketType(bNodeSocketType *st)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
|
|
|
BLI_ghash_insert(nodesockettypes_hash, (void *)st->idname, st);
|
|
|
|
/* XXX pass Main to register function? */
|
|
|
|
update_typeinfo(G.main, NULL, NULL, NULL, st, false);
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
void nodeUnregisterSocketType(bNodeSocketType *st)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
|
|
|
BLI_ghash_remove(nodesockettypes_hash, st->idname, NULL, node_free_socket_type);
|
|
|
|
}
|
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
bool nodeSocketIsRegistered(bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
return (sock->typeinfo != &NodeSocketTypeUndefined);
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
GHashIterator *nodeSocketTypeGetIterator(void)
|
|
|
|
{
|
|
|
|
return BLI_ghashIterator_new(nodesockettypes_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct bNodeSocket *nodeFindSocket(bNode *node, int in_out, const char *identifier)
|
|
|
|
{
|
|
|
|
bNodeSocket *sock = (in_out == SOCK_IN ? node->inputs.first : node->outputs.first);
|
2013-03-18 18:25:05 +00:00
|
|
|
for (; sock; sock = sock->next) {
|
|
|
|
if (STREQ(sock->identifier, identifier))
|
2013-03-18 16:34:57 +00:00
|
|
|
return sock;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find unique socket identifier */
|
|
|
|
static bool unique_identifier_check(void *arg, const char *identifier)
|
|
|
|
{
|
|
|
|
struct ListBase *lb = arg;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
for (sock = lb->first; sock; sock = sock->next) {
|
2013-03-18 18:25:05 +00:00
|
|
|
if (STREQ(sock->identifier, identifier))
|
2013-03-18 16:34:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static bNodeSocket *make_socket(bNodeTree *ntree, bNode *UNUSED(node), int in_out, ListBase *lb,
|
|
|
|
const char *idname, const char *identifier, const char *name)
|
2008-02-09 23:17:15 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock;
|
2013-03-18 16:34:57 +00:00
|
|
|
char auto_identifier[MAX_NAME];
|
|
|
|
|
|
|
|
if (identifier && identifier[0] != '\0') {
|
|
|
|
/* use explicit identifier */
|
|
|
|
BLI_strncpy(auto_identifier, identifier, sizeof(auto_identifier));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* if no explicit identifier is given, assign a unique identifier based on the name */
|
|
|
|
BLI_strncpy(auto_identifier, name, sizeof(auto_identifier));
|
|
|
|
}
|
|
|
|
/* make the identifier unique */
|
2013-05-30 11:51:21 +00:00
|
|
|
BLI_uniquename_cb(unique_identifier_check, lb, "socket", '.', auto_identifier, sizeof(auto_identifier));
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
sock = MEM_callocN(sizeof(bNodeSocket), "sock");
|
2013-03-18 16:34:57 +00:00
|
|
|
sock->in_out = in_out;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
|
2012-07-29 00:20:28 +00:00
|
|
|
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
BLI_strncpy(sock->name, name, NODE_MAXSTR);
|
2011-09-05 21:01:50 +00:00
|
|
|
sock->storage = NULL;
|
2012-10-24 21:57:16 +00:00
|
|
|
sock->flag |= SOCK_COLLAPSED;
|
2013-03-18 16:34:57 +00:00
|
|
|
sock->type = SOCK_CUSTOM; /* int type undefined by default */
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
|
|
|
|
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(idname));
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
return sock;
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, int in_out, const char *idname,
|
|
|
|
const char *identifier, const char *name)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
ListBase *lb = (in_out == SOCK_IN ? &node->inputs : &node->outputs);
|
|
|
|
bNodeSocket *sock = make_socket(ntree, node, in_out, lb, idname, identifier, name);
|
|
|
|
|
|
|
|
BLI_remlink(lb, sock); /* does nothing for new socket */
|
|
|
|
BLI_addtail(lb, sock);
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
node->update |= NODE_UPDATE;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
|
|
|
return sock;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, const char *idname,
|
|
|
|
bNodeSocket *next_sock, const char *identifier, const char *name)
|
2011-02-21 13:47:49 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
ListBase *lb = (in_out == SOCK_IN ? &node->inputs : &node->outputs);
|
|
|
|
bNodeSocket *sock = make_socket(ntree, node, in_out, lb, idname, identifier, name);
|
|
|
|
|
|
|
|
BLI_remlink(lb, sock); /* does nothing for new socket */
|
|
|
|
BLI_insertlinkbefore(lb, next_sock, sock);
|
2011-02-21 13:47:49 +00:00
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
node->update |= NODE_UPDATE;
|
2011-02-21 13:47:49 +00:00
|
|
|
|
|
|
|
return sock;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
const char *nodeStaticSocketType(int type, int subtype)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case SOCK_FLOAT:
|
|
|
|
switch (subtype) {
|
|
|
|
case PROP_UNSIGNED:
|
|
|
|
return "NodeSocketFloatUnsigned";
|
|
|
|
case PROP_PERCENTAGE:
|
|
|
|
return "NodeSocketFloatPercentage";
|
|
|
|
case PROP_FACTOR:
|
|
|
|
return "NodeSocketFloatFactor";
|
|
|
|
case PROP_ANGLE:
|
|
|
|
return "NodeSocketFloatAngle";
|
|
|
|
case PROP_TIME:
|
|
|
|
return "NodeSocketFloatTime";
|
|
|
|
case PROP_NONE:
|
|
|
|
default:
|
|
|
|
return "NodeSocketFloat";
|
|
|
|
}
|
|
|
|
case SOCK_INT:
|
|
|
|
switch (subtype) {
|
|
|
|
case PROP_UNSIGNED:
|
|
|
|
return "NodeSocketIntUnsigned";
|
|
|
|
case PROP_PERCENTAGE:
|
|
|
|
return "NodeSocketIntPercentage";
|
|
|
|
case PROP_FACTOR:
|
|
|
|
return "NodeSocketIntFactor";
|
|
|
|
case PROP_NONE:
|
|
|
|
default:
|
|
|
|
return "NodeSocketInt";
|
|
|
|
}
|
|
|
|
case SOCK_BOOLEAN:
|
|
|
|
return "NodeSocketBool";
|
|
|
|
case SOCK_VECTOR:
|
|
|
|
switch (subtype) {
|
|
|
|
case PROP_TRANSLATION:
|
|
|
|
return "NodeSocketVectorTranslation";
|
|
|
|
case PROP_DIRECTION:
|
|
|
|
return "NodeSocketVectorDirection";
|
|
|
|
case PROP_VELOCITY:
|
|
|
|
return "NodeSocketVectorVelocity";
|
|
|
|
case PROP_ACCELERATION:
|
|
|
|
return "NodeSocketVectorAcceleration";
|
|
|
|
case PROP_EULER:
|
|
|
|
return "NodeSocketVectorEuler";
|
|
|
|
case PROP_XYZ:
|
|
|
|
return "NodeSocketVectorXYZ";
|
|
|
|
case PROP_NONE:
|
|
|
|
default:
|
|
|
|
return "NodeSocketVector";
|
|
|
|
}
|
|
|
|
case SOCK_RGBA:
|
|
|
|
return "NodeSocketColor";
|
|
|
|
case SOCK_STRING:
|
|
|
|
return "NodeSocketString";
|
|
|
|
case SOCK_SHADER:
|
|
|
|
return "NodeSocketShader";
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *nodeStaticSocketInterfaceType(int type, int subtype)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case SOCK_FLOAT:
|
|
|
|
switch (subtype) {
|
|
|
|
case PROP_UNSIGNED:
|
|
|
|
return "NodeSocketInterfaceFloatUnsigned";
|
|
|
|
case PROP_PERCENTAGE:
|
|
|
|
return "NodeSocketInterfaceFloatPercentage";
|
|
|
|
case PROP_FACTOR:
|
|
|
|
return "NodeSocketInterfaceFloatFactor";
|
|
|
|
case PROP_ANGLE:
|
|
|
|
return "NodeSocketInterfaceFloatAngle";
|
|
|
|
case PROP_TIME:
|
|
|
|
return "NodeSocketInterfaceFloatTime";
|
|
|
|
case PROP_NONE:
|
|
|
|
default:
|
|
|
|
return "NodeSocketInterfaceFloat";
|
|
|
|
}
|
|
|
|
case SOCK_INT:
|
|
|
|
switch (subtype) {
|
|
|
|
case PROP_UNSIGNED:
|
|
|
|
return "NodeSocketInterfaceIntUnsigned";
|
|
|
|
case PROP_PERCENTAGE:
|
|
|
|
return "NodeSocketInterfaceIntPercentage";
|
|
|
|
case PROP_FACTOR:
|
|
|
|
return "NodeSocketInterfaceIntFactor";
|
|
|
|
case PROP_NONE:
|
|
|
|
default:
|
|
|
|
return "NodeSocketInterfaceInt";
|
|
|
|
}
|
|
|
|
case SOCK_BOOLEAN:
|
|
|
|
return "NodeSocketInterfaceBool";
|
|
|
|
case SOCK_VECTOR:
|
|
|
|
switch (subtype) {
|
|
|
|
case PROP_TRANSLATION:
|
|
|
|
return "NodeSocketInterfaceVectorTranslation";
|
|
|
|
case PROP_DIRECTION:
|
|
|
|
return "NodeSocketInterfaceVectorDirection";
|
|
|
|
case PROP_VELOCITY:
|
|
|
|
return "NodeSocketInterfaceVectorVelocity";
|
|
|
|
case PROP_ACCELERATION:
|
|
|
|
return "NodeSocketInterfaceVectorAcceleration";
|
|
|
|
case PROP_EULER:
|
|
|
|
return "NodeSocketInterfaceVectorEuler";
|
|
|
|
case PROP_XYZ:
|
|
|
|
return "NodeSocketInterfaceVectorXYZ";
|
|
|
|
case PROP_NONE:
|
|
|
|
default:
|
|
|
|
return "NodeSocketInterfaceVector";
|
|
|
|
}
|
|
|
|
case SOCK_RGBA:
|
|
|
|
return "NodeSocketInterfaceColor";
|
|
|
|
case SOCK_STRING:
|
|
|
|
return "NodeSocketInterfaceString";
|
|
|
|
case SOCK_SHADER:
|
|
|
|
return "NodeSocketInterfaceShader";
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeSocket *nodeAddStaticSocket(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype,
|
|
|
|
const char *identifier, const char *name)
|
|
|
|
{
|
|
|
|
const char *idname = nodeStaticSocketType(type, subtype);
|
|
|
|
bNodeSocket *sock;
|
|
|
|
|
|
|
|
if (!idname) {
|
|
|
|
printf("Error: static node socket type %d undefined\n", type);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sock = nodeAddSocket(ntree, node, in_out, idname, identifier, name);
|
|
|
|
sock->type = type;
|
|
|
|
return sock;
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeSocket *nodeInsertStaticSocket(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype,
|
|
|
|
bNodeSocket *next_sock, const char *identifier, const char *name)
|
|
|
|
{
|
|
|
|
const char *idname = nodeStaticSocketType(type, subtype);
|
|
|
|
bNodeSocket *sock;
|
|
|
|
|
|
|
|
if (!idname) {
|
|
|
|
printf("Error: static node socket type %d undefined\n", type);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sock = nodeInsertSocket(ntree, node, in_out, idname, next_sock, identifier, name);
|
|
|
|
sock->type = type;
|
|
|
|
return sock;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_socket_free(bNodeTree *UNUSED(ntree), bNodeSocket *sock, bNode *UNUSED(node))
|
|
|
|
{
|
|
|
|
if (sock->prop) {
|
|
|
|
IDP_FreeProperty(sock->prop);
|
|
|
|
MEM_freeN(sock->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sock->default_value)
|
|
|
|
MEM_freeN(sock->default_value);
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
|
|
|
bNodeLink *link, *next;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = next) {
|
|
|
|
next = link->next;
|
|
|
|
if (link->fromsock == sock || link->tosock == sock) {
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* this is fast, this way we don't need an in_out argument */
|
|
|
|
BLI_remlink(&node->inputs, sock);
|
|
|
|
BLI_remlink(&node->outputs, sock);
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_free(ntree, sock, node);
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(sock);
|
2011-02-08 09:14:18 +00:00
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
node->update |= NODE_UPDATE;
|
2011-02-08 09:14:18 +00:00
|
|
|
}
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *sock, *sock_next;
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeLink *link, *next;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = next) {
|
|
|
|
next = link->next;
|
|
|
|
if (link->fromnode == node || link->tonode == node) {
|
2011-09-05 21:01:50 +00:00
|
|
|
nodeRemLink(ntree, link);
|
2010-12-29 11:51:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock_next) {
|
|
|
|
sock_next = sock->next;
|
|
|
|
node_socket_free(ntree, sock, node);
|
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
|
|
|
for (sock = node->outputs.first; sock; sock = sock_next) {
|
|
|
|
sock_next = sock->next;
|
|
|
|
node_socket_free(ntree, sock, node);
|
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
node->update |= NODE_UPDATE;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
}
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2009-12-17 04:55:15 +00:00
|
|
|
/* finds a node based on its name */
|
|
|
|
bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name)
|
|
|
|
{
|
2010-08-22 14:15:28 +00:00
|
|
|
return BLI_findstring(&ntree->nodes, name, offsetof(bNode, name));
|
2009-12-17 04:55:15 +00:00
|
|
|
}
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2007-12-27 10:17:33 +00:00
|
|
|
/* finds a node based on given socket */
|
2013-03-18 16:34:57 +00:00
|
|
|
int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex)
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
int in_out = sock->in_out;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *tsock;
|
2012-07-29 00:20:28 +00:00
|
|
|
int index = 0;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
tsock = (in_out == SOCK_IN ? node->inputs.first : node->outputs.first);
|
|
|
|
for (index = 0; tsock; tsock = tsock->next, index++) {
|
|
|
|
if (tsock == sock)
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
break;
|
2011-02-22 20:24:06 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tsock)
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-27 10:17:33 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node) {
|
2012-07-29 00:20:28 +00:00
|
|
|
*nodep = node;
|
|
|
|
if (sockindex) *sockindex = index;
|
2007-12-27 10:17:33 +00:00
|
|
|
return 1;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
}
|
2007-12-27 10:17:33 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
*nodep = NULL;
|
2007-12-27 10:17:33 +00:00
|
|
|
return 0;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
}
|
Orange; daily noodler update commit.
- Adding execution code for Node trees. Was a bit a puzzle, since I want
it to be multithreading by design. This now is solved by defining a
stack per tree for all data that's being written into. This stack, which
resides now in the NodeTree itself, then can be allocated per thread.
- For testing pleasure, I've added a 'mix node' and a 'show node', so
you can already see it do something. :)
- reshuffled structure, to put things nice together, and have easier node
adding. Current state is still WIP though, structure might change.
For the record; new file node_shaders.c will contain all shader node
definitions, apart from the drawing callbacks.
Next: I'm going to check on Andrea's work on icons now, since this is very
much needed for true shader/composit work.
Now back to release work...
2005-12-21 14:24:51 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* ************** Add stuff ********** */
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* Find the first available, non-duplicate name for a given node */
|
|
|
|
void nodeUniqueName(bNodeTree *ntree, bNode *node)
|
2009-11-11 09:11:21 +00:00
|
|
|
{
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename(&ntree->nodes, node, DATA_("Node"), '.', offsetof(bNode, name), sizeof(node->name));
|
2009-11-11 09:11:21 +00:00
|
|
|
}
|
2008-02-09 23:17:15 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idname)
|
2008-02-09 23:17:15 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *node;
|
2009-11-11 09:11:21 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
node = MEM_callocN(sizeof(bNode), "new node");
|
2011-09-05 21:01:50 +00:00
|
|
|
BLI_addtail(&ntree->nodes, node);
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(node->idname, idname, sizeof(node->idname));
|
|
|
|
node_set_typeinfo(C, ntree, node, nodeTypeFind(idname));
|
2012-05-08 15:14:59 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
ntree->update |= NTREE_UPDATE_NODES;
|
2008-11-12 22:03:11 +00:00
|
|
|
|
2008-02-09 23:17:15 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
|
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
const char *idname = NULL;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
NODE_TYPES_BEGIN(ntype)
|
2013-04-18 11:36:11 +00:00
|
|
|
/* do an extra poll here, because some int types are used
|
|
|
|
* for multiple node types, this helps find the desired type
|
|
|
|
*/
|
|
|
|
if (ntype->type == type && (!ntype->poll || ntype->poll(ntype, ntree))) {
|
|
|
|
idname = ntype->idname;
|
2013-03-18 16:34:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
NODE_TYPES_END
|
|
|
|
if (!idname) {
|
|
|
|
printf("Error: static node type %d undefined\n", type);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return nodeAddNode(C, ntree, idname);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_socket_copy(bNodeSocket *dst, bNodeSocket *src)
|
|
|
|
{
|
|
|
|
src->new_sock = dst;
|
|
|
|
|
|
|
|
if (src->prop)
|
|
|
|
dst->prop = IDP_CopyProperty(src->prop);
|
|
|
|
|
|
|
|
if (src->default_value)
|
|
|
|
dst->default_value = MEM_dupallocN(src->default_value);
|
|
|
|
|
|
|
|
dst->stack_index = 0;
|
|
|
|
/* XXX some compositor node (e.g. image, render layers) still store
|
|
|
|
* some persistent buffer data here, need to clear this to avoid dangling pointers.
|
|
|
|
*/
|
|
|
|
dst->cache = NULL;
|
|
|
|
}
|
|
|
|
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
/* keep socket listorder identical, for copying links */
|
|
|
|
/* ntree is the target tree */
|
2011-02-21 13:47:49 +00:00
|
|
|
bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
|
2005-12-18 23:08:22 +00:00
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
bNode *nnode = MEM_callocN(sizeof(bNode), "dupli node");
|
2008-02-24 22:27:40 +00:00
|
|
|
bNodeSocket *sock, *oldsock;
|
2012-10-25 16:49:06 +00:00
|
|
|
bNodeLink *link, *oldlink;
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
*nnode = *node;
|
2012-08-02 09:52:37 +00:00
|
|
|
/* can be called for nodes outside a node tree (e.g. clipboard) */
|
|
|
|
if (ntree) {
|
|
|
|
nodeUniqueName(ntree, nnode);
|
|
|
|
|
|
|
|
BLI_addtail(&ntree->nodes, nnode);
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2008-01-01 18:29:19 +00:00
|
|
|
BLI_duplicatelist(&nnode->inputs, &node->inputs);
|
2012-07-29 00:20:28 +00:00
|
|
|
oldsock = node->inputs.first;
|
2013-03-18 16:34:57 +00:00
|
|
|
for (sock = nnode->inputs.first; sock; sock = sock->next, oldsock = oldsock->next)
|
|
|
|
node_socket_copy(sock, oldsock);
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2008-01-01 18:29:19 +00:00
|
|
|
BLI_duplicatelist(&nnode->outputs, &node->outputs);
|
2012-07-29 00:20:28 +00:00
|
|
|
oldsock = node->outputs.first;
|
2013-03-18 16:34:57 +00:00
|
|
|
for (sock = nnode->outputs.first; sock; sock = sock->next, oldsock = oldsock->next)
|
|
|
|
node_socket_copy(sock, oldsock);
|
|
|
|
|
|
|
|
if (node->prop)
|
|
|
|
nnode->prop = IDP_CopyProperty(node->prop);
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
|
2012-10-25 16:49:06 +00:00
|
|
|
BLI_duplicatelist(&nnode->internal_links, &node->internal_links);
|
|
|
|
oldlink = node->internal_links.first;
|
|
|
|
for (link = nnode->internal_links.first; link; link = link->next, oldlink = oldlink->next) {
|
|
|
|
link->fromnode = nnode;
|
|
|
|
link->tonode = nnode;
|
|
|
|
link->fromsock = link->fromsock->new_sock;
|
|
|
|
link->tosock = link->tosock->new_sock;
|
|
|
|
}
|
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
/* don't increase node->id users, freenode doesn't decrement either */
|
2005-12-20 15:43:55 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->typeinfo->copyfunc)
|
|
|
|
node->typeinfo->copyfunc(ntree, nnode, node);
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
node->new_node = nnode;
|
|
|
|
nnode->new_node = NULL;
|
2012-10-26 11:29:30 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (nnode->typeinfo->copyfunc_api) {
|
|
|
|
PointerRNA ptr;
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_Node, nnode, &ptr);
|
|
|
|
|
|
|
|
nnode->typeinfo->copyfunc_api(&ptr, node);
|
2012-10-26 11:29:30 +00:00
|
|
|
}
|
2008-11-12 22:03:11 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
if (ntree)
|
|
|
|
ntree->update |= NTREE_UPDATE_NODES;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2005-12-18 23:08:22 +00:00
|
|
|
return nnode;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:16:08 +00:00
|
|
|
/* also used via rna api, so we check for proper input output direction */
|
2005-12-18 23:08:22 +00:00
|
|
|
bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock)
|
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
bNodeLink *link = NULL;
|
2011-01-17 15:16:08 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* test valid input */
|
|
|
|
BLI_assert(fromnode);
|
|
|
|
BLI_assert(tonode);
|
2005-12-18 23:08:22 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (fromsock->in_out == SOCK_OUT && tosock->in_out == SOCK_IN) {
|
2012-07-29 00:20:28 +00:00
|
|
|
link = MEM_callocN(sizeof(bNodeLink), "link");
|
2012-08-02 09:52:37 +00:00
|
|
|
if (ntree)
|
|
|
|
BLI_addtail(&ntree->links, link);
|
2012-07-29 00:20:28 +00:00
|
|
|
link->fromnode = fromnode;
|
|
|
|
link->fromsock = fromsock;
|
|
|
|
link->tonode = tonode;
|
|
|
|
link->tosock = tosock;
|
2011-01-17 15:16:08 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (fromsock->in_out == SOCK_IN && tosock->in_out == SOCK_OUT) {
|
|
|
|
/* OK but flip */
|
2012-07-29 00:20:28 +00:00
|
|
|
link = MEM_callocN(sizeof(bNodeLink), "link");
|
2012-08-02 09:52:37 +00:00
|
|
|
if (ntree)
|
|
|
|
BLI_addtail(&ntree->links, link);
|
2012-07-29 00:20:28 +00:00
|
|
|
link->fromnode = tonode;
|
|
|
|
link->fromsock = tosock;
|
|
|
|
link->tonode = fromnode;
|
|
|
|
link->tosock = fromsock;
|
2011-01-17 15:16:08 +00:00
|
|
|
}
|
2005-12-18 23:08:22 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
if (ntree)
|
|
|
|
ntree->update |= NTREE_UPDATE_LINKS;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2005-12-18 23:08:22 +00:00
|
|
|
return link;
|
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
void nodeRemLink(bNodeTree *ntree, bNodeLink *link)
|
2005-12-20 15:43:55 +00:00
|
|
|
{
|
2012-08-02 09:52:37 +00:00
|
|
|
/* can be called for links outside a node tree (e.g. clipboard) */
|
|
|
|
if (ntree)
|
|
|
|
BLI_remlink(&ntree->links, link);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (link->tosock)
|
2012-07-29 00:20:28 +00:00
|
|
|
link->tosock->link = NULL;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
MEM_freeN(link);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
if (ntree)
|
|
|
|
ntree->update |= NTREE_UPDATE_LINKS;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
2010-01-04 04:26:28 +00:00
|
|
|
void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
bNodeLink *link, *next;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = next) {
|
|
|
|
next = link->next;
|
|
|
|
if (link->fromsock == sock || link->tosock == sock) {
|
2010-01-04 04:26:28 +00:00
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
ntree->update |= NTREE_UPDATE_LINKS;
|
2010-01-04 04:26:28 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
int nodeLinkIsHidden(bNodeLink *link)
|
|
|
|
{
|
|
|
|
return nodeSocketIsHidden(link->fromsock) || nodeSocketIsHidden(link->tosock);
|
|
|
|
}
|
|
|
|
|
2012-02-27 17:38:16 +00:00
|
|
|
void nodeInternalRelink(bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
|
|
|
bNodeLink *link, *link_next;
|
|
|
|
|
2012-10-25 16:49:06 +00:00
|
|
|
if (node->internal_links.first == NULL)
|
2012-02-27 17:38:16 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* store link pointers in output sockets, for efficient lookup */
|
2012-10-25 16:49:06 +00:00
|
|
|
for (link = node->internal_links.first; link; link = link->next)
|
2012-02-27 17:38:16 +00:00
|
|
|
link->tosock->link = link;
|
|
|
|
|
|
|
|
/* redirect downstream links */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = link_next) {
|
2012-02-27 17:38:16 +00:00
|
|
|
link_next = link->next;
|
|
|
|
|
|
|
|
/* do we have internal link? */
|
2012-07-29 00:20:28 +00:00
|
|
|
if (link->fromnode == node) {
|
2012-02-27 17:38:16 +00:00
|
|
|
if (link->fromsock->link) {
|
|
|
|
/* get the upstream input link */
|
|
|
|
bNodeLink *fromlink = link->fromsock->link->fromsock->link;
|
|
|
|
/* skip the node */
|
|
|
|
if (fromlink) {
|
|
|
|
link->fromnode = fromlink->fromnode;
|
|
|
|
link->fromsock = fromlink->fromsock;
|
|
|
|
|
2013-03-05 09:34:14 +00:00
|
|
|
/* if the up- or downstream link is invalid,
|
|
|
|
* the replacement link will be invalid too.
|
|
|
|
*/
|
|
|
|
if (!(fromlink->flag & NODE_LINK_VALID))
|
|
|
|
link->flag &= ~NODE_LINK_VALID;
|
|
|
|
|
2012-02-27 17:38:16 +00:00
|
|
|
ntree->update |= NTREE_UPDATE_LINKS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove remaining upstream links */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = link_next) {
|
2012-02-27 17:38:16 +00:00
|
|
|
link_next = link->next;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (link->tonode == node)
|
2012-02-27 17:38:16 +00:00
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
void nodeToView(bNode *node, float x, float y, float *rx, float *ry)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
if (node->parent) {
|
2012-05-22 14:13:33 +00:00
|
|
|
nodeToView(node->parent, x + node->locx, y + node->locy, rx, ry);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-22 14:13:33 +00:00
|
|
|
*rx = x + node->locx;
|
|
|
|
*ry = y + node->locy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nodeFromView(bNode *node, float x, float y, float *rx, float *ry)
|
|
|
|
{
|
|
|
|
if (node->parent) {
|
|
|
|
nodeFromView(node->parent, x, y, rx, ry);
|
|
|
|
*rx -= node->locx;
|
|
|
|
*ry -= node->locy;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*rx = x - node->locx;
|
|
|
|
*ry = y - node->locy;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2012-08-05 20:40:26 +00:00
|
|
|
int nodeAttachNodeCheck(bNode *node, bNode *parent)
|
|
|
|
{
|
|
|
|
bNode *parent_recurse;
|
|
|
|
for (parent_recurse = node; parent_recurse; parent_recurse = parent_recurse->parent) {
|
|
|
|
if (parent_recurse == parent) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void nodeAttachNode(bNode *node, bNode *parent)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
2012-05-22 14:13:33 +00:00
|
|
|
float locx, locy;
|
2012-08-05 20:40:26 +00:00
|
|
|
|
|
|
|
BLI_assert(parent->type == NODE_FRAME);
|
|
|
|
BLI_assert(nodeAttachNodeCheck(parent, node) == FALSE);
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
nodeToView(node, 0.0f, 0.0f, &locx, &locy);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
node->parent = parent;
|
|
|
|
/* transform to parent space */
|
2012-05-22 14:13:33 +00:00
|
|
|
nodeFromView(parent, locx, locy, &node->locx, &node->locy);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2010-12-03 03:44:39 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void nodeDetachNode(struct bNode *node)
|
|
|
|
{
|
2012-05-22 14:13:33 +00:00
|
|
|
float locx, locy;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
if (node->parent) {
|
2012-08-05 20:40:26 +00:00
|
|
|
|
|
|
|
BLI_assert(node->parent->type == NODE_FRAME);
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* transform to view space */
|
|
|
|
nodeToView(node, 0.0f, 0.0f, &locx, &locy);
|
|
|
|
node->locx = locx;
|
|
|
|
node->locy = locy;
|
2011-09-05 21:01:50 +00:00
|
|
|
node->parent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
bNodeTree *ntree;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* trees are created as local trees for compositor, material or texture nodes,
|
2011-09-05 21:01:50 +00:00
|
|
|
* node groups and other tree types are created as library data.
|
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
if (bmain) {
|
2013-03-18 18:25:05 +00:00
|
|
|
ntree = BKE_libblock_alloc(&bmain->nodetree, ID_NT, name);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-07-29 00:20:28 +00:00
|
|
|
ntree = MEM_callocN(sizeof(bNodeTree), "new node tree");
|
2013-03-18 16:34:57 +00:00
|
|
|
*( (short *)ntree->id.name ) = ID_NT;
|
2012-07-29 00:20:28 +00:00
|
|
|
BLI_strncpy(ntree->id.name + 2, name, sizeof(ntree->id.name));
|
2010-12-03 03:44:39 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* Types are fully initialized at this point,
|
|
|
|
* if an undefined node is added later this will be reset.
|
|
|
|
*/
|
|
|
|
ntree->init |= NTREE_TYPE_INIT;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(ntree->idname, idname, sizeof(ntree->idname));
|
|
|
|
ntree_set_typeinfo(ntree, ntreeTypeFind(idname));
|
2011-09-05 21:01:50 +00:00
|
|
|
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
return ntree;
|
2005-12-20 15:43:55 +00:00
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2009-11-20 04:19:57 +00:00
|
|
|
/* Warning: this function gets called during some rather unexpected times
|
|
|
|
* - this gets called when executing compositing updates (for threaded previews)
|
|
|
|
* - when the nodetree datablock needs to be copied (i.e. when users get copied)
|
2012-03-18 07:38:51 +00:00
|
|
|
* - for scene duplication use ntreeSwapID() after so we don't have stale pointers.
|
2012-07-05 12:50:50 +00:00
|
|
|
*
|
|
|
|
* do_make_extern: keep enabled for general use, only reason _not_ to enable is when
|
|
|
|
* copying for internal use (threads for eg), where you wont want it to modify the
|
|
|
|
* scene data.
|
2009-11-20 04:19:57 +00:00
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_user, const short do_make_extern, const short copy_previews)
|
2006-02-07 15:50:55 +00:00
|
|
|
{
|
|
|
|
bNodeTree *newtree;
|
2011-09-20 08:48:48 +00:00
|
|
|
bNode *node /*, *nnode */ /* UNUSED */, *last;
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *sock, *oldsock;
|
2011-02-21 13:47:49 +00:00
|
|
|
bNodeLink *link;
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return NULL;
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2011-02-11 09:37:58 +00:00
|
|
|
/* is ntree part of library? */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (newtree = G.main->nodetree.first; newtree; newtree = newtree->id.next)
|
|
|
|
if (newtree == ntree) break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newtree) {
|
2012-07-29 00:20:28 +00:00
|
|
|
newtree = BKE_libblock_copy(&ntree->id);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-07-29 00:20:28 +00:00
|
|
|
newtree = MEM_dupallocN(ntree);
|
2013-06-05 19:28:58 +00:00
|
|
|
newtree->id.lib = NULL; /* same as owning datablock id.lib */
|
2013-03-10 05:46:24 +00:00
|
|
|
BKE_libblock_copy_data(&newtree->id, &ntree->id, true); /* copy animdata and ID props */
|
2006-02-07 15:50:55 +00:00
|
|
|
}
|
2011-05-02 08:37:44 +00:00
|
|
|
|
|
|
|
id_us_plus((ID *)newtree->gpd);
|
|
|
|
|
2011-03-03 18:53:07 +00:00
|
|
|
/* in case a running nodetree is copied */
|
2012-07-29 00:20:28 +00:00
|
|
|
newtree->execdata = NULL;
|
2011-03-03 18:53:07 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
newtree->nodes.first = newtree->nodes.last = NULL;
|
|
|
|
newtree->links.first = newtree->links.last = NULL;
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2011-02-11 09:37:58 +00:00
|
|
|
last = ntree->nodes.last;
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-07-05 12:50:50 +00:00
|
|
|
|
2012-08-22 08:54:18 +00:00
|
|
|
/* ntreeUserDecrefID inline */
|
|
|
|
if (do_id_user) {
|
2012-08-22 09:10:16 +00:00
|
|
|
id_us_plus(node->id);
|
2012-08-22 08:54:18 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 12:50:50 +00:00
|
|
|
if (do_make_extern) {
|
|
|
|
id_lib_extern(node->id);
|
|
|
|
}
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
node->new_node = NULL;
|
2012-10-23 03:38:26 +00:00
|
|
|
/* nnode = */ nodeCopyNode(newtree, node); /* sets node->new */
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* make sure we don't copy new nodes again! */
|
2012-07-29 00:20:28 +00:00
|
|
|
if (node == last)
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
2006-02-07 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
2011-02-21 13:47:49 +00:00
|
|
|
/* copy links */
|
|
|
|
BLI_duplicatelist(&newtree->links, &ntree->links);
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = newtree->links.first; link; link = link->next) {
|
2011-02-21 13:47:49 +00:00
|
|
|
link->fromnode = (link->fromnode ? link->fromnode->new_node : NULL);
|
|
|
|
link->fromsock = (link->fromsock ? link->fromsock->new_sock : NULL);
|
|
|
|
link->tonode = (link->tonode ? link->tonode->new_node : NULL);
|
|
|
|
link->tosock = (link->tosock ? link->tosock->new_sock : NULL);
|
|
|
|
/* update the link socket's pointer */
|
|
|
|
if (link->tosock)
|
|
|
|
link->tosock->link = link;
|
2006-02-15 15:22:49 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* copy interface sockets */
|
|
|
|
BLI_duplicatelist(&newtree->inputs, &ntree->inputs);
|
|
|
|
oldsock = ntree->inputs.first;
|
|
|
|
for (sock = newtree->inputs.first; sock; sock = sock->next, oldsock = oldsock->next)
|
|
|
|
node_socket_copy(sock, oldsock);
|
|
|
|
|
|
|
|
BLI_duplicatelist(&newtree->outputs, &ntree->outputs);
|
|
|
|
oldsock = ntree->outputs.first;
|
|
|
|
for (sock = newtree->outputs.first; sock; sock = sock->next, oldsock = oldsock->next)
|
|
|
|
node_socket_copy(sock, oldsock);
|
|
|
|
|
|
|
|
/* copy preview hash */
|
|
|
|
if (ntree->previews && copy_previews) {
|
|
|
|
bNodeInstanceHashIterator iter;
|
|
|
|
|
|
|
|
newtree->previews = BKE_node_instance_hash_new("node previews");
|
|
|
|
|
|
|
|
NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
|
|
|
|
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
|
|
|
|
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
|
|
|
|
BKE_node_instance_hash_insert(newtree->previews, key, BKE_node_preview_copy(preview));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
newtree->previews = NULL;
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* update node->parent pointers */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = newtree->nodes.first; node; node = node->next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
if (node->parent)
|
|
|
|
node->parent = node->parent->new_node;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* node tree will generate its own interface type */
|
|
|
|
ntree->interface_type = NULL;
|
|
|
|
|
2006-02-07 15:50:55 +00:00
|
|
|
return newtree;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:54:18 +00:00
|
|
|
bNodeTree *ntreeCopyTree_ex(bNodeTree *ntree, const short do_id_user)
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
return ntreeCopyTree_internal(ntree, do_id_user, TRUE, TRUE);
|
2012-08-22 08:54:18 +00:00
|
|
|
}
|
2012-07-05 12:50:50 +00:00
|
|
|
bNodeTree *ntreeCopyTree(bNodeTree *ntree)
|
|
|
|
{
|
2012-08-22 08:54:18 +00:00
|
|
|
return ntreeCopyTree_ex(ntree, TRUE);
|
2012-07-05 12:50:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-05 10:50:38 +00:00
|
|
|
/* use when duplicating scenes */
|
2012-08-22 08:54:18 +00:00
|
|
|
void ntreeSwitchID_ex(bNodeTree *ntree, ID *id_from, ID *id_to, const short do_id_user)
|
2010-08-05 10:50:38 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
2012-08-22 08:54:18 +00:00
|
|
|
|
|
|
|
if (id_from == id_to) {
|
|
|
|
/* should never happen but may as well skip if it does */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-05 10:50:38 +00:00
|
|
|
/* for scene duplication only */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id == id_from) {
|
2012-08-22 08:54:18 +00:00
|
|
|
if (do_id_user) {
|
|
|
|
id_us_min(id_from);
|
|
|
|
id_us_plus(id_to);
|
|
|
|
}
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
node->id = id_to;
|
2010-08-05 10:50:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-22 08:54:18 +00:00
|
|
|
void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to)
|
|
|
|
{
|
|
|
|
ntreeSwitchID_ex(ntree, id_from, id_to, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ntreeUserIncrefID(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
id_us_plus(node->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void ntreeUserDecrefID(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
id_us_min(node->id);
|
|
|
|
}
|
|
|
|
}
|
2010-08-05 10:50:38 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* *************** Node Preview *********** */
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* XXX this should be removed eventually ...
|
|
|
|
* Currently BKE functions are modelled closely on previous code,
|
|
|
|
* using BKE_node_preview_init_tree to set up previews for a whole node tree in advance.
|
|
|
|
* This should be left more to the individual node tree implementations.
|
|
|
|
*/
|
|
|
|
int BKE_node_preview_used(bNode *node)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
/* XXX check for closed nodes? */
|
|
|
|
return (node->typeinfo->flag & NODE_PREVIEW) != 0;
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodePreview *BKE_node_preview_verify(bNodeInstanceHash *previews, bNodeInstanceKey key, int xsize, int ysize, int create)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodePreview *preview;
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
preview = BKE_node_instance_hash_lookup(previews, key);
|
|
|
|
if (!preview) {
|
|
|
|
if (create) {
|
|
|
|
preview = MEM_callocN(sizeof(bNodePreview), "node preview");
|
|
|
|
BKE_node_instance_hash_insert(previews, key, preview);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* node previews can get added with variable size this way */
|
2012-07-29 00:20:28 +00:00
|
|
|
if (xsize == 0 || ysize == 0)
|
2013-03-18 16:34:57 +00:00
|
|
|
return preview;
|
2009-01-27 17:12:40 +00:00
|
|
|
|
|
|
|
/* sanity checks & initialize */
|
2013-03-18 16:34:57 +00:00
|
|
|
if (preview->rect) {
|
|
|
|
if (preview->xsize != xsize || preview->ysize != ysize) {
|
|
|
|
MEM_freeN(preview->rect);
|
|
|
|
preview->rect = NULL;
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (preview->rect == NULL) {
|
|
|
|
preview->rect = MEM_callocN(4 * xsize + xsize * ysize * sizeof(char) * 4, "node preview rect");
|
|
|
|
preview->xsize = xsize;
|
|
|
|
preview->ysize = ysize;
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
2011-01-03 15:50:08 +00:00
|
|
|
/* no clear, makes nicer previews */
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
return preview;
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodePreview *BKE_node_preview_copy(bNodePreview *preview)
|
|
|
|
{
|
|
|
|
bNodePreview *new_preview = MEM_dupallocN(preview);
|
|
|
|
if (preview->rect)
|
|
|
|
new_preview->rect = MEM_dupallocN(preview->rect);
|
|
|
|
return new_preview;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_preview_free(bNodePreview *preview)
|
|
|
|
{
|
|
|
|
if (preview->rect)
|
|
|
|
MEM_freeN(preview->rect);
|
|
|
|
MEM_freeN(preview);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_preview_init_tree_recursive(bNodeInstanceHash *previews, bNodeTree *ntree, bNodeInstanceKey parent_key, int xsize, int ysize, int create)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node);
|
|
|
|
|
|
|
|
if (BKE_node_preview_used(node)) {
|
|
|
|
node->preview_xsize = xsize;
|
|
|
|
node->preview_ysize = ysize;
|
|
|
|
|
|
|
|
BKE_node_preview_verify(previews, key, xsize, ysize, create);
|
|
|
|
}
|
|
|
|
|
2013-03-22 15:46:38 +00:00
|
|
|
if (node->type == NODE_GROUP && node->id)
|
2013-03-18 16:34:57 +00:00
|
|
|
node_preview_init_tree_recursive(previews, (bNodeTree *)node->id, key, xsize, ysize, create);
|
|
|
|
}
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void BKE_node_preview_init_tree(bNodeTree *ntree, int xsize, int ysize, int create_previews)
|
|
|
|
{
|
|
|
|
if (!ntree)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!ntree->previews)
|
|
|
|
ntree->previews = BKE_node_instance_hash_new("node previews");
|
|
|
|
|
|
|
|
node_preview_init_tree_recursive(ntree->previews, ntree, NODE_INSTANCE_KEY_BASE, xsize, ysize, create_previews);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_preview_tag_used_recursive(bNodeInstanceHash *previews, bNodeTree *ntree, bNodeInstanceKey parent_key)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
2013-03-18 16:34:57 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node);
|
|
|
|
|
|
|
|
if (BKE_node_preview_used(node))
|
|
|
|
BKE_node_instance_hash_tag_key(previews, key);
|
|
|
|
|
2013-03-22 15:46:38 +00:00
|
|
|
if (node->type == NODE_GROUP && node->id)
|
2013-03-18 16:34:57 +00:00
|
|
|
node_preview_tag_used_recursive(previews, (bNodeTree *)node->id, key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_preview_remove_unused(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
if (!ntree || !ntree->previews)
|
|
|
|
return;
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* use the instance hash functions for tagging and removing unused previews */
|
|
|
|
BKE_node_instance_hash_clear_tags(ntree->previews);
|
|
|
|
node_preview_tag_used_recursive(ntree->previews, ntree, NODE_INSTANCE_KEY_BASE);
|
|
|
|
|
|
|
|
BKE_node_instance_hash_remove_untagged(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_preview_free_tree(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
if (!ntree)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ntree->previews) {
|
|
|
|
BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
|
|
|
|
ntree->previews = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_preview_clear(bNodePreview *preview)
|
|
|
|
{
|
|
|
|
if (preview && preview->rect)
|
|
|
|
memset(preview->rect, 0, MEM_allocN_len(preview->rect));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_preview_clear_tree(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNodeInstanceHashIterator iter;
|
|
|
|
|
|
|
|
if (!ntree || !ntree->previews)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
|
|
|
|
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
|
|
|
|
BKE_node_preview_clear(preview);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_preview_sync(bNodePreview *to, bNodePreview *from)
|
|
|
|
{
|
|
|
|
/* sizes should have been initialized by BKE_node_preview_init_tree */
|
|
|
|
BLI_assert(to->xsize == from->xsize && to->ysize == from->ysize);
|
|
|
|
|
|
|
|
/* copy over contents of previews */
|
|
|
|
if (to->rect && from->rect) {
|
|
|
|
int xsize = to->xsize;
|
|
|
|
int ysize = to->ysize;
|
|
|
|
memcpy(to->rect, from->rect, 4 * xsize + xsize * ysize * sizeof(char) * 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_preview_sync_tree(bNodeTree *to_ntree, bNodeTree *from_ntree)
|
|
|
|
{
|
|
|
|
bNodeInstanceHash *from_previews = from_ntree->previews;
|
|
|
|
bNodeInstanceHash *to_previews = to_ntree->previews;
|
|
|
|
bNodeInstanceHashIterator iter;
|
|
|
|
|
|
|
|
if (!from_previews || !to_previews)
|
2009-01-27 17:12:40 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
NODE_INSTANCE_HASH_ITER(iter, from_previews) {
|
|
|
|
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
|
|
|
|
bNodePreview *from = BKE_node_instance_hash_iterator_get_value(&iter);
|
|
|
|
bNodePreview *to = BKE_node_instance_hash_lookup(to_previews, key);
|
|
|
|
|
|
|
|
if (from && to)
|
|
|
|
node_preview_sync(to, from);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 10:34:52 +00:00
|
|
|
void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2013-03-22 10:34:52 +00:00
|
|
|
if (remove_old || !to_ntree->previews) {
|
|
|
|
/* free old previews */
|
|
|
|
if (to_ntree->previews)
|
|
|
|
BKE_node_instance_hash_free(to_ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
|
|
|
|
|
|
|
|
/* transfer previews */
|
|
|
|
to_ntree->previews = from_ntree->previews;
|
|
|
|
from_ntree->previews = NULL;
|
|
|
|
|
|
|
|
/* clean up, in case any to_ntree nodes have been removed */
|
|
|
|
BKE_node_preview_remove_unused(to_ntree);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bNodeInstanceHashIterator iter;
|
|
|
|
|
|
|
|
if (from_ntree->previews) {
|
|
|
|
NODE_INSTANCE_HASH_ITER(iter, from_ntree->previews) {
|
|
|
|
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
|
|
|
|
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
|
|
|
|
|
|
|
|
/* replace existing previews */
|
|
|
|
BKE_node_instance_hash_remove(to_ntree->previews, key, (bNodeInstanceValueFP)BKE_node_preview_free);
|
|
|
|
BKE_node_instance_hash_insert(to_ntree->previews, key, preview);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: NULL free function here, because pointers have already been moved over to to_ntree->previews! */
|
|
|
|
BKE_node_instance_hash_free(from_ntree->previews, NULL);
|
|
|
|
from_ntree->previews = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* hack warning! this function is only used for shader previews, and
|
|
|
|
* since it gets called multiple times per pixel for Ztransp we only
|
|
|
|
* add the color once. Preview gets cleared before it starts render though */
|
|
|
|
void BKE_node_preview_set_pixel(bNodePreview *preview, const float col[4], int x, int y, int do_manage)
|
|
|
|
{
|
|
|
|
if (preview) {
|
|
|
|
if (x >= 0 && y >= 0) {
|
|
|
|
if (x < preview->xsize && y < preview->ysize) {
|
|
|
|
unsigned char *tar = preview->rect + 4 * ((preview->xsize * y) + x);
|
|
|
|
|
|
|
|
if (do_manage) {
|
|
|
|
linearrgb_to_srgb_uchar4(tar, col);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rgba_float_to_uchar(tar, col);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//else printf("prv out bound x y %d %d\n", x, y);
|
|
|
|
}
|
|
|
|
//else printf("prv out bound x y %d %d\n", x, y);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#if 0
|
2009-01-27 17:12:40 +00:00
|
|
|
static void nodeClearPreview(bNode *node)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->preview && node->preview->rect)
|
2009-01-27 17:12:40 +00:00
|
|
|
memset(node->preview->rect, 0, MEM_allocN_len(node->preview->rect));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use it to enforce clear */
|
|
|
|
void ntreeClearPreview(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL)
|
2009-01-27 17:12:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->typeinfo->flag & NODE_PREVIEW)
|
2009-01-27 17:12:40 +00:00
|
|
|
nodeClearPreview(node);
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->type == NODE_GROUP)
|
2009-01-27 17:12:40 +00:00
|
|
|
ntreeClearPreview((bNodeTree *)node->id);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* hack warning! this function is only used for shader previews, and
|
2012-03-03 20:19:11 +00:00
|
|
|
* since it gets called multiple times per pixel for Ztransp we only
|
|
|
|
* add the color once. Preview gets cleared before it starts render though */
|
2012-10-15 23:11:59 +00:00
|
|
|
void nodeAddToPreview(bNode *node, const float col[4], int x, int y, int do_manage)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
bNodePreview *preview = node->preview;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (preview) {
|
2012-07-29 00:20:28 +00:00
|
|
|
if (x >= 0 && y >= 0) {
|
|
|
|
if (x < preview->xsize && y < preview->ysize) {
|
|
|
|
unsigned char *tar = preview->rect + 4 * ((preview->xsize * y) + x);
|
2010-12-19 20:12:12 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (do_manage) {
|
2012-01-19 08:22:23 +00:00
|
|
|
linearrgb_to_srgb_uchar4(tar, col);
|
2010-12-19 20:12:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-01-19 10:04:51 +00:00
|
|
|
rgba_float_to_uchar(tar, col);
|
2010-12-19 20:12:12 +00:00
|
|
|
}
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
//else printf("prv out bound x y %d %d\n", x, y);
|
|
|
|
}
|
|
|
|
//else printf("prv out bound x y %d %d\n", x, y);
|
|
|
|
}
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
#endif
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2006-12-30 16:35:46 +00:00
|
|
|
/* ************** Free stuff ********** */
|
2005-12-18 13:46:01 +00:00
|
|
|
|
|
|
|
/* goes over entire tree */
|
2007-12-27 10:17:33 +00:00
|
|
|
void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
|
2005-12-18 13:46:01 +00:00
|
|
|
{
|
2005-12-20 15:43:55 +00:00
|
|
|
bNodeLink *link, *next;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
ListBase *lb;
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = next) {
|
|
|
|
next = link->next;
|
2005-12-20 15:43:55 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (link->fromnode == node) {
|
|
|
|
lb = &node->outputs;
|
2011-02-21 13:47:49 +00:00
|
|
|
if (link->tonode)
|
2011-10-19 17:08:35 +00:00
|
|
|
link->tonode->update |= NODE_UPDATE;
|
2006-01-28 15:21:04 +00:00
|
|
|
}
|
2012-07-29 00:20:28 +00:00
|
|
|
else if (link->tonode == node)
|
|
|
|
lb = &node->inputs;
|
2005-12-20 15:43:55 +00:00
|
|
|
else
|
2012-07-29 00:20:28 +00:00
|
|
|
lb = NULL;
|
2005-12-20 15:43:55 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (lb) {
|
2012-07-29 00:20:28 +00:00
|
|
|
for (sock = lb->first; sock; sock = sock->next) {
|
|
|
|
if (link->fromsock == sock || link->tosock == sock)
|
2005-12-20 15:43:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock) {
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
nodeRemLink(ntree, link);
|
2005-12-20 15:43:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void node_unlink_attached(bNodeTree *ntree, bNode *parent)
|
2006-01-28 15:21:04 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *node;
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
if (node->parent == parent)
|
|
|
|
nodeDetachNode(node);
|
2006-01-28 15:21:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:54:18 +00:00
|
|
|
/** \note caller needs to manage node->id user */
|
2005-12-18 13:46:01 +00:00
|
|
|
void nodeFreeNode(bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock, *nextsock;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* extra free callback */
|
|
|
|
if (node->typeinfo && node->typeinfo->freefunc_api) {
|
|
|
|
PointerRNA ptr;
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
|
|
|
|
|
|
|
|
node->typeinfo->freefunc_api(&ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* since it is called while free database, node->id is undefined */
|
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
/* can be called for nodes outside a node tree (e.g. clipboard) */
|
|
|
|
if (ntree) {
|
|
|
|
/* remove all references to this node */
|
|
|
|
nodeUnlinkNode(ntree, node);
|
|
|
|
node_unlink_attached(ntree, node);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
BLI_remlink(&ntree->nodes, node);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
if (ntree->typeinfo && ntree->typeinfo->free_node_cache)
|
|
|
|
ntree->typeinfo->free_node_cache(ntree, node);
|
2013-02-27 14:25:39 +00:00
|
|
|
|
|
|
|
/* texture node has bad habit of keeping exec data around */
|
|
|
|
if (ntree->type == NTREE_TEXTURE && ntree->execdata) {
|
2013-03-18 16:34:57 +00:00
|
|
|
ntreeTexEndExecTree(ntree->execdata);
|
2013-02-27 14:25:39 +00:00
|
|
|
ntree->execdata = NULL;
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
if (node->typeinfo && node->typeinfo->freefunc)
|
2013-03-18 16:34:57 +00:00
|
|
|
node->typeinfo->freefunc(node);
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
2012-03-01 12:07:59 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (sock = node->inputs.first; sock; sock = nextsock) {
|
2011-09-05 21:01:50 +00:00
|
|
|
nextsock = sock->next;
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_free(ntree, sock, node);
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
2012-07-29 00:20:28 +00:00
|
|
|
for (sock = node->outputs.first; sock; sock = nextsock) {
|
2011-09-05 21:01:50 +00:00
|
|
|
nextsock = sock->next;
|
2013-03-18 16:34:57 +00:00
|
|
|
node_socket_free(ntree, sock, node);
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
|
|
|
|
2012-10-25 16:49:06 +00:00
|
|
|
BLI_freelistN(&node->internal_links);
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->prop) {
|
|
|
|
IDP_FreeProperty(node->prop);
|
|
|
|
MEM_freeN(node->prop);
|
|
|
|
}
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2005-12-18 13:46:01 +00:00
|
|
|
MEM_freeN(node);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
if (ntree)
|
|
|
|
ntree->update |= NTREE_UPDATE_NODES;
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
if (sock->prop) {
|
|
|
|
IDP_FreeProperty(sock->prop);
|
|
|
|
MEM_freeN(sock->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sock->default_value)
|
|
|
|
MEM_freeN(sock->default_value);
|
|
|
|
}
|
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
/* do not free ntree itself here, BKE_libblock_free calls this function too */
|
2012-08-22 08:54:18 +00:00
|
|
|
void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
|
2005-12-18 13:46:01 +00:00
|
|
|
{
|
2012-10-28 17:09:50 +00:00
|
|
|
bNodeTree *tntree;
|
2005-12-18 13:46:01 +00:00
|
|
|
bNode *node, *next;
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *sock, *nextsock;
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* XXX hack! node trees should not store execution graphs at all.
|
|
|
|
* This should be removed when old tree types no longer require it.
|
|
|
|
* Currently the execution data for texture nodes remains in the tree
|
|
|
|
* after execution, until the node tree is updated or freed.
|
|
|
|
*/
|
|
|
|
if (ntree->execdata) {
|
|
|
|
switch (ntree->type) {
|
2012-07-29 00:20:28 +00:00
|
|
|
case NTREE_SHADER:
|
2013-03-18 16:34:57 +00:00
|
|
|
ntreeShaderEndExecTree(ntree->execdata);
|
2012-07-29 00:20:28 +00:00
|
|
|
break;
|
|
|
|
case NTREE_TEXTURE:
|
2013-03-18 16:34:57 +00:00
|
|
|
ntreeTexEndExecTree(ntree->execdata);
|
2013-02-27 14:25:39 +00:00
|
|
|
ntree->execdata = NULL;
|
2012-07-29 00:20:28 +00:00
|
|
|
break;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-09 11:54:41 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* unregister associated RNA types */
|
|
|
|
ntreeInterfaceTypeFree(ntree);
|
|
|
|
|
2010-02-13 13:38:10 +00:00
|
|
|
BKE_free_animdata((ID *)ntree);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2011-05-02 08:37:44 +00:00
|
|
|
id_us_min((ID *)ntree->gpd);
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
BLI_freelistN(&ntree->links); /* do first, then unlink_node goes fast */
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = next) {
|
|
|
|
next = node->next;
|
2012-08-22 08:54:18 +00:00
|
|
|
|
|
|
|
/* ntreeUserIncrefID inline */
|
2012-10-03 07:35:29 +00:00
|
|
|
|
|
|
|
/* XXX, this is correct, however when freeing the entire database
|
|
|
|
* this ends up accessing freed data which isn't properly unlinking
|
|
|
|
* its self from scene nodes, SO - for now prefer invalid usercounts
|
|
|
|
* on free rather then bad memory access - Campbell */
|
|
|
|
#if 0
|
2012-08-22 08:54:18 +00:00
|
|
|
if (do_id_user) {
|
|
|
|
id_us_min(node->id);
|
|
|
|
}
|
2012-10-03 07:35:29 +00:00
|
|
|
#else
|
|
|
|
(void)do_id_user;
|
|
|
|
#endif
|
2012-08-22 08:54:18 +00:00
|
|
|
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
nodeFreeNode(ntree, node);
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* free interface sockets */
|
|
|
|
for (sock = ntree->inputs.first; sock; sock = nextsock) {
|
|
|
|
nextsock = sock->next;
|
|
|
|
node_socket_interface_free(ntree, sock);
|
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
|
|
|
for (sock = ntree->outputs.first; sock; sock = nextsock) {
|
|
|
|
nextsock = sock->next;
|
|
|
|
node_socket_interface_free(ntree, sock);
|
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* free preview hash */
|
|
|
|
if (ntree->previews) {
|
|
|
|
BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
|
|
|
|
}
|
2012-10-28 17:09:50 +00:00
|
|
|
|
|
|
|
/* if ntree is not part of library, free the libblock data explicitly */
|
|
|
|
for (tntree = G.main->nodetree.first; tntree; tntree = tntree->id.next)
|
|
|
|
if (tntree == ntree)
|
|
|
|
break;
|
|
|
|
if (tntree == NULL) {
|
|
|
|
BKE_libblock_free_data(&ntree->id);
|
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
2012-08-22 08:54:18 +00:00
|
|
|
/* same as ntreeFreeTree_ex but always manage users */
|
|
|
|
void ntreeFreeTree(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
ntreeFreeTree_ex(ntree, TRUE);
|
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2006-02-08 17:30:28 +00:00
|
|
|
void ntreeFreeCache(bNodeTree *ntree)
|
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->typeinfo->free_cache)
|
|
|
|
ntree->typeinfo->free_cache(ntree);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2006-02-11 23:17:41 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void ntreeSetOutput(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-03-01 12:20:18 +00:00
|
|
|
/* find the active outputs, might become tree type dependent handler */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *tnode;
|
2012-07-29 00:20:28 +00:00
|
|
|
int output = 0;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* we need a check for which output node should be tagged like this, below an exception */
|
2012-07-29 00:20:28 +00:00
|
|
|
if (node->type == CMP_NODE_OUTPUT_FILE)
|
2011-11-11 13:09:14 +00:00
|
|
|
continue;
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* there is more types having output class, each one is checked */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
|
|
|
if (tnode->typeinfo->nclass == NODE_CLASS_OUTPUT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree->type == NTREE_COMPOSIT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* same type, exception for viewer */
|
2012-07-29 00:20:28 +00:00
|
|
|
if (tnode->type == node->type ||
|
|
|
|
(ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) &&
|
|
|
|
ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)))
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tnode->flag & NODE_DO_OUTPUT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
output++;
|
2012-07-29 00:20:28 +00:00
|
|
|
if (output > 1)
|
2011-09-05 21:01:50 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* same type */
|
2012-07-29 00:20:28 +00:00
|
|
|
if (tnode->type == node->type) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tnode->flag & NODE_DO_OUTPUT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
output++;
|
2012-07-29 00:20:28 +00:00
|
|
|
if (output > 1)
|
2011-09-05 21:01:50 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-29 00:20:28 +00:00
|
|
|
if (output == 0)
|
2011-09-05 21:01:50 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* group node outputs use this flag too */
|
|
|
|
if (node->type == NODE_GROUP_OUTPUT) {
|
|
|
|
bNode *tnode;
|
|
|
|
int output = 0;
|
|
|
|
|
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
|
|
|
if (tnode->type == NODE_GROUP_OUTPUT) {
|
|
|
|
if (tnode->flag & NODE_DO_OUTPUT) {
|
|
|
|
output++;
|
|
|
|
if (output > 1)
|
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (output == 0)
|
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* here we could recursively set which nodes have to be done,
|
2012-03-03 20:19:11 +00:00
|
|
|
* might be different for editor or for "real" use... */
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 16:21:43 +00:00
|
|
|
bNodeTree *ntreeFromID(ID *id)
|
|
|
|
{
|
|
|
|
switch (GS(id->name)) {
|
2012-12-28 14:19:05 +00:00
|
|
|
case ID_MA: return ((Material *)id)->nodetree;
|
|
|
|
case ID_LA: return ((Lamp *)id)->nodetree;
|
|
|
|
case ID_WO: return ((World *)id)->nodetree;
|
|
|
|
case ID_TE: return ((Tex *)id)->nodetree;
|
|
|
|
case ID_SCE: return ((Scene *)id)->nodetree;
|
2012-12-03 16:21:43 +00:00
|
|
|
default: return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-07 15:50:55 +00:00
|
|
|
void ntreeMakeLocal(bNodeTree *ntree)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
Main *bmain = G.main;
|
2013-03-18 16:34:57 +00:00
|
|
|
int lib = FALSE, local = FALSE;
|
2006-02-07 15:50:55 +00:00
|
|
|
|
|
|
|
/* - only lib users: do nothing
|
2012-03-03 20:19:11 +00:00
|
|
|
* - only local users: set flag
|
|
|
|
* - mixed: make copy
|
|
|
|
*/
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree->id.lib == NULL) return;
|
|
|
|
if (ntree->id.us == 1) {
|
2011-10-26 21:22:35 +00:00
|
|
|
id_clear_lib_data(bmain, (ID *)ntree);
|
2006-02-07 15:50:55 +00:00
|
|
|
return;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
2006-02-07 15:50:55 +00:00
|
|
|
/* now check users of groups... again typedepending, callback... */
|
2013-03-18 16:34:57 +00:00
|
|
|
FOREACH_NODETREE(G.main, tntree, owner_id) {
|
|
|
|
bNode *node;
|
|
|
|
/* find if group is in tree */
|
|
|
|
for (node = tntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id == (ID *)ntree) {
|
|
|
|
if (owner_id->lib)
|
|
|
|
lib = TRUE;
|
|
|
|
else
|
|
|
|
local = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} FOREACH_NODETREE_END
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* if all users are local, we simply make tree local */
|
2013-03-18 16:34:57 +00:00
|
|
|
if (local && !lib) {
|
2011-10-26 21:22:35 +00:00
|
|
|
id_clear_lib_data(bmain, (ID *)ntree);
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (local && lib) {
|
2006-02-07 15:50:55 +00:00
|
|
|
/* this is the mixed case, we copy the tree and assign it to local users */
|
2012-08-22 09:35:46 +00:00
|
|
|
bNodeTree *newtree = ntreeCopyTree(ntree);
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
newtree->id.us = 0;
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
FOREACH_NODETREE(G.main, tntree, owner_id) {
|
|
|
|
bNode *node;
|
|
|
|
/* find if group is in tree */
|
|
|
|
for (node = tntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id == (ID *)ntree) {
|
|
|
|
if (owner_id->lib == NULL) {
|
|
|
|
node->id = (ID *)newtree;
|
|
|
|
newtree->id.us++;
|
|
|
|
ntree->id.us--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} FOREACH_NODETREE_END
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)
|
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
bNode *node = ntree->nodes.first;
|
|
|
|
for (; node; node = node->next)
|
|
|
|
if (node == testnode)
|
2011-09-05 21:01:50 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ntreeOutputExists(bNode *node, bNodeSocket *testsock)
|
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
bNodeSocket *sock = node->outputs.first;
|
|
|
|
for (; sock; sock = sock->next)
|
|
|
|
if (sock == testsock)
|
2011-09-05 21:01:50 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns localized tree for execution in threads */
|
|
|
|
bNodeTree *ntreeLocalize(bNodeTree *ntree)
|
|
|
|
{
|
2013-03-19 13:40:16 +00:00
|
|
|
if (ntree) {
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ltree;
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
bAction *action_backup = NULL, *tmpact_backup = NULL;
|
|
|
|
|
|
|
|
/* Workaround for copying an action on each render!
|
|
|
|
* set action to NULL so animdata actions don't get copied */
|
|
|
|
AnimData *adt = BKE_animdata_from_id(&ntree->id);
|
|
|
|
|
|
|
|
if (adt) {
|
|
|
|
action_backup = adt->action;
|
|
|
|
tmpact_backup = adt->tmpact;
|
|
|
|
|
|
|
|
adt->action = NULL;
|
|
|
|
adt->tmpact = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make full copy.
|
|
|
|
* Note: previews are not copied here.
|
|
|
|
*/
|
|
|
|
ltree = ntreeCopyTree_internal(ntree, FALSE, FALSE, FALSE);
|
|
|
|
|
|
|
|
if (adt) {
|
|
|
|
AnimData *ladt = BKE_animdata_from_id(<ree->id);
|
|
|
|
|
|
|
|
adt->action = ladt->action = action_backup;
|
|
|
|
adt->tmpact = ladt->tmpact = tmpact_backup;
|
|
|
|
|
|
|
|
if (action_backup) action_backup->id.us++;
|
|
|
|
if (tmpact_backup) tmpact_backup->id.us++;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* end animdata uglyness */
|
|
|
|
|
|
|
|
/* ensures only a single output node is enabled */
|
|
|
|
ntreeSetOutput(ntree);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
/* store new_node pointer to original */
|
|
|
|
node->new_node->new_node = node;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->typeinfo->localize)
|
|
|
|
ntree->typeinfo->localize(ltree, ntree);
|
|
|
|
|
|
|
|
return ltree;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* sync local composite with real tree */
|
|
|
|
/* local tree is supposed to be running, be careful moving previews! */
|
|
|
|
/* is called by jobs manager, outside threads, so it doesnt happen during draw */
|
|
|
|
void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
|
|
|
|
{
|
2013-03-19 13:40:16 +00:00
|
|
|
if (localtree && ntree) {
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->typeinfo->local_sync)
|
|
|
|
ntree->typeinfo->local_sync(localtree, ntree);
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* merge local tree results back, and free local tree */
|
|
|
|
/* we have to assume the editor already changed completely */
|
|
|
|
void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
|
|
|
|
{
|
2013-03-19 13:40:16 +00:00
|
|
|
if (localtree && ntree) {
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->typeinfo->local_merge)
|
|
|
|
ntree->typeinfo->local_merge(localtree, ntree);
|
|
|
|
|
|
|
|
ntreeFreeTree_ex(localtree, FALSE);
|
|
|
|
MEM_freeN(localtree);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* ************ NODE TREE INTERFACE *************** */
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-28 10:32:04 +00:00
|
|
|
static bNodeSocket *make_socket_interface(bNodeTree *ntree, int in_out,
|
2013-03-18 16:34:57 +00:00
|
|
|
const char *idname, const char *name)
|
|
|
|
{
|
|
|
|
bNodeSocketType *stype = nodeSocketTypeFind(idname);
|
|
|
|
bNodeSocket *sock;
|
|
|
|
int own_index = ntree->cur_index++;
|
2013-06-13 11:49:22 +00:00
|
|
|
|
|
|
|
if (stype == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
sock = MEM_callocN(sizeof(bNodeSocket), "socket template");
|
|
|
|
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
|
2013-03-28 10:32:04 +00:00
|
|
|
node_socket_set_typeinfo(ntree, sock, stype);
|
2013-03-18 16:34:57 +00:00
|
|
|
sock->in_out = in_out;
|
|
|
|
sock->type = SOCK_CUSTOM; /* int type undefined by default */
|
|
|
|
|
|
|
|
/* assign new unique index */
|
|
|
|
own_index = ntree->cur_index++;
|
|
|
|
/* use the own_index as socket identifier */
|
|
|
|
if (in_out == SOCK_IN)
|
|
|
|
BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index);
|
|
|
|
else
|
|
|
|
BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
|
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
|
|
|
/* XXX forward compatibility:
|
|
|
|
* own_index is deprecated, but needs to be set here.
|
|
|
|
* Node sockets generally use the identifier string instead now,
|
|
|
|
* but reconstructing own_index in writefile.c would require parsing the identifier string.
|
|
|
|
*/
|
2013-03-18 18:37:59 +00:00
|
|
|
|
2013-03-21 02:58:21 +00:00
|
|
|
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
|
2013-03-18 21:36:12 +00:00
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#endif
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
sock->own_index = own_index;
|
2013-03-18 18:37:59 +00:00
|
|
|
|
2013-03-21 02:58:21 +00:00
|
|
|
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
|
2013-03-18 21:36:12 +00:00
|
|
|
# pragma GCC diagnostic pop
|
|
|
|
#endif
|
|
|
|
|
2013-03-18 18:37:59 +00:00
|
|
|
#endif /* USE_NODE_COMPAT_CUSTOMNODES */
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
|
|
|
|
|
|
|
|
BLI_strncpy(sock->name, name, NODE_MAXSTR);
|
|
|
|
sock->storage = NULL;
|
|
|
|
sock->flag |= SOCK_COLLAPSED;
|
|
|
|
|
|
|
|
return sock;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, int in_out, const char *identifier)
|
|
|
|
{
|
|
|
|
bNodeSocket *iosock = (in_out == SOCK_IN ? ntree->inputs.first : ntree->outputs.first);
|
|
|
|
for (; iosock; iosock = iosock->next)
|
2013-03-18 18:25:05 +00:00
|
|
|
if (STREQ(iosock->identifier, identifier))
|
2013-03-18 16:34:57 +00:00
|
|
|
return iosock;
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree, int in_out, const char *idname, const char *name)
|
|
|
|
{
|
|
|
|
bNodeSocket *iosock;
|
|
|
|
|
2013-03-28 10:32:04 +00:00
|
|
|
iosock = make_socket_interface(ntree, in_out, idname, name);
|
2013-03-18 16:34:57 +00:00
|
|
|
if (in_out == SOCK_IN) {
|
|
|
|
BLI_addtail(&ntree->inputs, iosock);
|
|
|
|
ntree->update |= NTREE_UPDATE_GROUP_IN;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (in_out == SOCK_OUT) {
|
|
|
|
BLI_addtail(&ntree->outputs, iosock);
|
|
|
|
ntree->update |= NTREE_UPDATE_GROUP_OUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iosock;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *ntreeInsertSocketInterface(bNodeTree *ntree, int in_out, const char *idname,
|
|
|
|
bNodeSocket *next_sock, const char *name)
|
|
|
|
{
|
|
|
|
bNodeSocket *iosock;
|
|
|
|
|
2013-03-28 10:32:04 +00:00
|
|
|
iosock = make_socket_interface(ntree, in_out, idname, name);
|
2013-03-18 16:34:57 +00:00
|
|
|
if (in_out == SOCK_IN) {
|
|
|
|
BLI_insertlinkbefore(&ntree->inputs, next_sock, iosock);
|
|
|
|
ntree->update |= NTREE_UPDATE_GROUP_IN;
|
|
|
|
}
|
|
|
|
else if (in_out == SOCK_OUT) {
|
|
|
|
BLI_insertlinkbefore(&ntree->outputs, next_sock, iosock);
|
|
|
|
ntree->update |= NTREE_UPDATE_GROUP_OUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iosock;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
struct bNodeSocket *ntreeAddSocketInterfaceFromSocket(bNodeTree *ntree, bNode *from_node, bNodeSocket *from_sock)
|
|
|
|
{
|
|
|
|
bNodeSocket *iosock = ntreeAddSocketInterface(ntree, from_sock->in_out, from_sock->idname, from_sock->name);
|
|
|
|
if (iosock) {
|
|
|
|
if (iosock->typeinfo->interface_from_socket)
|
|
|
|
iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
return iosock;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
struct bNodeSocket *ntreeInsertSocketInterfaceFromSocket(bNodeTree *ntree, bNodeSocket *next_sock, bNode *from_node, bNodeSocket *from_sock)
|
|
|
|
{
|
|
|
|
bNodeSocket *iosock = ntreeInsertSocketInterface(ntree, from_sock->in_out, from_sock->idname, next_sock, from_sock->name);
|
|
|
|
if (iosock) {
|
|
|
|
if (iosock->typeinfo->interface_from_socket)
|
|
|
|
iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock);
|
|
|
|
}
|
|
|
|
return iosock;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
/* this is fast, this way we don't need an in_out argument */
|
|
|
|
BLI_remlink(&ntree->inputs, sock);
|
|
|
|
BLI_remlink(&ntree->outputs, sock);
|
|
|
|
|
|
|
|
node_socket_interface_free(ntree, sock);
|
|
|
|
MEM_freeN(sock);
|
|
|
|
|
|
|
|
ntree->update |= NTREE_UPDATE_GROUP;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* generates a valid RNA identifier from the node tree name */
|
|
|
|
static void ntree_interface_identifier_base(bNodeTree *ntree, char *base)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
/* generate a valid RNA identifier */
|
2013-03-18 18:25:05 +00:00
|
|
|
sprintf(base, "NodeTreeInterface_%s", ntree->id.name + 2);
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_identifier_sanitize(base, FALSE);
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* check if the identifier is already in use */
|
|
|
|
static bool ntree_interface_unique_identifier_check(void *UNUSED(data), const char *identifier)
|
|
|
|
{
|
|
|
|
return (RNA_struct_find(identifier) != NULL);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* generates the actual unique identifier and ui name and description */
|
|
|
|
static void ntree_interface_identifier(bNodeTree *ntree, const char *base, char *identifier, int maxlen, char *name, char *description)
|
|
|
|
{
|
|
|
|
/* There is a possibility that different node tree names get mapped to the same identifier
|
|
|
|
* after sanitization (e.g. "SomeGroup_A", "SomeGroup.A" both get sanitized to "SomeGroup_A").
|
|
|
|
* On top of the sanitized id string add a number suffix if necessary to avoid duplicates.
|
|
|
|
*/
|
|
|
|
identifier[0] = '\0';
|
|
|
|
BLI_uniquename_cb(ntree_interface_unique_identifier_check, NULL, base, '_', identifier, maxlen);
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
sprintf(name, "Node Tree %s Interface", ntree->id.name + 2);
|
|
|
|
sprintf(description, "Interface properties of node group %s", ntree->id.name + 2);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ntree_interface_type_create(bNodeTree *ntree)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
/* strings are generated from base string + ID name, sizes are sufficient */
|
2013-03-18 18:25:05 +00:00
|
|
|
char base[MAX_ID_NAME + 64], identifier[MAX_ID_NAME + 64], name[MAX_ID_NAME + 64], description[MAX_ID_NAME + 64];
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* generate a valid RNA identifier */
|
|
|
|
ntree_interface_identifier_base(ntree, base);
|
|
|
|
ntree_interface_identifier(ntree, base, identifier, sizeof(identifier), name, description);
|
|
|
|
|
|
|
|
/* register a subtype of PropertyGroup */
|
|
|
|
srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_PropertyGroup);
|
|
|
|
RNA_def_struct_ui_text(srna, name, description);
|
|
|
|
RNA_def_struct_duplicate_pointers(srna);
|
|
|
|
|
|
|
|
/* associate the RNA type with the node tree */
|
|
|
|
ntree->interface_type = srna;
|
|
|
|
RNA_struct_blender_type_set(srna, ntree);
|
|
|
|
|
|
|
|
/* add socket properties */
|
|
|
|
for (sock = ntree->inputs.first; sock; sock = sock->next) {
|
|
|
|
bNodeSocketType *stype = sock->typeinfo;
|
|
|
|
if (stype && stype->interface_register_properties)
|
|
|
|
stype->interface_register_properties(ntree, sock, srna);
|
|
|
|
}
|
|
|
|
for (sock = ntree->outputs.first; sock; sock = sock->next) {
|
|
|
|
bNodeSocketType *stype = sock->typeinfo;
|
|
|
|
if (stype && stype->interface_register_properties)
|
|
|
|
stype->interface_register_properties(ntree, sock, srna);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StructRNA *ntreeInterfaceTypeGet(bNodeTree *ntree, int create)
|
|
|
|
{
|
|
|
|
if (ntree->interface_type) {
|
|
|
|
/* strings are generated from base string + ID name, sizes are sufficient */
|
2013-03-18 18:25:05 +00:00
|
|
|
char base[MAX_ID_NAME + 64], identifier[MAX_ID_NAME + 64], name[MAX_ID_NAME + 64], description[MAX_ID_NAME + 64];
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* A bit of a hack: when changing the ID name, update the RNA type identifier too,
|
|
|
|
* so that the names match. This is not strictly necessary to keep it working,
|
|
|
|
* but better for identifying associated NodeTree blocks and RNA types.
|
|
|
|
*/
|
|
|
|
StructRNA *srna = ntree->interface_type;
|
|
|
|
|
|
|
|
ntree_interface_identifier_base(ntree, base);
|
|
|
|
|
|
|
|
/* RNA identifier may have a number suffix, but should start with the idbase string */
|
|
|
|
if (strncmp(RNA_struct_identifier(srna), base, sizeof(base)) != 0) {
|
|
|
|
/* generate new unique RNA identifier from the ID name */
|
|
|
|
ntree_interface_identifier(ntree, base, identifier, sizeof(identifier), name, description);
|
|
|
|
|
|
|
|
/* rename the RNA type */
|
|
|
|
RNA_def_struct_free_pointers(srna);
|
|
|
|
RNA_def_struct_identifier(srna, identifier);
|
|
|
|
RNA_def_struct_ui_text(srna, name, description);
|
|
|
|
RNA_def_struct_duplicate_pointers(srna);
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
2006-02-07 15:50:55 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (create) {
|
|
|
|
ntree_interface_type_create(ntree);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ntree->interface_type;
|
|
|
|
}
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ntreeInterfaceTypeFree(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
if (ntree->interface_type) {
|
|
|
|
RNA_struct_free(&BLENDER_RNA, ntree->interface_type);
|
|
|
|
ntree->interface_type = NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ntreeInterfaceTypeUpdate(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
/* XXX it would be sufficient to just recreate all properties
|
|
|
|
* instead of re-registering the whole struct type,
|
|
|
|
* but there is currently no good way to do this in the RNA functions.
|
|
|
|
* Overhead should be negligible.
|
|
|
|
*/
|
|
|
|
ntreeInterfaceTypeFree(ntree);
|
|
|
|
ntree_interface_type_create(ntree);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2006-12-30 16:35:46 +00:00
|
|
|
/* ************ find stuff *************** */
|
2005-12-18 23:08:22 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
int ntreeHasType(bNodeTree *ntree, int type)
|
2006-06-03 09:19:10 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntree)
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->type == type)
|
2006-06-03 09:19:10 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-18 23:08:22 +00:00
|
|
|
bNodeLink *nodeFindLink(bNodeTree *ntree, bNodeSocket *from, bNodeSocket *to)
|
|
|
|
{
|
|
|
|
bNodeLink *link;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
if (link->fromsock == from && link->tosock == to)
|
2005-12-18 23:08:22 +00:00
|
|
|
return link;
|
2012-07-29 00:20:28 +00:00
|
|
|
if (link->fromsock == to && link->tosock == from) /* hrms? */
|
2005-12-18 23:08:22 +00:00
|
|
|
return link;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-12-20 15:43:55 +00:00
|
|
|
int nodeCountSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
bNodeLink *link;
|
2012-07-29 00:20:28 +00:00
|
|
|
int tot = 0;
|
2005-12-20 15:43:55 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
if (link->fromsock == sock || link->tosock == sock)
|
2005-12-20 15:43:55 +00:00
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
return tot;
|
|
|
|
}
|
|
|
|
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
bNode *nodeGetActive(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return NULL;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->flag & NODE_ACTIVE)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
break;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2013-05-16 15:06:18 +00:00
|
|
|
static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key, bNodeInstanceKey parent_key, bNodeTree *ntree, short idtype)
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
{
|
2013-05-16 15:06:18 +00:00
|
|
|
if (parent_key.value == active_key.value) {
|
|
|
|
bNode *node;
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next)
|
|
|
|
if (node->id && GS(node->id->name) == idtype)
|
|
|
|
if (node->flag & NODE_ACTIVE_ID)
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bNode *node, *tnode;
|
|
|
|
/* no node with active ID in this tree, look inside groups */
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == NODE_GROUP) {
|
|
|
|
bNodeTree *group = (bNodeTree *)node->id;
|
|
|
|
bNodeInstanceKey group_key = BKE_node_instance_key(parent_key, ntree, node);
|
|
|
|
tnode = node_get_active_id_recursive(active_key, group_key, group, idtype);
|
|
|
|
if (tnode)
|
|
|
|
return tnode;
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 15:06:18 +00:00
|
|
|
/* two active flags, ID nodes have special flag for buttons display */
|
|
|
|
bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
|
|
|
|
{
|
|
|
|
if (ntree)
|
|
|
|
return node_get_active_id_recursive(ntree->active_viewer_key, NODE_INSTANCE_KEY_BASE, ntree, idtype);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
|
2009-10-06 15:31:25 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
2013-03-18 18:25:05 +00:00
|
|
|
bool ok = false;
|
2009-10-06 15:31:25 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return ok;
|
2009-10-06 15:31:25 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id && GS(node->id->name) == idtype) {
|
|
|
|
if (id && ok == FALSE && node->id == id) {
|
2009-10-06 15:31:25 +00:00
|
|
|
node->flag |= NODE_ACTIVE_ID;
|
2012-07-29 00:20:28 +00:00
|
|
|
ok = TRUE;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-10-06 15:31:25 +00:00
|
|
|
node->flag &= ~NODE_ACTIVE_ID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* update all groups linked from here
|
|
|
|
* if active ID node has been found already,
|
|
|
|
* just pass NULL so other matching nodes are deactivated.
|
|
|
|
*/
|
2013-03-18 18:25:05 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == NODE_GROUP)
|
|
|
|
ok |= nodeSetActiveID((bNodeTree *)node->id, idtype, (ok == false ? id : NULL));
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 15:31:25 +00:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-30 11:25:15 +00:00
|
|
|
/* two active flags, ID nodes have special flag for buttons display */
|
|
|
|
void nodeClearActiveID(bNodeTree *ntree, short idtype)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return;
|
2005-12-30 11:25:15 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next)
|
|
|
|
if (node->id && GS(node->id->name) == idtype)
|
2005-12-30 11:25:15 +00:00
|
|
|
node->flag &= ~NODE_ACTIVE_ID;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void nodeSetSelected(bNode *node, int select)
|
|
|
|
{
|
|
|
|
if (select) {
|
|
|
|
node->flag |= NODE_SELECT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bNodeSocket *sock;
|
|
|
|
|
|
|
|
node->flag &= ~NODE_SELECT;
|
|
|
|
|
|
|
|
/* deselect sockets too */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next)
|
2013-03-18 16:34:57 +00:00
|
|
|
sock->flag &= ~NODE_SELECT;
|
2013-03-18 18:25:05 +00:00
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next)
|
2013-03-18 16:34:57 +00:00
|
|
|
sock->flag &= ~NODE_SELECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-11 18:43:48 +00:00
|
|
|
void nodeClearActive(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree == NULL) return;
|
2012-06-11 18:43:48 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next)
|
2012-06-11 18:43:48 +00:00
|
|
|
node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_ID);
|
|
|
|
}
|
|
|
|
|
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. :)
2005-12-29 18:08:01 +00:00
|
|
|
/* 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 */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
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. :)
2005-12-29 18:08:01 +00:00
|
|
|
tnode->flag &= ~NODE_ACTIVE;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->id && tnode->id) {
|
|
|
|
if (GS(node->id->name) == GS(tnode->id->name))
|
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. :)
2005-12-29 18:08:01 +00:00
|
|
|
tnode->flag &= ~NODE_ACTIVE_ID;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE)
|
2011-11-08 13:07:16 +00:00
|
|
|
tnode->flag &= ~NODE_ACTIVE_TEXTURE;
|
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. :)
2005-12-29 18:08:01 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
node->flag |= NODE_ACTIVE;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->id)
|
2011-09-05 21:01:50 +00:00
|
|
|
node->flag |= NODE_ACTIVE_ID;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE)
|
2011-11-08 13:07:16 +00:00
|
|
|
node->flag |= NODE_ACTIVE_TEXTURE;
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2012-01-08 10:23:19 +00:00
|
|
|
int nodeSocketIsHidden(bNodeSocket *sock)
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
return ((sock->flag & (SOCK_HIDDEN | SOCK_UNAVAIL)) != 0);
|
2012-03-01 07:56:15 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
/* ************** Node Clipboard *********** */
|
|
|
|
|
2012-08-20 13:51:25 +00:00
|
|
|
#define USE_NODE_CB_VALIDATE
|
|
|
|
|
|
|
|
#ifdef USE_NODE_CB_VALIDATE
|
|
|
|
/**
|
|
|
|
* This data structure is to validate the node on creation,
|
|
|
|
* otherwise we may reference missing data.
|
|
|
|
*
|
|
|
|
* Currently its only used for ID's, but nodes may one day
|
2012-08-24 23:22:34 +00:00
|
|
|
* reference other pointers which need validation.
|
2012-08-20 13:51:25 +00:00
|
|
|
*/
|
|
|
|
typedef struct bNodeClipboardExtraInfo {
|
2012-08-23 16:17:47 +00:00
|
|
|
struct bNodeClipboardExtraInfo *next, *prev;
|
2012-08-20 13:51:25 +00:00
|
|
|
ID *id;
|
2012-08-23 16:17:47 +00:00
|
|
|
char id_name[MAX_ID_NAME];
|
|
|
|
char library_name[FILE_MAX];
|
2012-08-20 13:51:25 +00:00
|
|
|
} bNodeClipboardExtraInfo;
|
|
|
|
#endif /* USE_NODE_CB_VALIDATE */
|
|
|
|
|
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
typedef struct bNodeClipboard {
|
|
|
|
ListBase nodes;
|
2012-08-20 13:51:25 +00:00
|
|
|
|
|
|
|
#ifdef USE_NODE_CB_VALIDATE
|
2012-08-23 16:17:47 +00:00
|
|
|
ListBase nodes_extra_info;
|
2012-08-20 13:51:25 +00:00
|
|
|
#endif
|
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
ListBase links;
|
2012-08-06 08:41:45 +00:00
|
|
|
int type;
|
2012-08-02 09:52:37 +00:00
|
|
|
} bNodeClipboard;
|
|
|
|
|
2013-03-22 05:34:10 +00:00
|
|
|
static bNodeClipboard node_clipboard = {{NULL}};
|
2012-08-02 09:52:37 +00:00
|
|
|
|
2012-08-06 08:41:45 +00:00
|
|
|
void BKE_node_clipboard_init(struct bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
node_clipboard.type = ntree->type;
|
|
|
|
}
|
|
|
|
|
2012-08-06 08:25:24 +00:00
|
|
|
void BKE_node_clipboard_clear(void)
|
2012-08-02 09:52:37 +00:00
|
|
|
{
|
|
|
|
bNode *node, *node_next;
|
|
|
|
bNodeLink *link, *link_next;
|
|
|
|
|
2012-08-06 10:03:17 +00:00
|
|
|
for (link = node_clipboard.links.first; link; link = link_next) {
|
2012-08-02 09:52:37 +00:00
|
|
|
link_next = link->next;
|
|
|
|
nodeRemLink(NULL, link);
|
|
|
|
}
|
|
|
|
node_clipboard.links.first = node_clipboard.links.last = NULL;
|
|
|
|
|
2012-08-06 10:03:17 +00:00
|
|
|
for (node = node_clipboard.nodes.first; node; node = node_next) {
|
2012-08-02 09:52:37 +00:00
|
|
|
node_next = node->next;
|
|
|
|
nodeFreeNode(NULL, node);
|
|
|
|
}
|
|
|
|
node_clipboard.nodes.first = node_clipboard.nodes.last = NULL;
|
2012-08-20 13:51:25 +00:00
|
|
|
|
|
|
|
#ifdef USE_NODE_CB_VALIDATE
|
2012-08-23 16:17:47 +00:00
|
|
|
BLI_freelistN(&node_clipboard.nodes_extra_info);
|
2012-08-20 13:51:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return FALSE when one or more ID's are lost */
|
|
|
|
int BKE_node_clipboard_validate(void)
|
|
|
|
{
|
|
|
|
int ok = TRUE;
|
|
|
|
|
|
|
|
#ifdef USE_NODE_CB_VALIDATE
|
|
|
|
bNodeClipboardExtraInfo *node_info;
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
|
|
|
|
/* lists must be aligned */
|
|
|
|
BLI_assert(BLI_countlist(&node_clipboard.nodes) ==
|
2012-10-29 02:11:40 +00:00
|
|
|
BLI_countlist(&node_clipboard.nodes_extra_info));
|
2012-08-20 13:51:25 +00:00
|
|
|
|
|
|
|
for (node = node_clipboard.nodes.first, node_info = node_clipboard.nodes_extra_info.first;
|
2012-10-29 02:11:40 +00:00
|
|
|
node;
|
|
|
|
node = node->next, node_info = node_info->next)
|
2012-08-20 13:51:25 +00:00
|
|
|
{
|
|
|
|
/* validate the node against the stored node info */
|
|
|
|
|
|
|
|
/* re-assign each loop since we may clear,
|
|
|
|
* open a new file where the ID is valid, and paste again */
|
|
|
|
node->id = node_info->id;
|
|
|
|
|
|
|
|
/* currently only validate the ID */
|
|
|
|
if (node->id) {
|
|
|
|
ListBase *lb = which_libbase(G.main, GS(node_info->id_name));
|
|
|
|
BLI_assert(lb != NULL);
|
|
|
|
|
|
|
|
if (BLI_findindex(lb, node_info->id) == -1) {
|
|
|
|
/* may assign NULL */
|
|
|
|
node->id = BLI_findstring(lb, node_info->id_name + 2, offsetof(ID, name) + 2);
|
2012-08-20 13:59:19 +00:00
|
|
|
|
2012-08-20 13:51:25 +00:00
|
|
|
if (node->id == NULL) {
|
|
|
|
ok = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* USE_NODE_CB_VALIDATE */
|
|
|
|
|
|
|
|
return ok;
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 08:25:24 +00:00
|
|
|
void BKE_node_clipboard_add_node(bNode *node)
|
2012-08-02 09:52:37 +00:00
|
|
|
{
|
2012-08-20 13:51:25 +00:00
|
|
|
#ifdef USE_NODE_CB_VALIDATE
|
2012-08-23 16:17:47 +00:00
|
|
|
/* add extra info */
|
2013-02-05 09:42:40 +00:00
|
|
|
bNodeClipboardExtraInfo *node_info = MEM_mallocN(sizeof(bNodeClipboardExtraInfo), "bNodeClipboardExtraInfo");
|
2012-08-20 13:51:25 +00:00
|
|
|
|
|
|
|
node_info->id = node->id;
|
2012-08-23 16:17:47 +00:00
|
|
|
if (node->id) {
|
|
|
|
BLI_strncpy(node_info->id_name, node->id->name, sizeof(node_info->id_name));
|
|
|
|
if (node->id->lib) {
|
|
|
|
BLI_strncpy(node_info->library_name, node->id->lib->filepath, sizeof(node_info->library_name));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
node_info->library_name[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
node_info->id_name[0] = '\0';
|
|
|
|
node_info->library_name[0] = '\0';
|
|
|
|
}
|
|
|
|
BLI_addtail(&node_clipboard.nodes_extra_info, node_info);
|
2012-08-20 13:51:25 +00:00
|
|
|
/* end extra info */
|
|
|
|
#endif /* USE_NODE_CB_VALIDATE */
|
|
|
|
|
2012-08-23 16:17:47 +00:00
|
|
|
/* add node */
|
2012-08-02 09:52:37 +00:00
|
|
|
BLI_addtail(&node_clipboard.nodes, node);
|
2012-08-20 13:51:25 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 08:25:24 +00:00
|
|
|
void BKE_node_clipboard_add_link(bNodeLink *link)
|
2012-08-02 09:52:37 +00:00
|
|
|
{
|
|
|
|
BLI_addtail(&node_clipboard.links, link);
|
|
|
|
}
|
|
|
|
|
2012-08-06 08:25:24 +00:00
|
|
|
const ListBase *BKE_node_clipboard_get_nodes(void)
|
2012-08-02 09:52:37 +00:00
|
|
|
{
|
|
|
|
return &node_clipboard.nodes;
|
|
|
|
}
|
|
|
|
|
2012-08-06 08:25:24 +00:00
|
|
|
const ListBase *BKE_node_clipboard_get_links(void)
|
2012-08-02 09:52:37 +00:00
|
|
|
{
|
|
|
|
return &node_clipboard.links;
|
|
|
|
}
|
|
|
|
|
2012-08-06 08:41:45 +00:00
|
|
|
int BKE_node_clipboard_get_type(void)
|
|
|
|
{
|
|
|
|
return node_clipboard.type;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* Node Instance Hash */
|
|
|
|
|
|
|
|
/* magic number for initial hash key */
|
|
|
|
const bNodeInstanceKey NODE_INSTANCE_KEY_BASE = {5381};
|
2013-04-24 16:36:50 +00:00
|
|
|
const bNodeInstanceKey NODE_INSTANCE_KEY_NONE = {0};
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* Generate a hash key from ntree and node names
|
|
|
|
* Uses the djb2 algorithm with xor by Bernstein:
|
|
|
|
* http://www.cse.yorku.ca/~oz/hash.html
|
|
|
|
*/
|
|
|
|
static bNodeInstanceKey node_hash_int_str(bNodeInstanceKey hash, const char *str)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
|
|
|
|
while ((c = *str++))
|
|
|
|
hash.value = ((hash.value << 5) + hash.value) ^ c; /* (hash * 33) ^ c */
|
|
|
|
|
|
|
|
/* separator '\0' character, to avoid ambiguity from concatenated strings */
|
|
|
|
hash.value = (hash.value << 5) + hash.value; /* hash * 33 */
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeInstanceKey BKE_node_instance_key(bNodeInstanceKey parent_key, bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
|
|
|
bNodeInstanceKey key;
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
key = node_hash_int_str(parent_key, ntree->id.name + 2);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
if (node)
|
|
|
|
key = node_hash_int_str(key, node->name);
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int node_instance_hash_key(const void *key)
|
|
|
|
{
|
|
|
|
return ((const bNodeInstanceKey *)key)->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int node_instance_hash_key_cmp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
unsigned int value_a = ((const bNodeInstanceKey *)a)->value;
|
|
|
|
unsigned int value_b = ((const bNodeInstanceKey *)b)->value;
|
|
|
|
if (value_a == value_b)
|
|
|
|
return 0;
|
|
|
|
else if (value_a < value_b)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeInstanceHash *BKE_node_instance_hash_new(const char *info)
|
|
|
|
{
|
|
|
|
bNodeInstanceHash *hash = MEM_mallocN(sizeof(bNodeInstanceHash), info);
|
|
|
|
hash->ghash = BLI_ghash_new(node_instance_hash_key, node_instance_hash_key_cmp, "node instance hash ghash");
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_instance_hash_free(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp)
|
|
|
|
{
|
|
|
|
BLI_ghash_free(hash->ghash, NULL, (GHashValFreeFP)valfreefp);
|
|
|
|
MEM_freeN(hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_instance_hash_insert(bNodeInstanceHash *hash, bNodeInstanceKey key, void *value)
|
|
|
|
{
|
|
|
|
bNodeInstanceHashEntry *entry = value;
|
|
|
|
entry->key = key;
|
|
|
|
entry->tag = 0;
|
|
|
|
BLI_ghash_insert(hash->ghash, &entry->key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *BKE_node_instance_hash_lookup(bNodeInstanceHash *hash, bNodeInstanceKey key)
|
|
|
|
{
|
|
|
|
return BLI_ghash_lookup(hash->ghash, &key);
|
|
|
|
}
|
|
|
|
|
|
|
|
int BKE_node_instance_hash_remove(bNodeInstanceHash *hash, bNodeInstanceKey key, bNodeInstanceValueFP valfreefp)
|
|
|
|
{
|
|
|
|
return BLI_ghash_remove(hash->ghash, &key, NULL, (GHashValFreeFP)valfreefp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_instance_hash_clear(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp)
|
|
|
|
{
|
|
|
|
BLI_ghash_clear(hash->ghash, NULL, (GHashValFreeFP)valfreefp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *BKE_node_instance_hash_pop(bNodeInstanceHash *hash, bNodeInstanceKey key)
|
|
|
|
{
|
|
|
|
return BLI_ghash_pop(hash->ghash, &key, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int BKE_node_instance_hash_haskey(bNodeInstanceHash *hash, bNodeInstanceKey key)
|
|
|
|
{
|
|
|
|
return BLI_ghash_haskey(hash->ghash, &key);
|
|
|
|
}
|
|
|
|
|
|
|
|
int BKE_node_instance_hash_size(bNodeInstanceHash *hash)
|
|
|
|
{
|
|
|
|
return BLI_ghash_size(hash->ghash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash)
|
|
|
|
{
|
|
|
|
bNodeInstanceHashIterator iter;
|
|
|
|
|
|
|
|
NODE_INSTANCE_HASH_ITER(iter, hash) {
|
|
|
|
bNodeInstanceHashEntry *value = BKE_node_instance_hash_iterator_get_value(&iter);
|
|
|
|
|
|
|
|
value->tag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_instance_hash_tag(bNodeInstanceHash *UNUSED(hash), void *value)
|
|
|
|
{
|
|
|
|
bNodeInstanceHashEntry *entry = value;
|
|
|
|
entry->tag = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey key)
|
|
|
|
{
|
|
|
|
bNodeInstanceHashEntry *entry = BKE_node_instance_hash_lookup(hash, key);
|
|
|
|
|
|
|
|
if (entry) {
|
|
|
|
entry->tag = 1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp)
|
|
|
|
{
|
|
|
|
/* NOTE: Hash must not be mutated during iterating!
|
|
|
|
* Store tagged entries in a separate list and remove items afterward.
|
|
|
|
*/
|
2013-03-18 18:25:05 +00:00
|
|
|
bNodeInstanceKey *untagged = MEM_mallocN(sizeof(bNodeInstanceKey) * BKE_node_instance_hash_size(hash), "temporary node instance key list");
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeInstanceHashIterator iter;
|
|
|
|
int num_untagged, i;
|
|
|
|
|
|
|
|
num_untagged = 0;
|
|
|
|
NODE_INSTANCE_HASH_ITER(iter, hash) {
|
|
|
|
bNodeInstanceHashEntry *value = BKE_node_instance_hash_iterator_get_value(&iter);
|
|
|
|
|
|
|
|
if (!value->tag)
|
|
|
|
untagged[num_untagged++] = BKE_node_instance_hash_iterator_get_key(&iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_untagged; ++i) {
|
|
|
|
BKE_node_instance_hash_remove(hash, untagged[i], valfreefp);
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(untagged);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* ************** dependency stuff *********** */
|
|
|
|
|
|
|
|
/* node is guaranteed to be not checked before */
|
2012-10-09 17:30:33 +00:00
|
|
|
static int node_get_deplist_recurs(bNodeTree *ntree, bNode *node, bNode ***nsort)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *fromnode;
|
2012-10-09 17:30:33 +00:00
|
|
|
bNodeLink *link;
|
2011-09-05 21:01:50 +00:00
|
|
|
int level = 0xFFF;
|
|
|
|
|
2012-05-19 13:28:19 +00:00
|
|
|
node->done = TRUE;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* check linked nodes */
|
2012-10-09 17:30:33 +00:00
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
if (link->tonode == node) {
|
|
|
|
fromnode = link->fromnode;
|
2013-03-18 16:34:57 +00:00
|
|
|
if (fromnode->done == 0)
|
|
|
|
fromnode->level = node_get_deplist_recurs(ntree, fromnode, nsort);
|
|
|
|
if (fromnode->level <= level)
|
|
|
|
level = fromnode->level - 1;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check parent node */
|
|
|
|
if (node->parent) {
|
2012-07-29 00:20:28 +00:00
|
|
|
if (node->parent->done == 0)
|
2012-10-09 17:30:33 +00:00
|
|
|
node->parent->level = node_get_deplist_recurs(ntree, node->parent, nsort);
|
2011-09-05 21:01:50 +00:00
|
|
|
if (node->parent->level <= level)
|
|
|
|
level = node->parent->level - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsort) {
|
2012-07-29 00:20:28 +00:00
|
|
|
**nsort = node;
|
2011-09-05 21:01:50 +00:00
|
|
|
(*nsort)++;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
return level;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *node, **nsort;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
*totnodes = 0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* first clear data */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-05-19 13:28:19 +00:00
|
|
|
node->done = FALSE;
|
2011-09-05 21:01:50 +00:00
|
|
|
(*totnodes)++;
|
|
|
|
}
|
2012-07-29 00:20:28 +00:00
|
|
|
if (*totnodes == 0) {
|
2011-09-05 21:01:50 +00:00
|
|
|
*deplist = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
nsort = *deplist = MEM_callocN((*totnodes) * sizeof(bNode *), "sorted node array");
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* recursive check */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->done == 0) {
|
2012-10-09 17:30:33 +00:00
|
|
|
node->level = node_get_deplist_recurs(ntree, node, &nsort);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-07 12:30:29 +00:00
|
|
|
/* only updates node->level for detecting cycles links */
|
|
|
|
static void ntree_update_node_level(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
/* first clear tag */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-05-19 13:28:19 +00:00
|
|
|
node->done = FALSE;
|
2012-03-07 12:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* recursive check */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->done == 0) {
|
2012-10-09 17:30:33 +00:00
|
|
|
node->level = node_get_deplist_recurs(ntree, node, NULL);
|
2012-03-07 12:30:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void ntree_update_link_pointers(bNodeTree *ntree)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock;
|
|
|
|
bNodeLink *link;
|
|
|
|
|
|
|
|
/* first clear data */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
|
|
|
sock->link = NULL;
|
2011-12-19 12:04:05 +00:00
|
|
|
sock->flag &= ~SOCK_IN_USE;
|
|
|
|
}
|
2012-07-29 00:20:28 +00:00
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
2011-12-19 12:04:05 +00:00
|
|
|
sock->flag &= ~SOCK_IN_USE;
|
|
|
|
}
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
link->tosock->link = link;
|
2011-12-19 12:04:05 +00:00
|
|
|
|
|
|
|
link->fromsock->flag |= SOCK_IN_USE;
|
|
|
|
link->tosock->flag |= SOCK_IN_USE;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
|
2011-09-16 08:20:21 +00:00
|
|
|
static void ntree_validate_links(bNodeTree *ntree)
|
2007-03-24 18:41:54 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeLink *link;
|
|
|
|
|
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
link->flag |= NODE_LINK_VALID;
|
|
|
|
if (link->fromnode && link->tonode && link->fromnode->level <= link->tonode->level)
|
|
|
|
link->flag &= ~NODE_LINK_VALID;
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (ntree->typeinfo->validate_link) {
|
|
|
|
if (!ntree->typeinfo->validate_link(ntree, link))
|
2011-09-05 21:01:50 +00:00
|
|
|
link->flag &= ~NODE_LINK_VALID;
|
|
|
|
}
|
|
|
|
}
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void ntreeVerifyNodes(struct Main *main, struct ID *id)
|
2007-03-24 18:41:54 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
FOREACH_NODETREE(main, ntree, owner_id) {
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next)
|
2013-03-19 13:40:16 +00:00
|
|
|
if (node->typeinfo->verifyfunc)
|
2013-03-18 16:34:57 +00:00
|
|
|
node->typeinfo->verifyfunc(ntree, node, id);
|
|
|
|
} FOREACH_NODETREE_END
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
|
2010-01-27 05:42:17 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *node;
|
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
if (!ntree)
|
|
|
|
return;
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* avoid reentrant updates, can be caused by RNA update callbacks */
|
|
|
|
if (ntree->is_updating)
|
|
|
|
return;
|
|
|
|
ntree->is_updating = TRUE;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (ntree->update & (NTREE_UPDATE_LINKS | NTREE_UPDATE_NODES)) {
|
2012-03-20 16:59:00 +00:00
|
|
|
/* set the bNodeSocket->link pointers */
|
2012-03-07 12:30:29 +00:00
|
|
|
ntree_update_link_pointers(ntree);
|
2012-03-20 16:59:00 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-03-07 12:30:29 +00:00
|
|
|
/* update individual nodes */
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-03-07 12:30:29 +00:00
|
|
|
/* node tree update tags override individual node update flags */
|
|
|
|
if ((node->update & NODE_UPDATE) || (ntree->update & NTREE_UPDATE)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->typeinfo->updatefunc)
|
2012-03-07 12:30:29 +00:00
|
|
|
node->typeinfo->updatefunc(ntree, node);
|
2012-10-25 16:49:06 +00:00
|
|
|
|
|
|
|
nodeUpdateInternalLinks(ntree, node);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2010-01-27 05:42:17 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-03-07 12:30:29 +00:00
|
|
|
/* generic tree update callback */
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->typeinfo->update)
|
|
|
|
ntree->typeinfo->update(ntree);
|
|
|
|
/* XXX this should be moved into the tree type update callback for tree supporting node groups.
|
|
|
|
* Currently the node tree interface is still a generic feature of the base NodeTree type.
|
|
|
|
*/
|
|
|
|
if (ntree->update & NTREE_UPDATE_GROUP)
|
|
|
|
ntreeInterfaceTypeUpdate(ntree);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* XXX hack, should be done by depsgraph!! */
|
2013-05-07 15:28:42 +00:00
|
|
|
if (bmain)
|
|
|
|
ntreeVerifyNodes(bmain, &ntree->id);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->update & (NTREE_UPDATE_LINKS | NTREE_UPDATE_NODES)) {
|
|
|
|
/* node updates can change sockets or links, repeat link pointer update afterward */
|
|
|
|
ntree_update_link_pointers(ntree);
|
|
|
|
|
|
|
|
/* update the node level from link dependencies */
|
|
|
|
ntree_update_node_level(ntree);
|
|
|
|
|
|
|
|
/* check link validity */
|
|
|
|
ntree_validate_links(ntree);
|
|
|
|
}
|
|
|
|
|
2012-08-06 18:49:28 +00:00
|
|
|
/* clear update flags */
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
node->update = 0;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
ntree->update = 0;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
ntree->is_updating = FALSE;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2010-01-27 05:42:17 +00:00
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
void nodeUpdate(bNodeTree *ntree, bNode *node)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
/* avoid reentrant updates, can be caused by RNA update callbacks */
|
|
|
|
if (ntree->is_updating)
|
|
|
|
return;
|
|
|
|
ntree->is_updating = TRUE;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->typeinfo->updatefunc)
|
2011-09-05 21:01:50 +00:00
|
|
|
node->typeinfo->updatefunc(ntree, node);
|
2012-10-25 16:49:06 +00:00
|
|
|
|
|
|
|
nodeUpdateInternalLinks(ntree, node);
|
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
/* clear update flag */
|
|
|
|
node->update = 0;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
ntree->is_updating = FALSE;
|
2010-01-27 05:42:17 +00:00
|
|
|
}
|
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
int nodeUpdateID(bNodeTree *ntree, ID *id)
|
2007-03-24 18:41:54 +00:00
|
|
|
{
|
2007-04-11 17:49:08 +00:00
|
|
|
bNode *node;
|
2011-09-05 21:01:50 +00:00
|
|
|
int change = FALSE;
|
2011-10-19 17:08:35 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ELEM(NULL, id, ntree))
|
2011-09-05 21:01:50 +00:00
|
|
|
return change;
|
2007-04-11 17:49:08 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* avoid reentrant updates, can be caused by RNA update callbacks */
|
|
|
|
if (ntree->is_updating)
|
|
|
|
return change;
|
|
|
|
ntree->is_updating = TRUE;
|
2011-09-06 18:15:34 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2013-03-18 18:25:05 +00:00
|
|
|
if (node->id == id) {
|
2013-03-18 16:34:57 +00:00
|
|
|
change = TRUE;
|
|
|
|
node->update |= NODE_UPDATE_ID;
|
|
|
|
if (node->typeinfo->updatefunc)
|
|
|
|
node->typeinfo->updatefunc(ntree, node);
|
|
|
|
/* clear update flag */
|
|
|
|
node->update = 0;
|
2007-04-11 17:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 16:49:06 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
nodeUpdateInternalLinks(ntree, node);
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree->is_updating = FALSE;
|
2011-09-05 21:01:50 +00:00
|
|
|
return change;
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 16:49:06 +00:00
|
|
|
void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
|
|
|
BLI_freelistN(&node->internal_links);
|
|
|
|
|
|
|
|
if (node->typeinfo && node->typeinfo->update_internal_links)
|
|
|
|
node->typeinfo->update_internal_links(ntree, node);
|
|
|
|
}
|
|
|
|
|
2007-03-24 18:41:54 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* nodes that use ID data get synced with local data */
|
|
|
|
void nodeSynchronizeID(bNode *node, bool copy_to_id)
|
2007-03-24 18:41:54 +00:00
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
if (node->id == NULL) return;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
if (ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) {
|
|
|
|
bNodeSocket *sock;
|
2013-03-18 18:25:05 +00:00
|
|
|
Material *ma = (Material *)node->id;
|
2013-03-18 16:34:57 +00:00
|
|
|
int a;
|
|
|
|
|
|
|
|
/* hrmf, case in loop isn't super fast, but we don't edit 100s of material at same time either! */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (a = 0, sock = node->inputs.first; sock; sock = sock->next, a++) {
|
2013-03-18 16:34:57 +00:00
|
|
|
if (!nodeSocketIsHidden(sock)) {
|
|
|
|
if (copy_to_id) {
|
|
|
|
switch (a) {
|
|
|
|
case MAT_IN_COLOR:
|
|
|
|
copy_v3_v3(&ma->r, ((bNodeSocketValueRGBA *)sock->default_value)->value); break;
|
|
|
|
case MAT_IN_SPEC:
|
|
|
|
copy_v3_v3(&ma->specr, ((bNodeSocketValueRGBA *)sock->default_value)->value); break;
|
|
|
|
case MAT_IN_REFL:
|
2013-03-18 18:25:05 +00:00
|
|
|
ma->ref = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
2013-03-18 16:34:57 +00:00
|
|
|
case MAT_IN_MIR:
|
|
|
|
copy_v3_v3(&ma->mirr, ((bNodeSocketValueRGBA *)sock->default_value)->value); break;
|
|
|
|
case MAT_IN_AMB:
|
|
|
|
ma->amb = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
|
|
|
case MAT_IN_EMIT:
|
|
|
|
ma->emit = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
|
|
|
case MAT_IN_SPECTRA:
|
|
|
|
ma->spectra = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
|
|
|
case MAT_IN_RAY_MIRROR:
|
|
|
|
ma->ray_mirror = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
|
|
|
case MAT_IN_ALPHA:
|
|
|
|
ma->alpha = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
|
|
|
case MAT_IN_TRANSLUCENCY:
|
|
|
|
ma->translucency = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (a) {
|
|
|
|
case MAT_IN_COLOR:
|
|
|
|
copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, &ma->r); break;
|
|
|
|
case MAT_IN_SPEC:
|
|
|
|
copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, &ma->specr); break;
|
|
|
|
case MAT_IN_REFL:
|
2013-03-18 18:25:05 +00:00
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->ref; break;
|
2013-03-18 16:34:57 +00:00
|
|
|
case MAT_IN_MIR:
|
|
|
|
copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, &ma->mirr); break;
|
|
|
|
case MAT_IN_AMB:
|
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->amb; break;
|
|
|
|
case MAT_IN_EMIT:
|
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->emit; break;
|
|
|
|
case MAT_IN_SPECTRA:
|
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->spectra; break;
|
|
|
|
case MAT_IN_RAY_MIRROR:
|
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->ray_mirror; break;
|
|
|
|
case MAT_IN_ALPHA:
|
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->alpha; break;
|
|
|
|
case MAT_IN_TRANSLUCENCY:
|
|
|
|
((bNodeSocketValueFloat *)sock->default_value)->value = ma->translucency; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-11 17:49:08 +00:00
|
|
|
}
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* ************* node type access ********** */
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
const char *nodeLabel(bNode *node)
|
2011-02-07 16:41:57 +00:00
|
|
|
{
|
2012-07-29 00:20:28 +00:00
|
|
|
if (node->label[0] != '\0')
|
2011-09-05 21:01:50 +00:00
|
|
|
return node->label;
|
|
|
|
else if (node->typeinfo->labelfunc)
|
|
|
|
return node->typeinfo->labelfunc(node);
|
|
|
|
else
|
2013-03-18 16:34:57 +00:00
|
|
|
return IFACE_(node->typeinfo->ui_name);
|
2011-02-07 16:41:57 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_type_base_defaults(bNodeType *ntype)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
/* default size values */
|
|
|
|
node_type_size_preset(ntype, NODE_SIZE_DEFAULT);
|
|
|
|
ntype->height = 100;
|
|
|
|
ntype->minheight = 30;
|
|
|
|
ntype->maxheight = FLT_MAX;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2011-02-07 16:41:57 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* allow this node for any tree type */
|
|
|
|
static int node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(ntree))
|
2008-11-12 22:03:11 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
return TRUE;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* use the basic poll function */
|
|
|
|
static int node_poll_instance_default(bNode *node, bNodeTree *ntree)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
return node->typeinfo->poll(node->typeinfo, ntree);
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
/* Use static type info header to map static int type to identifier string and RNA struct type.
|
|
|
|
* Associate the RNA struct type with the bNodeType.
|
|
|
|
* Dynamically registered nodes will create an RNA type at runtime
|
|
|
|
* and call RNA_struct_blender_type_set, so this only needs to be done for old RNA types
|
|
|
|
* created in makesrna, which can not be associated to a bNodeType immediately,
|
|
|
|
* since bNodeTypes are registered afterward ...
|
|
|
|
*/
|
|
|
|
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
|
|
|
|
case ID: \
|
|
|
|
BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \
|
|
|
|
ntype->ext.srna = RNA_struct_find(#Category #StructName); \
|
|
|
|
BLI_assert(ntype->ext.srna != NULL); \
|
|
|
|
RNA_struct_blender_type_set(ntype->ext.srna, ntype); \
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
#include "NOD_static_types.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* make sure we have a valid type (everything registered) */
|
|
|
|
BLI_assert(ntype->idname[0] != '\0');
|
|
|
|
|
|
|
|
ntype->type = type;
|
|
|
|
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
|
|
|
|
ntype->nclass = nclass;
|
|
|
|
ntype->flag = flag;
|
|
|
|
|
|
|
|
node_type_base_defaults(ntype);
|
|
|
|
|
|
|
|
ntype->poll = node_poll_default;
|
|
|
|
ntype->poll_instance = node_poll_instance_default;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2007-03-26 15:07:38 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_base_custom(bNodeType *ntype, const char *idname, const char *name, short nclass, short flag)
|
2011-02-07 09:33:36 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname));
|
|
|
|
ntype->type = NODE_CUSTOM;
|
|
|
|
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
|
2011-02-07 09:33:36 +00:00
|
|
|
ntype->nclass = nclass;
|
|
|
|
ntype->flag = flag;
|
2011-11-20 16:38:23 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node_type_base_defaults(ntype);
|
|
|
|
}
|
2011-11-20 16:38:23 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static bool unique_socket_template_identifier_check(void *arg, const char *name)
|
|
|
|
{
|
|
|
|
bNodeSocketTemplate *ntemp;
|
2013-03-18 18:25:05 +00:00
|
|
|
struct {bNodeSocketTemplate *list; bNodeSocketTemplate *ntemp;} *data = arg;
|
2013-02-22 10:46:27 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
for (ntemp = data->list; ntemp->type >= 0; ++ntemp) {
|
|
|
|
if (ntemp != data->ntemp) {
|
2013-03-18 18:25:05 +00:00
|
|
|
if (STREQ(ntemp->identifier, name)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unique_socket_template_identifier(bNodeSocketTemplate *list, bNodeSocketTemplate *ntemp, const char defname[], char delim)
|
|
|
|
{
|
|
|
|
struct {bNodeSocketTemplate *list; bNodeSocketTemplate *ntemp;} data;
|
2013-03-18 18:25:05 +00:00
|
|
|
data.list = list;
|
2013-03-18 16:34:57 +00:00
|
|
|
data.ntemp = ntemp;
|
|
|
|
|
|
|
|
BLI_uniquename_cb(unique_socket_template_identifier_check, &data, defname, delim, ntemp->identifier, sizeof(ntemp->identifier));
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocketTemplate *ntemp;
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
ntype->inputs = inputs;
|
|
|
|
ntype->outputs = outputs;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* automatically generate unique identifiers */
|
|
|
|
if (inputs) {
|
|
|
|
/* clear identifier strings (uninitialized memory) */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (ntemp = inputs; ntemp->type >= 0; ++ntemp)
|
2013-03-18 16:34:57 +00:00
|
|
|
ntemp->identifier[0] = '\0';
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
for (ntemp = inputs; ntemp->type >= 0; ++ntemp) {
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
|
|
|
|
unique_socket_template_identifier(inputs, ntemp, ntemp->identifier, '_');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (outputs) {
|
|
|
|
/* clear identifier strings (uninitialized memory) */
|
2013-03-18 18:25:05 +00:00
|
|
|
for (ntemp = outputs; ntemp->type >= 0; ++ntemp)
|
2013-03-18 16:34:57 +00:00
|
|
|
ntemp->identifier[0] = '\0';
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
for (ntemp = outputs; ntemp->type >= 0; ++ntemp) {
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
|
|
|
|
unique_socket_template_identifier(outputs, ntemp, ntemp->identifier, '_');
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 09:33:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_init(struct bNodeType *ntype, void (*initfunc)(struct bNodeTree *ntree, struct bNode *node))
|
2011-02-08 09:02:16 +00:00
|
|
|
{
|
|
|
|
ntype->initfunc = initfunc;
|
|
|
|
}
|
|
|
|
|
2011-02-07 09:33:36 +00:00
|
|
|
void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth)
|
|
|
|
{
|
|
|
|
ntype->width = width;
|
|
|
|
ntype->minwidth = minwidth;
|
2011-09-05 21:01:50 +00:00
|
|
|
if (maxwidth <= minwidth)
|
|
|
|
ntype->maxwidth = FLT_MAX;
|
|
|
|
else
|
|
|
|
ntype->maxwidth = maxwidth;
|
2011-02-07 09:33:36 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 10:46:27 +00:00
|
|
|
void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case NODE_SIZE_DEFAULT:
|
|
|
|
node_type_size(ntype, 140, 100, 320);
|
|
|
|
break;
|
|
|
|
case NODE_SIZE_SMALL:
|
|
|
|
node_type_size(ntype, 100, 80, 320);
|
|
|
|
break;
|
2013-05-21 20:21:46 +00:00
|
|
|
case NODE_SIZE_MIDDLE:
|
|
|
|
node_type_size(ntype, 150, 120, 320);
|
|
|
|
break;
|
2013-02-22 10:46:27 +00:00
|
|
|
case NODE_SIZE_LARGE:
|
2013-05-21 20:21:46 +00:00
|
|
|
node_type_size(ntype, 240, 140, 320);
|
2013-02-22 10:46:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_storage(bNodeType *ntype,
|
|
|
|
const char *storagename,
|
|
|
|
void (*freefunc)(struct bNode *node),
|
|
|
|
void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, struct bNode *src_node))
|
2011-02-07 09:33:36 +00:00
|
|
|
{
|
2011-02-08 09:02:16 +00:00
|
|
|
if (storagename)
|
2011-09-26 18:51:10 +00:00
|
|
|
BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
|
2011-02-08 09:02:16 +00:00
|
|
|
else
|
|
|
|
ntype->storagename[0] = '\0';
|
2013-03-18 16:34:57 +00:00
|
|
|
ntype->copyfunc = copyfunc;
|
|
|
|
ntype->freefunc = freefunc;
|
2011-02-07 09:33:36 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *))
|
|
|
|
{
|
|
|
|
ntype->labelfunc = labelfunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_type_update(struct bNodeType *ntype,
|
2012-07-29 00:20:28 +00:00
|
|
|
void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
|
|
|
|
void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id))
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
ntype->updatefunc = updatefunc;
|
|
|
|
ntype->verifyfunc = verifyfunc;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction initexecfunc, NodeFreeExecFunction freeexecfunc, NodeExecFunction execfunc)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
ntype->initexecfunc = initexecfunc;
|
|
|
|
ntype->freeexecfunc = freeexecfunc;
|
2013-03-18 16:34:57 +00:00
|
|
|
ntype->execfunc = execfunc;
|
2011-11-20 16:38:23 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpufunc)
|
2011-02-07 09:33:36 +00:00
|
|
|
{
|
|
|
|
ntype->gpufunc = gpufunc;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_type_internal_links(bNodeType *ntype, void (*update_internal_links)(bNodeTree *, bNode *))
|
2011-02-08 12:54:32 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
ntype->update_internal_links = update_internal_links;
|
2011-02-08 12:54:32 +00:00
|
|
|
}
|
2011-02-07 09:33:36 +00:00
|
|
|
|
2011-11-02 19:24:30 +00:00
|
|
|
void node_type_compatibility(struct bNodeType *ntype, short compatibility)
|
|
|
|
{
|
|
|
|
ntype->compatibility = compatibility;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
/* callbacks for undefined types */
|
|
|
|
|
|
|
|
static int node_undefined_poll(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(nodetree))
|
|
|
|
{
|
|
|
|
/* this type can not be added deliberately, it's just a placeholder */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* register fallback types used for undefined tree, nodes, sockets */
|
|
|
|
static void register_undefined_types(void)
|
|
|
|
{
|
|
|
|
/* Note: these types are not registered in the type hashes,
|
|
|
|
* they are just used as placeholders in case the actual types are not registered.
|
|
|
|
*/
|
|
|
|
|
|
|
|
strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined");
|
|
|
|
strcpy(NodeTreeTypeUndefined.ui_name, "Undefined");
|
|
|
|
strcpy(NodeTreeTypeUndefined.ui_description, "Undefined Node Tree Type");
|
|
|
|
|
|
|
|
node_type_base_custom(&NodeTypeUndefined, "NodeUndefined", "Undefined", 0, 0);
|
|
|
|
NodeTypeUndefined.poll = node_undefined_poll;
|
|
|
|
|
|
|
|
BLI_strncpy(NodeSocketTypeUndefined.idname, "NodeSocketUndefined", sizeof(NodeSocketTypeUndefined.idname));
|
|
|
|
/* extra type info for standard socket types */
|
|
|
|
NodeSocketTypeUndefined.type = SOCK_CUSTOM;
|
|
|
|
NodeSocketTypeUndefined.subtype = PROP_NONE;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void registerCompositNodes(void)
|
|
|
|
{
|
|
|
|
register_node_type_cmp_group();
|
|
|
|
|
|
|
|
register_node_type_cmp_rlayers();
|
|
|
|
register_node_type_cmp_image();
|
|
|
|
register_node_type_cmp_texture();
|
|
|
|
register_node_type_cmp_value();
|
|
|
|
register_node_type_cmp_rgb();
|
|
|
|
register_node_type_cmp_curve_time();
|
|
|
|
register_node_type_cmp_movieclip();
|
|
|
|
|
|
|
|
register_node_type_cmp_composite();
|
|
|
|
register_node_type_cmp_viewer();
|
|
|
|
register_node_type_cmp_splitviewer();
|
|
|
|
register_node_type_cmp_output_file();
|
|
|
|
register_node_type_cmp_view_levels();
|
|
|
|
|
|
|
|
register_node_type_cmp_curve_rgb();
|
|
|
|
register_node_type_cmp_mix_rgb();
|
|
|
|
register_node_type_cmp_hue_sat();
|
|
|
|
register_node_type_cmp_brightcontrast();
|
|
|
|
register_node_type_cmp_gamma();
|
|
|
|
register_node_type_cmp_invert();
|
|
|
|
register_node_type_cmp_alphaover();
|
|
|
|
register_node_type_cmp_zcombine();
|
|
|
|
register_node_type_cmp_colorbalance();
|
|
|
|
register_node_type_cmp_huecorrect();
|
|
|
|
|
|
|
|
register_node_type_cmp_normal();
|
|
|
|
register_node_type_cmp_curve_vec();
|
|
|
|
register_node_type_cmp_map_value();
|
|
|
|
register_node_type_cmp_map_range();
|
|
|
|
register_node_type_cmp_normalize();
|
|
|
|
|
|
|
|
register_node_type_cmp_filter();
|
|
|
|
register_node_type_cmp_blur();
|
|
|
|
register_node_type_cmp_dblur();
|
|
|
|
register_node_type_cmp_bilateralblur();
|
|
|
|
register_node_type_cmp_vecblur();
|
|
|
|
register_node_type_cmp_dilateerode();
|
|
|
|
register_node_type_cmp_inpaint();
|
|
|
|
register_node_type_cmp_despeckle();
|
|
|
|
register_node_type_cmp_defocus();
|
|
|
|
|
|
|
|
register_node_type_cmp_valtorgb();
|
|
|
|
register_node_type_cmp_rgbtobw();
|
|
|
|
register_node_type_cmp_setalpha();
|
|
|
|
register_node_type_cmp_idmask();
|
|
|
|
register_node_type_cmp_math();
|
|
|
|
register_node_type_cmp_seprgba();
|
|
|
|
register_node_type_cmp_combrgba();
|
|
|
|
register_node_type_cmp_sephsva();
|
|
|
|
register_node_type_cmp_combhsva();
|
|
|
|
register_node_type_cmp_sepyuva();
|
|
|
|
register_node_type_cmp_combyuva();
|
|
|
|
register_node_type_cmp_sepycca();
|
|
|
|
register_node_type_cmp_combycca();
|
|
|
|
register_node_type_cmp_premulkey();
|
|
|
|
|
|
|
|
register_node_type_cmp_diff_matte();
|
|
|
|
register_node_type_cmp_distance_matte();
|
|
|
|
register_node_type_cmp_chroma_matte();
|
|
|
|
register_node_type_cmp_color_matte();
|
|
|
|
register_node_type_cmp_channel_matte();
|
|
|
|
register_node_type_cmp_color_spill();
|
|
|
|
register_node_type_cmp_luma_matte();
|
|
|
|
register_node_type_cmp_doubleedgemask();
|
|
|
|
register_node_type_cmp_keyingscreen();
|
|
|
|
register_node_type_cmp_keying();
|
|
|
|
|
|
|
|
register_node_type_cmp_translate();
|
|
|
|
register_node_type_cmp_rotate();
|
|
|
|
register_node_type_cmp_scale();
|
|
|
|
register_node_type_cmp_flip();
|
|
|
|
register_node_type_cmp_crop();
|
|
|
|
register_node_type_cmp_displace();
|
|
|
|
register_node_type_cmp_mapuv();
|
|
|
|
register_node_type_cmp_glare();
|
|
|
|
register_node_type_cmp_tonemap();
|
|
|
|
register_node_type_cmp_lensdist();
|
|
|
|
register_node_type_cmp_transform();
|
|
|
|
register_node_type_cmp_stabilize2d();
|
|
|
|
register_node_type_cmp_moviedistortion();
|
|
|
|
|
|
|
|
register_node_type_cmp_colorcorrection();
|
|
|
|
register_node_type_cmp_boxmask();
|
|
|
|
register_node_type_cmp_ellipsemask();
|
|
|
|
register_node_type_cmp_bokehimage();
|
|
|
|
register_node_type_cmp_bokehblur();
|
|
|
|
register_node_type_cmp_switch();
|
|
|
|
register_node_type_cmp_pixelate();
|
|
|
|
|
|
|
|
register_node_type_cmp_mask();
|
|
|
|
register_node_type_cmp_trackpos();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void registerShaderNodes(void)
|
|
|
|
{
|
|
|
|
register_node_type_sh_group();
|
|
|
|
|
|
|
|
register_node_type_sh_output();
|
|
|
|
register_node_type_sh_material();
|
|
|
|
register_node_type_sh_camera();
|
|
|
|
register_node_type_sh_gamma();
|
|
|
|
register_node_type_sh_brightcontrast();
|
|
|
|
register_node_type_sh_value();
|
|
|
|
register_node_type_sh_rgb();
|
2013-05-20 15:58:37 +00:00
|
|
|
register_node_type_sh_wireframe();
|
2013-06-09 20:46:22 +00:00
|
|
|
register_node_type_sh_wavelength();
|
2013-03-18 16:34:57 +00:00
|
|
|
register_node_type_sh_mix_rgb();
|
|
|
|
register_node_type_sh_valtorgb();
|
|
|
|
register_node_type_sh_rgbtobw();
|
|
|
|
register_node_type_sh_texture();
|
|
|
|
register_node_type_sh_normal();
|
|
|
|
register_node_type_sh_geom();
|
|
|
|
register_node_type_sh_mapping();
|
|
|
|
register_node_type_sh_curve_vec();
|
|
|
|
register_node_type_sh_curve_rgb();
|
|
|
|
register_node_type_sh_math();
|
|
|
|
register_node_type_sh_vect_math();
|
|
|
|
register_node_type_sh_squeeze();
|
|
|
|
register_node_type_sh_material_ext();
|
|
|
|
register_node_type_sh_invert();
|
|
|
|
register_node_type_sh_seprgb();
|
|
|
|
register_node_type_sh_combrgb();
|
|
|
|
register_node_type_sh_hue_sat();
|
|
|
|
|
|
|
|
register_node_type_sh_attribute();
|
|
|
|
register_node_type_sh_geometry();
|
|
|
|
register_node_type_sh_light_path();
|
|
|
|
register_node_type_sh_light_falloff();
|
|
|
|
register_node_type_sh_object_info();
|
|
|
|
register_node_type_sh_fresnel();
|
|
|
|
register_node_type_sh_layer_weight();
|
|
|
|
register_node_type_sh_tex_coord();
|
|
|
|
register_node_type_sh_particle_info();
|
|
|
|
register_node_type_sh_bump();
|
|
|
|
|
|
|
|
register_node_type_sh_background();
|
|
|
|
register_node_type_sh_bsdf_anisotropic();
|
|
|
|
register_node_type_sh_bsdf_diffuse();
|
|
|
|
register_node_type_sh_bsdf_glossy();
|
|
|
|
register_node_type_sh_bsdf_glass();
|
|
|
|
register_node_type_sh_bsdf_translucent();
|
|
|
|
register_node_type_sh_bsdf_transparent();
|
|
|
|
register_node_type_sh_bsdf_velvet();
|
2013-05-23 17:45:20 +00:00
|
|
|
register_node_type_sh_bsdf_toon();
|
2013-03-18 16:34:57 +00:00
|
|
|
register_node_type_sh_emission();
|
|
|
|
register_node_type_sh_holdout();
|
|
|
|
//register_node_type_sh_volume_transparent();
|
|
|
|
//register_node_type_sh_volume_isotropic();
|
2013-04-01 20:26:52 +00:00
|
|
|
register_node_type_sh_subsurface_scattering();
|
2013-03-18 16:34:57 +00:00
|
|
|
register_node_type_sh_mix_shader();
|
|
|
|
register_node_type_sh_add_shader();
|
|
|
|
|
|
|
|
register_node_type_sh_output_lamp();
|
|
|
|
register_node_type_sh_output_material();
|
|
|
|
register_node_type_sh_output_world();
|
|
|
|
|
|
|
|
register_node_type_sh_tex_image();
|
|
|
|
register_node_type_sh_tex_environment();
|
|
|
|
register_node_type_sh_tex_sky();
|
|
|
|
register_node_type_sh_tex_noise();
|
|
|
|
register_node_type_sh_tex_wave();
|
|
|
|
register_node_type_sh_tex_voronoi();
|
|
|
|
register_node_type_sh_tex_musgrave();
|
|
|
|
register_node_type_sh_tex_gradient();
|
|
|
|
register_node_type_sh_tex_magic();
|
|
|
|
register_node_type_sh_tex_checker();
|
|
|
|
register_node_type_sh_tex_brick();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void registerTextureNodes(void)
|
|
|
|
{
|
|
|
|
register_node_type_tex_group();
|
|
|
|
|
|
|
|
|
|
|
|
register_node_type_tex_math();
|
|
|
|
register_node_type_tex_mix_rgb();
|
|
|
|
register_node_type_tex_valtorgb();
|
|
|
|
register_node_type_tex_rgbtobw();
|
|
|
|
register_node_type_tex_valtonor();
|
|
|
|
register_node_type_tex_curve_rgb();
|
|
|
|
register_node_type_tex_curve_time();
|
|
|
|
register_node_type_tex_invert();
|
|
|
|
register_node_type_tex_hue_sat();
|
|
|
|
register_node_type_tex_coord();
|
|
|
|
register_node_type_tex_distance();
|
|
|
|
register_node_type_tex_compose();
|
|
|
|
register_node_type_tex_decompose();
|
|
|
|
|
|
|
|
register_node_type_tex_output();
|
|
|
|
register_node_type_tex_viewer();
|
|
|
|
register_node_type_sh_script();
|
|
|
|
register_node_type_sh_tangent();
|
|
|
|
register_node_type_sh_normal_map();
|
|
|
|
register_node_type_sh_hair_info();
|
|
|
|
|
|
|
|
register_node_type_tex_checker();
|
|
|
|
register_node_type_tex_texture();
|
|
|
|
register_node_type_tex_bricks();
|
|
|
|
register_node_type_tex_image();
|
|
|
|
register_node_type_sh_bsdf_refraction();
|
|
|
|
register_node_type_sh_ambient_occlusion();
|
|
|
|
|
|
|
|
register_node_type_tex_rotate();
|
|
|
|
register_node_type_tex_translate();
|
|
|
|
register_node_type_tex_scale();
|
|
|
|
register_node_type_tex_at();
|
|
|
|
|
|
|
|
register_node_type_tex_proc_voronoi();
|
|
|
|
register_node_type_tex_proc_blend();
|
|
|
|
register_node_type_tex_proc_magic();
|
|
|
|
register_node_type_tex_proc_marble();
|
|
|
|
register_node_type_tex_proc_clouds();
|
|
|
|
register_node_type_tex_proc_wood();
|
|
|
|
register_node_type_tex_proc_musgrave();
|
|
|
|
register_node_type_tex_proc_noise();
|
|
|
|
register_node_type_tex_proc_stucci();
|
|
|
|
register_node_type_tex_proc_distnoise();
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
|
|
|
|
2007-03-26 15:07:38 +00:00
|
|
|
void init_nodesystem(void)
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
nodetreetypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodetreetypes_hash gh");
|
|
|
|
nodetypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodetypes_hash gh");
|
|
|
|
nodesockettypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodesockettypes_hash gh");
|
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
register_undefined_types();
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
register_standard_node_socket_types();
|
|
|
|
|
|
|
|
register_node_tree_type_cmp();
|
|
|
|
register_node_tree_type_sh();
|
|
|
|
register_node_tree_type_tex();
|
|
|
|
|
|
|
|
register_node_type_frame();
|
|
|
|
register_node_type_reroute();
|
|
|
|
register_node_type_group_input();
|
|
|
|
register_node_type_group_output();
|
2012-08-02 09:52:37 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
registerCompositNodes();
|
|
|
|
registerShaderNodes();
|
|
|
|
registerTextureNodes();
|
2007-03-26 15:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void free_nodesystem(void)
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
NODE_TYPES_BEGIN(nt)
|
2013-03-18 18:25:05 +00:00
|
|
|
if (nt->ext.free) {
|
2013-03-18 16:34:57 +00:00
|
|
|
nt->ext.free(nt->ext.data);
|
|
|
|
}
|
|
|
|
NODE_TYPES_END
|
|
|
|
|
|
|
|
NODE_SOCKET_TYPES_BEGIN(st)
|
2013-03-18 18:25:05 +00:00
|
|
|
if (st->ext_socket.free)
|
2013-03-18 16:34:57 +00:00
|
|
|
st->ext_socket.free(st->ext_socket.data);
|
2013-03-18 18:25:05 +00:00
|
|
|
if (st->ext_interface.free)
|
2013-03-18 16:34:57 +00:00
|
|
|
st->ext_interface.free(st->ext_interface.data);
|
|
|
|
NODE_SOCKET_TYPES_END
|
|
|
|
|
|
|
|
NODE_TREE_TYPES_BEGIN(nt)
|
2013-03-18 18:25:05 +00:00
|
|
|
if (nt->ext.free) {
|
2013-03-18 16:34:57 +00:00
|
|
|
nt->ext.free(nt->ext.data);
|
|
|
|
}
|
|
|
|
NODE_TREE_TYPES_END
|
|
|
|
|
|
|
|
BLI_ghash_free(nodetypes_hash, NULL, node_free_type);
|
|
|
|
nodetypes_hash = NULL;
|
|
|
|
|
|
|
|
BLI_ghash_free(nodesockettypes_hash, NULL, node_free_socket_type);
|
|
|
|
nodesockettypes_hash = NULL;
|
|
|
|
|
|
|
|
BLI_ghash_free(nodetreetypes_hash, NULL, ntree_free_type);
|
|
|
|
nodetreetypes_hash = NULL;
|
2007-03-26 15:07:38 +00:00
|
|
|
}
|
2009-08-15 16:43:03 +00:00
|
|
|
|
2012-05-05 14:33:36 +00:00
|
|
|
/* called from BKE_scene_unlink, when deleting a scene goes over all scenes
|
2009-08-15 16:43:03 +00:00
|
|
|
* other than the input, checks if they have render layer nodes referencing
|
|
|
|
* the to-be-deleted scene, and resets them to NULL. */
|
|
|
|
|
|
|
|
/* XXX needs to get current scene then! */
|
|
|
|
void clear_scene_in_nodes(Main *bmain, Scene *sce)
|
|
|
|
{
|
|
|
|
Scene *sce1;
|
|
|
|
bNode *node;
|
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next) {
|
|
|
|
if (sce1 != sce) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sce1->nodetree) {
|
2012-07-29 00:20:28 +00:00
|
|
|
for (node = sce1->nodetree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == CMP_NODE_R_LAYERS) {
|
|
|
|
Scene *nodesce = (Scene *)node->id;
|
2009-08-15 16:43:03 +00:00
|
|
|
|
2012-07-29 00:20:28 +00:00
|
|
|
if (nodesce == sce) node->id = NULL;
|
2009-08-15 16:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-26 22:37:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* NodeTree Iterator Helpers (FOREACH_NODETREE) */
|
|
|
|
|
|
|
|
void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain)
|
|
|
|
{
|
|
|
|
ntreeiter->ngroup = bmain->nodetree.first;
|
|
|
|
ntreeiter->scene = bmain->scene.first;
|
|
|
|
ntreeiter->mat = bmain->mat.first;
|
|
|
|
ntreeiter->tex = bmain->tex.first;
|
|
|
|
ntreeiter->lamp = bmain->lamp.first;
|
|
|
|
ntreeiter->world = bmain->world.first;
|
|
|
|
}
|
|
|
|
bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
|
|
|
|
bNodeTree **r_nodetree, struct ID **r_id)
|
|
|
|
{
|
|
|
|
if (ntreeiter->ngroup) {
|
|
|
|
*r_nodetree = ntreeiter->ngroup;
|
|
|
|
*r_id = (ID *)ntreeiter->ngroup;
|
|
|
|
ntreeiter->ngroup = ntreeiter->ngroup->id.next;
|
|
|
|
}
|
|
|
|
else if (ntreeiter->scene) {
|
|
|
|
*r_nodetree = ntreeiter->scene->nodetree;
|
|
|
|
*r_id = (ID *)ntreeiter->scene;
|
|
|
|
ntreeiter->scene = ntreeiter->scene->id.next;
|
|
|
|
}
|
|
|
|
else if (ntreeiter->mat) {
|
|
|
|
*r_nodetree = ntreeiter->mat->nodetree;
|
|
|
|
*r_id = (ID *)ntreeiter->mat;
|
|
|
|
ntreeiter->mat = ntreeiter->mat->id.next;
|
|
|
|
}
|
|
|
|
else if (ntreeiter->tex) {
|
|
|
|
*r_nodetree = ntreeiter->tex->nodetree;
|
|
|
|
*r_id = (ID *)ntreeiter->tex;
|
|
|
|
ntreeiter->tex = ntreeiter->tex->id.next;
|
|
|
|
}
|
|
|
|
else if (ntreeiter->lamp) {
|
|
|
|
*r_nodetree = ntreeiter->lamp->nodetree;
|
|
|
|
*r_id = (ID *)ntreeiter->lamp;
|
|
|
|
ntreeiter->lamp = ntreeiter->lamp->id.next;
|
|
|
|
}
|
|
|
|
else if (ntreeiter->world) {
|
|
|
|
*r_nodetree = ntreeiter->world->nodetree;
|
|
|
|
*r_id = (ID *)ntreeiter->world;
|
|
|
|
ntreeiter->world = ntreeiter->world->id.next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|