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-06-19 09:32:37 +00:00
|
|
|
#if 0 /* pynodes commented for now */
|
|
|
|
# ifdef WITH_PYTHON
|
|
|
|
# include <Python.h>
|
|
|
|
# endif
|
2008-10-29 16:49:51 +00:00
|
|
|
#endif
|
|
|
|
|
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"
|
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"
|
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"
|
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2011-02-07 09:33:36 +00:00
|
|
|
#include "BKE_node.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
#include "BKE_utildefines.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BKE_utildefines.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
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "RNA_access.h"
|
2007-03-24 18:41:54 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "NOD_socket.h"
|
|
|
|
#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
|
|
|
|
2007-03-26 15:07:38 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *ntreeGetType(int type)
|
|
|
|
{
|
|
|
|
static bNodeTreeType *types[NUM_NTREE_TYPES];
|
|
|
|
static int types_init = 1;
|
|
|
|
if (types_init) {
|
|
|
|
types[NTREE_SHADER] = &ntreeType_Shader;
|
|
|
|
types[NTREE_COMPOSIT] = &ntreeType_Composite;
|
|
|
|
types[NTREE_TEXTURE] = &ntreeType_Texture;
|
|
|
|
types_init = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (type >= 0 && type < NUM_NTREE_TYPES) {
|
2011-09-05 21:01:50 +00:00
|
|
|
return types[type];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
static bNodeType *node_get_type(bNodeTree *ntree, int 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
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeType *ntype = ntreeGetType(ntree->type)->node_types.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (; ntype; ntype= ntype->next)
|
|
|
|
if (ntype->type==type)
|
2011-02-21 13:47:49 +00:00
|
|
|
return ntype;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeType *ntreeGetNodeType(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
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
return node_get_type(ntree, ntree->nodetype);
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeSocketType *ntreeGetSocketType(int type)
|
|
|
|
{
|
|
|
|
static bNodeSocketType *types[NUM_SOCKET_TYPES]= {NULL};
|
|
|
|
static int types_init = 1;
|
|
|
|
|
|
|
|
if (types_init) {
|
|
|
|
node_socket_type_init(types);
|
|
|
|
types_init= 0;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (type < NUM_SOCKET_TYPES) {
|
2011-09-05 21:01:50 +00:00
|
|
|
return types[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
|
|
|
else {
|
2011-09-05 21:01:50 +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
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ntreeInitTypes(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node, *next;
|
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-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= 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
|
|
|
next= node->next;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
node->typeinfo= node_get_type(ntree, node->type);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->type==NODE_DYNAMIC) {
|
2011-09-05 21:01:50 +00:00
|
|
|
/* needed info if the pynode script fails now: */
|
|
|
|
node->storage= ntree;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->id!=NULL) { /* not an empty script node */
|
2012-04-29 15:47:02 +00:00
|
|
|
node->custom1 = 0;
|
|
|
|
node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ADDEXIST);
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
// if (node->typeinfo)
|
2011-09-05 21:01:50 +00:00
|
|
|
// node->typeinfo->initfunc(node);
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->typeinfo==NULL) {
|
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
|
|
|
printf("Error: Node type %s doesn't exist anymore, removed\n", node->name);
|
|
|
|
nodeFreeNode(ntree, 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
|
|
|
}
|
|
|
|
|
|
|
|
ntree->init |= NTREE_TYPE_INIT;
|
|
|
|
}
|
|
|
|
|
2011-09-05 23:40:52 +00:00
|
|
|
static bNodeSocket *make_socket(bNodeTree *UNUSED(ntree), int in_out, const char *name, int type)
|
2008-02-09 23:17:15 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock;
|
|
|
|
|
|
|
|
sock= MEM_callocN(sizeof(bNodeSocket), "sock");
|
|
|
|
|
|
|
|
BLI_strncpy(sock->name, name, NODE_MAXSTR);
|
|
|
|
sock->limit = (in_out==SOCK_IN ? 1 : 0xFFF);
|
|
|
|
sock->type= type;
|
|
|
|
sock->storage = NULL;
|
|
|
|
|
2012-01-20 13:27:54 +00:00
|
|
|
sock->default_value = node_socket_make_default_value(type);
|
|
|
|
node_socket_init_default_value(type, sock->default_value);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
return sock;
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, int in_out, const char *name, int 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
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock = make_socket(ntree, in_out, name, type);
|
|
|
|
if (in_out==SOCK_IN)
|
|
|
|
BLI_addtail(&node->inputs, sock);
|
|
|
|
else if (in_out==SOCK_OUT)
|
|
|
|
BLI_addtail(&node->outputs, 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;
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, bNodeSocket *next_sock, const char *name, int type)
|
2011-02-21 13:47:49 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock = make_socket(ntree, in_out, name, type);
|
|
|
|
if (in_out==SOCK_IN)
|
|
|
|
BLI_insertlinkbefore(&node->inputs, next_sock, sock);
|
|
|
|
else if (in_out==SOCK_OUT)
|
|
|
|
BLI_insertlinkbefore(&node->outputs, 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;
|
|
|
|
}
|
|
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
for (link= ntree->links.first; link; link= next) {
|
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
|
|
|
next= link->next;
|
2012-03-24 06:18:31 +00:00
|
|
|
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
|
|
|
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
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
|
|
|
{
|
|
|
|
bNodeSocket *sock;
|
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-03-24 06:18:31 +00:00
|
|
|
for (link= ntree->links.first; link; link= next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
next= link->next;
|
2012-03-24 06:18:31 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
for (sock=node->inputs.first; sock; sock=sock->next)
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
2011-09-05 21:01:50 +00:00
|
|
|
BLI_freelistN(&node->inputs);
|
|
|
|
for (sock=node->outputs.first; sock; sock=sock->next)
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
2011-09-05 21:01:50 +00:00
|
|
|
BLI_freelistN(&node->outputs);
|
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 */
|
2011-02-22 20:24:06 +00:00
|
|
|
int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex, int *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;
|
2006-12-20 17:57:56 +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-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
for (index=0, tsock= node->inputs.first; tsock; tsock= tsock->next, index++) {
|
|
|
|
if (tsock==sock) {
|
2011-02-22 20:24:06 +00:00
|
|
|
if (in_out) *in_out= SOCK_IN;
|
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;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (index=0, tsock= node->outputs.first; tsock; tsock= tsock->next, index++) {
|
|
|
|
if (tsock==sock) {
|
2011-02-22 20:24:06 +00:00
|
|
|
if (in_out) *in_out= SOCK_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
|
|
|
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) {
|
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
|
|
|
*nodep= node;
|
2012-03-24 06:18:31 +00:00
|
|
|
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
|
|
|
|
|
|
|
*nodep= NULL;
|
|
|
|
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 ********** */
|
|
|
|
static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype)
|
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
|
|
|
bNodeSocketTemplate *sockdef;
|
2011-09-20 08:48:48 +00:00
|
|
|
/* bNodeSocket *sock; */ /* UNUSED */
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->inputs) {
|
2011-09-05 21:01:50 +00:00
|
|
|
sockdef= ntype->inputs;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (sockdef->type != -1) {
|
2011-09-20 08:48:48 +00:00
|
|
|
/* sock = */ node_add_input_from_template(ntree, node, sockdef);
|
2010-12-29 12:18:59 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
sockdef++;
|
2011-02-21 13:47:49 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->outputs) {
|
2011-09-05 21:01:50 +00:00
|
|
|
sockdef= ntype->outputs;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (sockdef->type != -1) {
|
2011-09-20 08:48:48 +00:00
|
|
|
/* sock = */ node_add_output_from_template(ntree, node, sockdef);
|
2010-12-29 12:18:59 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
sockdef++;
|
2010-12-29 12:18:59 +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
|
|
|
/* 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
|
|
|
{
|
2010-02-18 10:14:49 +00:00
|
|
|
BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), sizeof(node->name));
|
2009-11-11 09:11:21 +00:00
|
|
|
}
|
2008-02-09 23:17:15 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp)
|
2008-02-09 23:17:15 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNode *node;
|
|
|
|
bNodeType *ntype;
|
|
|
|
|
|
|
|
ntype= node_get_type(ntree, ntemp->type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype == NULL) {
|
2011-09-05 21:01:50 +00:00
|
|
|
printf("nodeAddNodeType() error: '%d' type invalid\n", ntemp->type);
|
2011-04-23 08:02:29 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
/* validity check */
|
|
|
|
if (!nodeValid(ntree, ntemp))
|
|
|
|
return NULL;
|
2009-11-11 09:11:21 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
node= MEM_callocN(sizeof(bNode), "new node");
|
2008-02-09 23:17:15 +00:00
|
|
|
node->type= ntype->type;
|
2011-09-05 21:01:50 +00:00
|
|
|
node->typeinfo= ntype;
|
2008-02-09 23:17:15 +00:00
|
|
|
node->flag= NODE_SELECT|ntype->flag;
|
|
|
|
node->width= ntype->width;
|
2011-09-05 21:01:50 +00:00
|
|
|
node->miniwidth= 42.0f;
|
|
|
|
node->height= ntype->height;
|
|
|
|
|
|
|
|
node_add_sockets_from_type(ntree, node, ntype);
|
|
|
|
|
|
|
|
/* initialize the node name with the node label */
|
|
|
|
BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR);
|
|
|
|
nodeUniqueName(ntree, node);
|
|
|
|
|
|
|
|
BLI_addtail(&ntree->nodes, node);
|
|
|
|
|
2012-05-08 15:14:59 +00:00
|
|
|
if (ntype->initfunc!=NULL)
|
|
|
|
ntype->initfunc(ntree, node, ntemp);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nodeMakeDynamicType(bNode *node)
|
|
|
|
{
|
|
|
|
/* find SH_DYNAMIC_NODE ntype */
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeType *ntype= ntreeGetType(NTREE_SHADER)->node_types.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (ntype) {
|
|
|
|
if (ntype->type==NODE_DYNAMIC)
|
2008-02-09 23:17:15 +00:00
|
|
|
break;
|
|
|
|
ntype= ntype->next;
|
|
|
|
}
|
2007-03-25 23:54:39 +00:00
|
|
|
|
2008-02-09 23:17:15 +00:00
|
|
|
/* make own type struct to fill */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype) {
|
2008-02-09 23:17:15 +00:00
|
|
|
/*node->typeinfo= MEM_dupallocN(ntype);*/
|
|
|
|
bNodeType *newtype= MEM_callocN(sizeof(bNodeType), "dynamic bNodeType");
|
|
|
|
*newtype= *ntype;
|
2011-10-19 23:10:54 +00:00
|
|
|
BLI_strncpy(newtype->name, ntype->name, sizeof(newtype->name));
|
2008-02-09 23:17:15 +00:00
|
|
|
node->typeinfo= newtype;
|
|
|
|
}
|
|
|
|
}
|
2007-03-25 23:54:39 +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
|
|
|
/* 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
|
|
|
{
|
|
|
|
bNode *nnode= MEM_callocN(sizeof(bNode), "dupli node");
|
2008-02-24 22:27:40 +00:00
|
|
|
bNodeSocket *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
|
|
|
|
2005-12-18 23:08:22 +00:00
|
|
|
*nnode= *node;
|
2009-11-11 09:11:21 +00:00
|
|
|
nodeUniqueName(ntree, nnode);
|
|
|
|
|
2005-12-18 23:08:22 +00:00
|
|
|
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);
|
2008-02-24 22:27:40 +00:00
|
|
|
oldsock= node->inputs.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= nnode->inputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
|
2008-02-24 22:27:40 +00:00
|
|
|
oldsock->new_sock= sock;
|
2011-09-05 21:01:50 +00:00
|
|
|
sock->stack_index= 0;
|
|
|
|
|
2012-01-20 13:27:54 +00:00
|
|
|
sock->default_value = node_socket_make_default_value(oldsock->type);
|
|
|
|
node_socket_copy_default_value(oldsock->type, sock->default_value, oldsock->default_value);
|
2011-09-07 12:46:30 +00:00
|
|
|
|
|
|
|
/* XXX some compositor node (e.g. image, render layers) still store
|
|
|
|
* some persistent buffer data here, need to clear this to avoid dangling pointers.
|
|
|
|
*/
|
|
|
|
sock->cache = NULL;
|
2008-02-24 22:27:40 +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
|
|
|
|
2008-01-01 18:29:19 +00:00
|
|
|
BLI_duplicatelist(&nnode->outputs, &node->outputs);
|
2008-02-24 22:27:40 +00:00
|
|
|
oldsock= node->outputs.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= nnode->outputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
|
2008-02-24 22:27:40 +00:00
|
|
|
oldsock->new_sock= sock;
|
2011-09-05 21:01:50 +00:00
|
|
|
sock->stack_index= 0;
|
|
|
|
|
2012-01-20 13:27:54 +00:00
|
|
|
sock->default_value = node_socket_make_default_value(oldsock->type);
|
|
|
|
node_socket_copy_default_value(oldsock->type, sock->default_value, oldsock->default_value);
|
2011-09-07 12:46:30 +00:00
|
|
|
|
|
|
|
/* XXX some compositor node (e.g. image, render layers) still store
|
|
|
|
* some persistent buffer data here, need to clear this to avoid dangling pointers.
|
|
|
|
*/
|
|
|
|
sock->cache = NULL;
|
2006-01-28 15:21:04 +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
|
|
|
|
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
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->typeinfo->copystoragefunc)
|
2007-04-04 13:58:12 +00:00
|
|
|
node->typeinfo->copystoragefunc(node, nnode);
|
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-08-02 17:29:34 +00:00
|
|
|
node->new_node= nnode;
|
|
|
|
nnode->new_node= 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
|
|
|
nnode->preview= NULL;
|
2008-11-12 22:03:11 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
ntree->update |= NTREE_UPDATE_NODES;
|
|
|
|
|
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)
|
|
|
|
{
|
2011-01-17 15:16:08 +00:00
|
|
|
bNodeSocket *sock;
|
|
|
|
bNodeLink *link= NULL;
|
|
|
|
int from= 0, to= 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (fromnode) {
|
2011-01-17 15:16:08 +00:00
|
|
|
/* test valid input */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= fromnode->outputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==fromsock)
|
2011-01-17 15:16:08 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-01-17 15:16:08 +00:00
|
|
|
from= 1; /* OK */
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= fromnode->inputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==fromsock)
|
2011-01-17 15:16:08 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-01-17 15:16:08 +00:00
|
|
|
from= -1; /* OK but flip */
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
else {
|
|
|
|
/* check tree sockets */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= ntree->inputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==fromsock)
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-09-05 21:01:50 +00:00
|
|
|
from= 1; /* OK */
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= ntree->outputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==fromsock)
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-09-05 21:01:50 +00:00
|
|
|
from= -1; /* OK but flip */
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tonode) {
|
|
|
|
for (sock= tonode->inputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==tosock)
|
2011-01-17 15:16:08 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-01-17 15:16:08 +00:00
|
|
|
to= 1; /* OK */
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= tonode->outputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==tosock)
|
2011-01-17 15:16:08 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-01-17 15:16:08 +00:00
|
|
|
to= -1; /* OK but flip */
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
else {
|
|
|
|
/* check tree sockets */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= ntree->outputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==tosock)
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-09-05 21:01:50 +00:00
|
|
|
to= 1; /* OK */
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= ntree->inputs.first; sock; sock= sock->next)
|
|
|
|
if (sock==tosock)
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sock)
|
2011-09-05 21:01:50 +00:00
|
|
|
to= -1; /* OK but flip */
|
|
|
|
}
|
|
|
|
}
|
2005-12-18 23:08:22 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (from >= 0 && to >= 0) {
|
2011-01-17 15:16:08 +00:00
|
|
|
link= MEM_callocN(sizeof(bNodeLink), "link");
|
|
|
|
BLI_addtail(&ntree->links, link);
|
|
|
|
link->fromnode= fromnode;
|
|
|
|
link->fromsock= fromsock;
|
|
|
|
link->tonode= tonode;
|
|
|
|
link->tosock= tosock;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (from <= 0 && to <= 0) {
|
2011-01-17 15:16:08 +00:00
|
|
|
link= MEM_callocN(sizeof(bNodeLink), "link");
|
|
|
|
BLI_addtail(&ntree->links, link);
|
|
|
|
link->fromnode= tonode;
|
|
|
|
link->fromsock= tosock;
|
|
|
|
link->tonode= fromnode;
|
|
|
|
link->tosock= fromsock;
|
|
|
|
}
|
2005-12-18 23:08:22 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
ntree->update |= NTREE_UPDATE_LINKS;
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
BLI_remlink(&ntree->links, link);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (link->tosock)
|
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
|
|
|
link->tosock->link= NULL;
|
|
|
|
MEM_freeN(link);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
for (link= ntree->links.first; link; link= next) {
|
2010-01-04 04:26:28 +00:00
|
|
|
next= link->next;
|
2012-03-24 06:18:31 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-02-27 17:38:16 +00:00
|
|
|
void nodeInternalRelink(bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
|
|
|
bNodeLink *link, *link_next;
|
|
|
|
ListBase intlinks;
|
|
|
|
|
|
|
|
if (!node->typeinfo->internal_connect)
|
|
|
|
return;
|
|
|
|
|
|
|
|
intlinks = node->typeinfo->internal_connect(ntree, node);
|
|
|
|
|
|
|
|
/* store link pointers in output sockets, for efficient lookup */
|
|
|
|
for (link=intlinks.first; link; link=link->next)
|
|
|
|
link->tosock->link = link;
|
|
|
|
|
|
|
|
/* redirect downstream links */
|
|
|
|
for (link=ntree->links.first; link; link=link_next) {
|
|
|
|
link_next = link->next;
|
|
|
|
|
|
|
|
/* do we have internal link? */
|
|
|
|
if (link->fromnode==node) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
ntree->update |= NTREE_UPDATE_LINKS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove remaining upstream links */
|
|
|
|
for (link=ntree->links.first; link; link=link_next) {
|
|
|
|
link_next = link->next;
|
|
|
|
|
|
|
|
if (link->tonode==node)
|
|
|
|
nodeRemLink(ntree, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&intlinks);
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* transforms node location to area coords */
|
|
|
|
void nodeSpaceCoords(bNode *node, float *locx, float *locy)
|
|
|
|
{
|
|
|
|
if (node->parent) {
|
|
|
|
nodeSpaceCoords(node->parent, locx, locy);
|
|
|
|
*locx += node->locx;
|
|
|
|
*locy += node->locy;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*locx = node->locx;
|
|
|
|
*locy = node->locy;
|
|
|
|
}
|
|
|
|
}
|
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-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
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
float parentx, parenty;
|
|
|
|
|
|
|
|
node->parent = parent;
|
|
|
|
/* transform to parent space */
|
|
|
|
nodeSpaceCoords(parent, &parentx, &parenty);
|
|
|
|
node->locx -= parentx;
|
|
|
|
node->locy -= parenty;
|
|
|
|
}
|
2010-12-03 03:44:39 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void nodeDetachNode(struct bNode *node)
|
|
|
|
{
|
|
|
|
float parentx, parenty;
|
|
|
|
|
|
|
|
if (node->parent) {
|
|
|
|
/* transform to "global" (area) space */
|
|
|
|
nodeSpaceCoords(node->parent, &parentx, &parenty);
|
|
|
|
node->locx += parentx;
|
|
|
|
node->locy += parenty;
|
|
|
|
node->parent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bNodeTree *ntreeAddTree(const char *name, int type, int nodetype)
|
|
|
|
{
|
|
|
|
bNodeTree *ntree;
|
|
|
|
bNodeType *ntype;
|
|
|
|
|
|
|
|
/* trees are created as local trees if they of compositor, material or texture type,
|
|
|
|
* node groups and other tree types are created as library data.
|
|
|
|
*/
|
|
|
|
if (ELEM3(type, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE) && nodetype==0) {
|
2010-12-03 03:44:39 +00:00
|
|
|
ntree= MEM_callocN(sizeof(bNodeTree), "new node tree");
|
2010-12-07 10:15:09 +00:00
|
|
|
*( (short *)ntree->id.name )= ID_NT; /* not "type", as that is ntree->type */
|
2010-12-03 03:44:39 +00:00
|
|
|
BLI_strncpy(ntree->id.name+2, name, sizeof(ntree->id.name));
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
else
|
2012-05-05 14:03:12 +00:00
|
|
|
ntree= BKE_libblock_alloc(&G.main->nodetree, ID_NT, name);
|
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
|
|
|
ntree->type= type;
|
2011-09-05 21:01:50 +00:00
|
|
|
ntree->nodetype = nodetype;
|
|
|
|
|
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
|
|
|
ntreeInitTypes(ntree);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
ntype = node_get_type(ntree, ntree->nodetype);
|
|
|
|
if (ntype && ntype->inittreefunc)
|
|
|
|
ntype->inittreefunc(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
|
|
|
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.
|
2009-11-20 04:19:57 +00:00
|
|
|
*/
|
2011-02-11 09:37:58 +00:00
|
|
|
bNodeTree *ntreeCopyTree(bNodeTree *ntree)
|
2006-02-07 15:50:55 +00:00
|
|
|
{
|
|
|
|
bNodeTree *newtree;
|
2011-09-20 08:48:48 +00:00
|
|
|
bNode *node /*, *nnode */ /* UNUSED */, *last;
|
2011-02-21 13:47:49 +00:00
|
|
|
bNodeLink *link;
|
|
|
|
bNodeSocket *gsock, *oldgsock;
|
2006-02-07 15:50:55 +00:00
|
|
|
|
2012-03-24 06:18:31 +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-03-24 06:18:31 +00:00
|
|
|
for (newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
|
|
|
|
if (newtree==ntree) break;
|
|
|
|
if (newtree) {
|
2012-05-05 14:03:12 +00:00
|
|
|
newtree= BKE_libblock_copy(&ntree->id);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-02-11 09:37:58 +00:00
|
|
|
newtree= MEM_dupallocN(ntree);
|
2012-05-05 14:03:12 +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 */
|
2011-09-05 21:01:50 +00:00
|
|
|
newtree->execdata= NULL;
|
2011-03-03 18:53:07 +00:00
|
|
|
|
2011-02-11 09:37:58 +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-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
2006-08-02 17:29:34 +00:00
|
|
|
node->new_node= NULL;
|
2011-09-20 08:48:48 +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! */
|
|
|
|
if (node==last)
|
|
|
|
break;
|
2006-02-07 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
2011-02-21 13:47:49 +00:00
|
|
|
/* socket definition for group usage */
|
|
|
|
BLI_duplicatelist(&newtree->inputs, &ntree->inputs);
|
2012-03-24 06:18:31 +00:00
|
|
|
for (gsock= newtree->inputs.first, oldgsock= ntree->inputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
|
2011-02-21 13:47:49 +00:00
|
|
|
oldgsock->new_sock= gsock;
|
|
|
|
gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL);
|
2012-01-20 13:27:54 +00:00
|
|
|
gsock->default_value = node_socket_make_default_value(oldgsock->type);
|
|
|
|
node_socket_copy_default_value(oldgsock->type, gsock->default_value, oldgsock->default_value);
|
2006-02-07 15:50:55 +00:00
|
|
|
}
|
2011-02-21 13:47:49 +00:00
|
|
|
BLI_duplicatelist(&newtree->outputs, &ntree->outputs);
|
2012-03-24 06:18:31 +00:00
|
|
|
for (gsock= newtree->outputs.first, oldgsock= ntree->outputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
|
2011-02-21 13:47:49 +00:00
|
|
|
oldgsock->new_sock= gsock;
|
|
|
|
gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL);
|
2012-01-20 13:27:54 +00:00
|
|
|
gsock->default_value = node_socket_make_default_value(oldgsock->type);
|
|
|
|
node_socket_copy_default_value(oldgsock->type, gsock->default_value, oldgsock->default_value);
|
2011-02-21 13:47:49 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2011-02-21 13:47:49 +00:00
|
|
|
/* copy links */
|
|
|
|
BLI_duplicatelist(&newtree->links, &ntree->links);
|
2012-03-24 06:18:31 +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
|
|
|
|
|
|
|
/* update node->parent pointers */
|
|
|
|
for (node=newtree->nodes.first; node; node=node->next) {
|
|
|
|
if (node->parent)
|
|
|
|
node->parent = node->parent->new_node;
|
|
|
|
}
|
|
|
|
|
2006-02-07 15:50:55 +00:00
|
|
|
return newtree;
|
|
|
|
}
|
|
|
|
|
2010-08-05 10:50:38 +00:00
|
|
|
/* use when duplicating scenes */
|
|
|
|
void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
/* for scene duplication only */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->id==id_from) {
|
2010-08-05 10:50:38 +00:00
|
|
|
node->id= id_to;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* *************** preview *********** */
|
|
|
|
/* if node->preview, then we assume the rect to exist */
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void nodeFreePreview(bNode *node)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->preview) {
|
|
|
|
if (node->preview->rect)
|
2009-01-27 17:12:40 +00:00
|
|
|
MEM_freeN(node->preview->rect);
|
|
|
|
MEM_freeN(node->preview);
|
|
|
|
node->preview= NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_init_preview(bNode *node, int xsize, int ysize)
|
|
|
|
{
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->preview==NULL) {
|
2009-01-27 17:12:40 +00:00
|
|
|
node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
|
|
|
|
// printf("added preview %s\n", node->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* node previews can get added with variable size this way */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (xsize==0 || ysize==0)
|
2009-01-27 17:12:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* sanity checks & initialize */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->preview->rect) {
|
|
|
|
if (node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
|
2009-01-27 17:12:40 +00:00
|
|
|
MEM_freeN(node->preview->rect);
|
|
|
|
node->preview->rect= NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->preview->rect==NULL) {
|
2010-12-19 20:12:12 +00:00
|
|
|
node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(char)*4, "node preview rect");
|
2009-01-27 17:12:40 +00:00
|
|
|
node->preview->xsize= xsize;
|
|
|
|
node->preview->ysize= ysize;
|
|
|
|
}
|
2011-01-03 15:50:08 +00:00
|
|
|
/* no clear, makes nicer previews */
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntree==NULL)
|
2009-01-27 17:12:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
|
2009-01-27 17:12:40 +00:00
|
|
|
node_init_preview(node, xsize, ysize);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
|
2009-01-27 17:12:40 +00:00
|
|
|
ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
if (ntree==NULL)
|
2009-01-27 17:12:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->typeinfo->flag & NODE_PREVIEW)
|
2009-01-27 17:12:40 +00:00
|
|
|
nodeClearPreview(node);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
|
2009-01-27 17:12:40 +00:00
|
|
|
ntreeClearPreview((bNodeTree *)node->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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 */
|
2011-03-07 11:51:09 +00:00
|
|
|
void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
|
|
|
bNodePreview *preview= node->preview;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (preview) {
|
|
|
|
if (x>=0 && y>=0) {
|
|
|
|
if (x<preview->xsize && y<preview->ysize) {
|
2009-10-07 22:05:30 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
for (link= ntree->links.first; link; link= next) {
|
2005-12-20 15:43:55 +00:00
|
|
|
next= link->next;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (link->fromnode==node) {
|
2005-12-20 15:43:55 +00:00
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
else if (link->tonode==node)
|
2005-12-20 15:43:55 +00:00
|
|
|
lb= &node->inputs;
|
|
|
|
else
|
|
|
|
lb= NULL;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (lb) {
|
|
|
|
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;
|
|
|
|
for (node=ntree->nodes.first; node; node=node->next) {
|
|
|
|
if (node->parent == parent)
|
|
|
|
nodeDetachNode(node);
|
2006-01-28 15:21:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-18 13:46:01 +00:00
|
|
|
void nodeFreeNode(bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *treetype= ntreeGetType(ntree->type);
|
|
|
|
bNodeSocket *sock, *nextsock;
|
|
|
|
|
|
|
|
/* remove all references to this node */
|
2007-12-27 10:17:33 +00:00
|
|
|
nodeUnlinkNode(ntree, node);
|
2011-09-05 21:01:50 +00:00
|
|
|
node_unlink_attached(ntree, node);
|
|
|
|
|
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
|
|
|
BLI_remlink(&ntree->nodes, node);
|
2012-03-01 12:07:59 +00:00
|
|
|
|
2006-08-15 08:56:48 +00:00
|
|
|
/* since it is called while free database, node->id is undefined */
|
2005-12-18 23:08:22 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
if (treetype->free_node_cache)
|
|
|
|
treetype->free_node_cache(ntree, node);
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node->typeinfo && node->typeinfo->freestoragefunc)
|
2012-03-01 12:07:59 +00:00
|
|
|
node->typeinfo->freestoragefunc(node);
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
for (sock=node->inputs.first; sock; sock = nextsock) {
|
|
|
|
nextsock = sock->next;
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
|
|
|
for (sock=node->outputs.first; sock; sock = nextsock) {
|
|
|
|
nextsock = sock->next;
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(sock);
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeFreePreview(node);
|
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
|
|
|
|
|
|
|
ntree->update |= NTREE_UPDATE_NODES;
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
/* do not free ntree itself here, BKE_libblock_free calls this function too */
|
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 ntreeFreeTree(bNodeTree *ntree)
|
2005-12-18 13:46:01 +00:00
|
|
|
{
|
|
|
|
bNode *node, *next;
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocket *sock;
|
2005-12-18 13:46:01 +00:00
|
|
|
|
2012-03-24 06:18:31 +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) {
|
|
|
|
case NTREE_COMPOSIT:
|
2011-09-06 16:32:51 +00:00
|
|
|
ntreeCompositEndExecTree(ntree->execdata, 1);
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
|
|
|
case NTREE_SHADER:
|
2011-09-06 16:32:51 +00:00
|
|
|
ntreeShaderEndExecTree(ntree->execdata, 1);
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
|
|
|
case NTREE_TEXTURE:
|
2011-09-06 16:32:51 +00:00
|
|
|
ntreeTexEndExecTree(ntree->execdata, 1);
|
2011-09-05 21:01:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-07-09 11:54:41 +00:00
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
BLI_freelistN(&ntree->links); /* do first, then unlink_node goes fast */
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= next) {
|
2005-12-18 13:46:01 +00:00
|
|
|
next= node->next;
|
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
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
for (sock=ntree->inputs.first; sock; sock=sock->next)
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
2011-02-21 13:47:49 +00:00
|
|
|
BLI_freelistN(&ntree->inputs);
|
2011-09-05 21:01:50 +00:00
|
|
|
for (sock=ntree->outputs.first; sock; sock=sock->next)
|
2012-01-20 13:27:54 +00:00
|
|
|
node_socket_free_default_value(sock->type, sock->default_value);
|
2011-02-21 13:47:49 +00:00
|
|
|
BLI_freelistN(&ntree->outputs);
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
|
|
|
|
2006-02-08 17:30:28 +00:00
|
|
|
void ntreeFreeCache(bNodeTree *ntree)
|
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *treetype;
|
2006-02-08 17:30:28 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntree==NULL) return;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
treetype= ntreeGetType(ntree->type);
|
|
|
|
if (treetype->free_cache)
|
|
|
|
treetype->free_cache(ntree);
|
|
|
|
}
|
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-03-24 06:18:31 +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;
|
|
|
|
int output= 0;
|
|
|
|
|
|
|
|
/* we need a check for which output node should be tagged like this, below an exception */
|
2012-03-24 06:18:31 +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-03-24 06:18:31 +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-03-24 06:18:31 +00:00
|
|
|
if (ntree->type==NTREE_COMPOSIT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* same type, exception for viewer */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tnode->type==node->type ||
|
2011-09-05 21:01:50 +00:00
|
|
|
(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-03-24 06:18:31 +00:00
|
|
|
if (output>1)
|
2011-09-05 21:01:50 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* same type */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tnode->type==node->type) {
|
|
|
|
if (tnode->flag & NODE_DO_OUTPUT) {
|
2011-09-05 21:01:50 +00:00
|
|
|
output++;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (output>1)
|
2011-09-05 21:01:50 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (output==0)
|
2011-09-05 21:01:50 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct MakeLocalCallData {
|
|
|
|
ID *group_id;
|
|
|
|
ID *new_id;
|
|
|
|
int lib, local;
|
|
|
|
} MakeLocalCallData;
|
|
|
|
|
|
|
|
static void ntreeMakeLocal_CheckLocal(void *calldata, ID *owner_id, bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
MakeLocalCallData *cd= (MakeLocalCallData*)calldata;
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
/* find if group is in tree */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->id == cd->group_id) {
|
|
|
|
if (owner_id->lib) cd->lib= 1;
|
2011-09-05 21:01:50 +00:00
|
|
|
else cd->local= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-11 23:17:41 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void ntreeMakeLocal_LinkNew(void *calldata, ID *owner_id, bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
MakeLocalCallData *cd= (MakeLocalCallData*)calldata;
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
/* find if group is in tree */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->id == cd->group_id) {
|
|
|
|
if (owner_id->lib==NULL) {
|
2011-09-05 21:01:50 +00:00
|
|
|
node->id= cd->new_id;
|
|
|
|
cd->new_id->us++;
|
|
|
|
cd->group_id->us--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-08 17:30:28 +00:00
|
|
|
}
|
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
|
|
|
{
|
2011-10-23 17:52:20 +00:00
|
|
|
Main *bmain= G.main;
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *treetype= ntreeGetType(ntree->type);
|
|
|
|
MakeLocalCallData cd;
|
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-03-24 06:18:31 +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... */
|
2011-09-05 21:01:50 +00:00
|
|
|
cd.group_id = &ntree->id;
|
|
|
|
cd.new_id = NULL;
|
|
|
|
cd.local = 0;
|
|
|
|
cd.lib = 0;
|
|
|
|
|
|
|
|
treetype->foreach_nodetree(G.main, &cd, &ntreeMakeLocal_CheckLocal);
|
|
|
|
|
|
|
|
/* if all users are local, we simply make tree local */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cd.local && cd.lib==0) {
|
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
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (cd.local && cd.lib) {
|
2006-02-07 15:50:55 +00:00
|
|
|
/* this is the mixed case, we copy the tree and assign it to local users */
|
2011-02-11 09:37:58 +00:00
|
|
|
bNodeTree *newtree= ntreeCopyTree(ntree);
|
2006-02-07 15:50:55 +00:00
|
|
|
|
|
|
|
newtree->id.us= 0;
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
cd.new_id = &newtree->id;
|
|
|
|
treetype->foreach_nodetree(G.main, &cd, &ntreeMakeLocal_LinkNew);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)
|
|
|
|
{
|
|
|
|
bNode *node= ntree->nodes.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
bNodeSocket *sock= node->outputs.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
bNodeTreeType *ntreetype= ntreeGetType(ntree->type);
|
|
|
|
|
|
|
|
bNodeTree *ltree;
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
bAction *action_backup= NULL, *tmpact_backup= NULL;
|
|
|
|
|
|
|
|
/* Workaround for copying an action on each render!
|
2012-03-18 07:38:51 +00:00
|
|
|
* set action to NULL so animdata actions don't get copied */
|
2011-09-05 21:01:50 +00:00
|
|
|
AnimData *adt= BKE_animdata_from_id(&ntree->id);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (adt) {
|
2011-09-05 21:01:50 +00:00
|
|
|
action_backup= adt->action;
|
|
|
|
tmpact_backup= adt->tmpact;
|
|
|
|
|
|
|
|
adt->action= NULL;
|
|
|
|
adt->tmpact= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* node copy func */
|
|
|
|
ltree= ntreeCopyTree(ntree);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (adt) {
|
2011-09-05 21:01:50 +00:00
|
|
|
AnimData *ladt= BKE_animdata_from_id(<ree->id);
|
|
|
|
|
|
|
|
adt->action= ladt->action= action_backup;
|
|
|
|
adt->tmpact= ladt->tmpact= tmpact_backup;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (action_backup) action_backup->id.us++;
|
|
|
|
if (tmpact_backup) tmpact_backup->id.us++;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
/* end animdata uglyness */
|
|
|
|
|
|
|
|
/* ensures only a single output node is enabled */
|
|
|
|
ntreeSetOutput(ntree);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
/* store new_node pointer to original */
|
|
|
|
node->new_node->new_node= node;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ntreetype->localize)
|
|
|
|
ntreetype->localize(ltree, ntree);
|
|
|
|
|
|
|
|
return ltree;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
bNodeTreeType *ntreetype= ntreeGetType(ntree->type);
|
|
|
|
|
|
|
|
if (ntreetype->local_sync)
|
|
|
|
ntreetype->local_sync(localtree, ntree);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* merge local tree results back, and free local tree */
|
|
|
|
/* we have to assume the editor already changed completely */
|
|
|
|
void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNodeTreeType *ntreetype= ntreeGetType(ntree->type);
|
|
|
|
bNode *lnode;
|
|
|
|
|
|
|
|
/* move over the compbufs and previews */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
|
|
|
|
if (ntreeNodeExists(ntree, lnode->new_node)) {
|
|
|
|
if (lnode->preview && lnode->preview->rect) {
|
2011-09-05 21:01:50 +00:00
|
|
|
nodeFreePreview(lnode->new_node);
|
|
|
|
lnode->new_node->preview= lnode->preview;
|
|
|
|
lnode->preview= NULL;
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-07 15:50:55 +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
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
if (ntreetype->local_merge)
|
|
|
|
ntreetype->local_merge(localtree, ntree);
|
|
|
|
|
|
|
|
ntreeFreeTree(localtree);
|
|
|
|
MEM_freeN(localtree);
|
|
|
|
}
|
2006-02-07 15:50:55 +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)
|
|
|
|
for (node= ntree->nodes.first; node; node= node->next)
|
|
|
|
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-03-24 06:18:31 +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-03-24 06:18:31 +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;
|
|
|
|
int tot= 0;
|
|
|
|
|
2012-03-24 06:18:31 +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-03-24 06:18:31 +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-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next)
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-12-30 11:25:15 +00:00
|
|
|
/* two active flags, ID nodes have special flag for buttons display */
|
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 *nodeGetActiveID(bNodeTree *ntree, short idtype)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntree==NULL) return NULL;
|
2008-03-14 18:08:27 +00:00
|
|
|
|
|
|
|
/* check for group edit */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next)
|
|
|
|
if (node->flag & NODE_GROUP_EDIT)
|
2008-03-14 18:08:27 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node)
|
2008-03-14 18:08:27 +00:00
|
|
|
ntree= (bNodeTree*)node->id;
|
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
|
|
|
|
2008-03-14 18:08:27 +00:00
|
|
|
/* now find active node with this id */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next)
|
|
|
|
if (node->id && GS(node->id->name)==idtype)
|
|
|
|
if (node->flag & NODE_ACTIVE_ID)
|
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;
|
2008-03-14 18:08:27 +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 node;
|
|
|
|
}
|
|
|
|
|
2009-10-06 15:31:25 +00:00
|
|
|
int nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
int ok= FALSE;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntree==NULL) return ok;
|
2009-10-06 15:31:25 +00:00
|
|
|
|
|
|
|
/* check for group edit */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next)
|
|
|
|
if (node->flag & NODE_GROUP_EDIT)
|
2009-10-06 15:31:25 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node)
|
2009-10-06 15:31:25 +00:00
|
|
|
ntree= (bNodeTree*)node->id;
|
|
|
|
|
|
|
|
/* now find active node with this id */
|
2012-03-24 06:18:31 +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;
|
|
|
|
ok= TRUE;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-10-06 15:31:25 +00:00
|
|
|
node->flag &= ~NODE_ACTIVE_ID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
if (ntree==NULL) return;
|
2005-12-30 11:25:15 +00:00
|
|
|
|
2012-03-24 06:18:31 +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;
|
|
|
|
}
|
|
|
|
|
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-03-24 06:18:31 +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)
|
|
|
|
{
|
2012-04-16 10:50:57 +00:00
|
|
|
return ((sock->flag & (SOCK_HIDDEN | SOCK_UNAVAIL)) != 0);
|
2012-01-08 10:23:19 +00:00
|
|
|
}
|
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
void nodeSocketSetType(bNodeSocket *sock, int type)
|
|
|
|
{
|
|
|
|
int old_type = sock->type;
|
|
|
|
void *old_default_value = sock->default_value;
|
|
|
|
|
|
|
|
sock->type = type;
|
|
|
|
|
|
|
|
sock->default_value = node_socket_make_default_value(sock->type);
|
|
|
|
node_socket_init_default_value(type, sock->default_value);
|
|
|
|
node_socket_convert_default_value(sock->type, sock->default_value, old_type, old_default_value);
|
|
|
|
node_socket_free_default_value(old_type, old_default_value);
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* ************** dependency stuff *********** */
|
|
|
|
|
|
|
|
/* node is guaranteed to be not checked before */
|
|
|
|
static int node_get_deplist_recurs(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;
|
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
|
|
|
bNodeSocket *sock;
|
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-03-24 06:18:31 +00:00
|
|
|
for (sock= node->inputs.first; sock; sock= sock->next) {
|
|
|
|
if (sock->link) {
|
2011-09-05 21:01:50 +00:00
|
|
|
fromnode= sock->link->fromnode;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (fromnode) {
|
2011-09-05 21:01:50 +00:00
|
|
|
if (fromnode->done==0)
|
|
|
|
fromnode->level= node_get_deplist_recurs(fromnode, nsort);
|
|
|
|
if (fromnode->level <= level)
|
|
|
|
level = fromnode->level - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check parent node */
|
|
|
|
if (node->parent) {
|
|
|
|
if (node->parent->done==0)
|
|
|
|
node->parent->level= node_get_deplist_recurs(node->parent, nsort);
|
|
|
|
if (node->parent->level <= level)
|
|
|
|
level = node->parent->level - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsort) {
|
|
|
|
**nsort= 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
|
|
|
}
|
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
|
|
|
|
2011-09-05 21:01:50 +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-03-24 06:18:31 +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-03-24 06:18:31 +00:00
|
|
|
if (*totnodes==0) {
|
2011-09-05 21:01:50 +00:00
|
|
|
*deplist = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsort= *deplist= MEM_callocN((*totnodes)*sizeof(bNode*), "sorted node array");
|
|
|
|
|
|
|
|
/* recursive check */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->done==0) {
|
2011-09-05 21:01:50 +00:00
|
|
|
node->level= node_get_deplist_recurs(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-03-24 06:18:31 +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-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->done==0) {
|
2012-03-07 12:30:29 +00:00
|
|
|
node->level= node_get_deplist_recurs(node, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
for (sock= node->inputs.first; sock; sock= sock->next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
sock->link= NULL;
|
2011-12-19 12:04:05 +00:00
|
|
|
sock->flag &= ~SOCK_IN_USE;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= node->outputs.first; sock; sock= sock->next) {
|
2011-12-19 12:04:05 +00:00
|
|
|
sock->flag &= ~SOCK_IN_USE;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
for (sock= ntree->inputs.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-03-24 06:18:31 +00:00
|
|
|
for (sock= ntree->outputs.first; sock; sock= sock->next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
sock->link= NULL;
|
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-03-24 06:18:31 +00:00
|
|
|
for (link= ntree->links.first; link; link= link->next) {
|
2011-12-19 12:04:05 +00:00
|
|
|
link->tosock->link= link;
|
|
|
|
|
|
|
|
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
|
|
|
bNodeTreeType *ntreetype = ntreeGetType(ntree->type);
|
|
|
|
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;
|
|
|
|
else if (ntreetype->validate_link) {
|
|
|
|
if (!ntreetype->validate_link(ntree, link))
|
|
|
|
link->flag &= ~NODE_LINK_VALID;
|
|
|
|
}
|
|
|
|
}
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void ntree_verify_nodes_cb(void *calldata, struct ID *UNUSED(owner_id), struct bNodeTree *ntree)
|
2007-03-24 18:41:54 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
ID *id= (ID*)calldata;
|
2007-04-11 17:49:08 +00:00
|
|
|
bNode *node;
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
for (node=ntree->nodes.first; node; node=node->next)
|
|
|
|
if (node->typeinfo->verifyfunc)
|
|
|
|
node->typeinfo->verifyfunc(ntree, node, id);
|
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
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *ntreetype;
|
|
|
|
bNodeTree *ntree;
|
|
|
|
int n;
|
2007-04-11 17:49:08 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
for (n=0; n < NUM_NTREE_TYPES; ++n) {
|
|
|
|
ntreetype= ntreeGetType(n);
|
|
|
|
if (ntreetype && ntreetype->foreach_nodetree)
|
|
|
|
ntreetype->foreach_nodetree(main, id, ntree_verify_nodes_cb);
|
2007-04-11 17:49:08 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
|
|
|
|
ntree_verify_nodes_cb(id, NULL, ntree);
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void ntreeUpdateTree(bNodeTree *ntree)
|
2010-01-27 05:42:17 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *ntreetype= ntreeGetType(ntree->type);
|
|
|
|
bNode *node;
|
|
|
|
|
2012-03-20 16:59:00 +00:00
|
|
|
if (ntree->update & (NTREE_UPDATE_LINKS|NTREE_UPDATE_NODES)) {
|
|
|
|
/* 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
|
|
|
|
|
|
|
/* update the node level from link dependencies */
|
2012-03-07 12:30:29 +00:00
|
|
|
ntree_update_node_level(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 */
|
|
|
|
for (node=ntree->nodes.first; node; node=node->next) {
|
|
|
|
/* node tree update tags override individual node update flags */
|
|
|
|
if ((node->update & NODE_UPDATE) || (ntree->update & NTREE_UPDATE)) {
|
|
|
|
if (ntreetype->update_node)
|
|
|
|
ntreetype->update_node(ntree, node);
|
|
|
|
else if (node->typeinfo->updatefunc)
|
|
|
|
node->typeinfo->updatefunc(ntree, node);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2012-03-07 12:30:29 +00:00
|
|
|
/* clear update flag */
|
|
|
|
node->update = 0;
|
2010-01-27 05:42:17 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-03-07 12:30:29 +00:00
|
|
|
/* check link validity */
|
|
|
|
if (ntree->update & (NTREE_UPDATE_LINKS|NTREE_UPDATE_NODES))
|
2011-09-05 21:01:50 +00:00
|
|
|
ntree_validate_links(ntree);
|
|
|
|
|
2012-03-07 12:30:29 +00:00
|
|
|
/* generic tree update callback */
|
2011-09-05 21:01:50 +00:00
|
|
|
if (ntreetype->update)
|
|
|
|
ntreetype->update(ntree);
|
|
|
|
else {
|
2011-10-19 17:08:35 +00:00
|
|
|
/* Trees can be associated with a specific node type (i.e. group nodes),
|
|
|
|
* in that case a tree update function may be defined by that node type.
|
|
|
|
*/
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeType *ntype= node_get_type(ntree, ntree->nodetype);
|
|
|
|
if (ntype && ntype->updatetreefunc)
|
|
|
|
ntype->updatetreefunc(ntree);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX hack, should be done by depsgraph!! */
|
|
|
|
ntreeVerifyNodes(G.main, &ntree->id);
|
|
|
|
|
|
|
|
/* clear the update flag */
|
|
|
|
ntree->update = 0;
|
|
|
|
}
|
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
|
|
|
{
|
2011-10-19 17:08:35 +00:00
|
|
|
bNodeTreeType *ntreetype= ntreeGetType(ntree->type);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2011-10-19 17:08:35 +00:00
|
|
|
if (ntreetype->update_node)
|
2011-09-05 21:01:50 +00:00
|
|
|
ntreetype->update_node(ntree, node);
|
2011-10-19 17:08:35 +00:00
|
|
|
else if (node->typeinfo->updatefunc)
|
2011-09-05 21:01:50 +00:00
|
|
|
node->typeinfo->updatefunc(ntree, node);
|
2011-10-19 17:08:35 +00:00
|
|
|
/* clear update flag */
|
|
|
|
node->update = 0;
|
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
|
|
|
{
|
2011-09-06 18:15:34 +00:00
|
|
|
bNodeTreeType *ntreetype;
|
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
|
|
|
|
2011-09-06 18:15:34 +00:00
|
|
|
ntreetype = ntreeGetType(ntree->type);
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
if (ntreetype->update_node) {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->id==id) {
|
2011-09-05 21:01:50 +00:00
|
|
|
change = TRUE;
|
2012-04-16 13:49:33 +00:00
|
|
|
node->update |= NODE_UPDATE_ID;
|
2011-09-05 21:01:50 +00:00
|
|
|
ntreetype->update_node(ntree, node);
|
2011-10-19 17:08:35 +00:00
|
|
|
/* clear update flag */
|
|
|
|
node->update = 0;
|
2007-04-11 17:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
for (node= ntree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->id==id) {
|
2011-09-05 21:01:50 +00:00
|
|
|
change = TRUE;
|
2012-04-16 13:49:33 +00:00
|
|
|
node->update |= NODE_UPDATE_ID;
|
2011-09-05 21:01:50 +00:00
|
|
|
if (node->typeinfo->updatefunc)
|
|
|
|
node->typeinfo->updatefunc(ntree, node);
|
2011-10-19 17:08:35 +00:00
|
|
|
/* clear update flag */
|
|
|
|
node->update = 0;
|
2007-04-11 17:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
return change;
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* ************* node type access ********** */
|
|
|
|
|
|
|
|
int nodeValid(bNodeTree *ntree, bNodeTemplate *ntemp)
|
2007-03-24 18:41:54 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeType *ntype= node_get_type(ntree, ntemp->type);
|
|
|
|
if (ntype) {
|
|
|
|
if (ntype->validfunc)
|
|
|
|
return ntype->validfunc(ntree, ntemp);
|
|
|
|
else
|
|
|
|
return 1;
|
2007-04-11 17:49:08 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
else
|
|
|
|
return 0;
|
2007-03-24 18:41:54 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
const char* nodeLabel(bNode *node)
|
2011-02-07 16:41:57 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
if (node->label[0]!='\0')
|
|
|
|
return node->label;
|
|
|
|
else if (node->typeinfo->labelfunc)
|
|
|
|
return node->typeinfo->labelfunc(node);
|
|
|
|
else
|
2012-03-17 14:42:44 +00:00
|
|
|
return IFACE_(node->typeinfo->name);
|
2011-02-07 16:41:57 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
struct bNodeTree *nodeGroupEditGet(struct bNode *node)
|
|
|
|
{
|
|
|
|
if (node->typeinfo->group_edit_get)
|
|
|
|
return node->typeinfo->group_edit_get(node);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-02-07 16:41:57 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
struct bNodeTree *nodeGroupEditSet(struct bNode *node, int edit)
|
2008-11-12 22:03:11 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
if (node->typeinfo->group_edit_set)
|
|
|
|
return node->typeinfo->group_edit_set(node, edit);
|
|
|
|
else if (node->typeinfo->group_edit_get)
|
|
|
|
return node->typeinfo->group_edit_get(node);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nodeGroupEditClear(struct bNode *node)
|
|
|
|
{
|
|
|
|
if (node->typeinfo->group_edit_clear)
|
|
|
|
node->typeinfo->group_edit_clear(node);
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
struct bNodeTemplate nodeMakeTemplate(struct bNode *node)
|
|
|
|
{
|
|
|
|
bNodeTemplate ntemp;
|
|
|
|
if (node->typeinfo->templatefunc)
|
|
|
|
return node->typeinfo->templatefunc(node);
|
|
|
|
else {
|
|
|
|
ntemp.type = node->type;
|
|
|
|
return ntemp;
|
|
|
|
}
|
|
|
|
}
|
2007-03-26 15:07:38 +00:00
|
|
|
|
2011-11-20 16:38:23 +00:00
|
|
|
void node_type_base(bNodeTreeType *ttype, bNodeType *ntype, int type, const char *name, short nclass, short flag)
|
2011-02-07 09:33:36 +00:00
|
|
|
{
|
|
|
|
memset(ntype, 0, sizeof(bNodeType));
|
2011-11-20 16:38:23 +00:00
|
|
|
|
2011-02-07 09:33:36 +00:00
|
|
|
ntype->type = type;
|
2011-09-05 21:01:50 +00:00
|
|
|
BLI_strncpy(ntype->name, name, sizeof(ntype->name));
|
2011-02-07 09:33:36 +00:00
|
|
|
ntype->nclass = nclass;
|
|
|
|
ntype->flag = flag;
|
2011-11-20 16:38:23 +00:00
|
|
|
|
|
|
|
/* Default muting stuff. */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ttype)
|
2012-02-27 17:38:16 +00:00
|
|
|
ntype->internal_connect = ttype->internal_connect;
|
2011-11-20 16:38:23 +00:00
|
|
|
|
2011-02-07 09:33:36 +00:00
|
|
|
/* default size values */
|
|
|
|
ntype->width = 140;
|
|
|
|
ntype->minwidth = 100;
|
|
|
|
ntype->maxwidth = 320;
|
2011-09-05 21:01:50 +00:00
|
|
|
ntype->height = 100;
|
|
|
|
ntype->minheight = 30;
|
|
|
|
ntype->maxheight = FLT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
|
|
|
|
{
|
|
|
|
ntype->inputs = inputs;
|
|
|
|
ntype->outputs = outputs;
|
2011-02-07 09:33:36 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_type_init(struct bNodeType *ntype, void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp))
|
2011-02-08 09:02:16 +00:00
|
|
|
{
|
|
|
|
ntype->initfunc = initfunc;
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_type_valid(struct bNodeType *ntype, int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp))
|
|
|
|
{
|
|
|
|
ntype->validfunc = validfunc;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-02-08 09:02:16 +00:00
|
|
|
void node_type_storage(bNodeType *ntype, const char *storagename, void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *))
|
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';
|
2011-02-07 09:33:36 +00:00
|
|
|
ntype->copystoragefunc = copystoragefunc;
|
|
|
|
ntype->freestoragefunc = freestoragefunc;
|
|
|
|
}
|
|
|
|
|
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_template(struct bNodeType *ntype, struct bNodeTemplate (*templatefunc)(struct bNode *))
|
|
|
|
{
|
|
|
|
ntype->templatefunc = templatefunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_type_update(struct bNodeType *ntype,
|
|
|
|
void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
|
|
|
|
void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id))
|
|
|
|
{
|
|
|
|
ntype->updatefunc = updatefunc;
|
|
|
|
ntype->verifyfunc = verifyfunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_type_tree(struct bNodeType *ntype, void (*inittreefunc)(struct bNodeTree *), void (*updatetreefunc)(struct bNodeTree *))
|
|
|
|
{
|
|
|
|
ntype->inittreefunc = inittreefunc;
|
|
|
|
ntype->updatetreefunc = updatetreefunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_type_group_edit(struct bNodeType *ntype,
|
|
|
|
struct bNodeTree *(*group_edit_get)(struct bNode *node),
|
|
|
|
struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit),
|
|
|
|
void (*group_edit_clear)(struct bNode *node))
|
|
|
|
{
|
|
|
|
ntype->group_edit_get = group_edit_get;
|
|
|
|
ntype->group_edit_set = group_edit_set;
|
|
|
|
ntype->group_edit_clear = group_edit_clear;
|
|
|
|
}
|
|
|
|
|
2011-02-07 09:33:36 +00:00
|
|
|
void node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **))
|
|
|
|
{
|
|
|
|
ntype->execfunc = execfunc;
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_type_exec_new(struct bNodeType *ntype,
|
|
|
|
void *(*initexecfunc)(struct bNode *node),
|
|
|
|
void (*freeexecfunc)(struct bNode *node, void *nodedata),
|
|
|
|
void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **))
|
|
|
|
{
|
|
|
|
ntype->initexecfunc = initexecfunc;
|
|
|
|
ntype->freeexecfunc = freeexecfunc;
|
|
|
|
ntype->newexecfunc = newexecfunc;
|
|
|
|
}
|
|
|
|
|
2012-02-27 17:38:16 +00:00
|
|
|
void node_type_internal_connect(bNodeType *ntype, ListBase (*internal_connect)(bNodeTree *, bNode *))
|
2011-11-20 16:38:23 +00:00
|
|
|
{
|
2012-02-27 17:38:16 +00:00
|
|
|
ntype->internal_connect = internal_connect;
|
2011-11-20 16:38:23 +00:00
|
|
|
}
|
|
|
|
|
2011-02-07 09:33:36 +00:00
|
|
|
void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out))
|
|
|
|
{
|
|
|
|
ntype->gpufunc = gpufunc;
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out))
|
2011-02-08 12:54:32 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
ntype->gpuextfunc = gpuextfunc;
|
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
|
|
|
|
|
|
|
static bNodeType *is_nodetype_registered(ListBase *typelist, int type)
|
2007-03-26 15:07:38 +00:00
|
|
|
{
|
|
|
|
bNodeType *ntype= typelist->first;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (;ntype; ntype= ntype->next )
|
|
|
|
if (ntype->type==type)
|
2007-03-26 15:07:38 +00:00
|
|
|
return ntype;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-20 16:13:27 +00:00
|
|
|
void nodeRegisterType(bNodeTreeType *ttype, bNodeType *ntype)
|
2007-03-26 15:07:38 +00:00
|
|
|
{
|
2011-11-20 16:13:27 +00:00
|
|
|
ListBase *typelist = &(ttype->node_types);
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeType *found= is_nodetype_registered(typelist, ntype->type);
|
2007-03-26 15:07:38 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (found==NULL)
|
2011-09-05 21:01:50 +00:00
|
|
|
BLI_addtail(typelist, ntype);
|
2007-03-26 15:07:38 +00:00
|
|
|
}
|
|
|
|
|
2011-11-20 16:13:27 +00:00
|
|
|
static void registerCompositNodes(bNodeTreeType *ttype)
|
|
|
|
{
|
|
|
|
register_node_type_frame(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_group(ttype);
|
|
|
|
// register_node_type_cmp_forloop(ttype);
|
|
|
|
// register_node_type_cmp_whileloop(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_rlayers(ttype);
|
|
|
|
register_node_type_cmp_image(ttype);
|
|
|
|
register_node_type_cmp_texture(ttype);
|
|
|
|
register_node_type_cmp_value(ttype);
|
|
|
|
register_node_type_cmp_rgb(ttype);
|
|
|
|
register_node_type_cmp_curve_time(ttype);
|
|
|
|
register_node_type_cmp_movieclip(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_composite(ttype);
|
|
|
|
register_node_type_cmp_viewer(ttype);
|
|
|
|
register_node_type_cmp_splitviewer(ttype);
|
|
|
|
register_node_type_cmp_output_file(ttype);
|
|
|
|
register_node_type_cmp_view_levels(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_curve_rgb(ttype);
|
|
|
|
register_node_type_cmp_mix_rgb(ttype);
|
|
|
|
register_node_type_cmp_hue_sat(ttype);
|
|
|
|
register_node_type_cmp_brightcontrast(ttype);
|
|
|
|
register_node_type_cmp_gamma(ttype);
|
|
|
|
register_node_type_cmp_invert(ttype);
|
|
|
|
register_node_type_cmp_alphaover(ttype);
|
|
|
|
register_node_type_cmp_zcombine(ttype);
|
|
|
|
register_node_type_cmp_colorbalance(ttype);
|
|
|
|
register_node_type_cmp_huecorrect(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_normal(ttype);
|
|
|
|
register_node_type_cmp_curve_vec(ttype);
|
|
|
|
register_node_type_cmp_map_value(ttype);
|
|
|
|
register_node_type_cmp_normalize(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_filter(ttype);
|
|
|
|
register_node_type_cmp_blur(ttype);
|
|
|
|
register_node_type_cmp_dblur(ttype);
|
|
|
|
register_node_type_cmp_bilateralblur(ttype);
|
|
|
|
register_node_type_cmp_vecblur(ttype);
|
|
|
|
register_node_type_cmp_dilateerode(ttype);
|
|
|
|
register_node_type_cmp_defocus(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_valtorgb(ttype);
|
|
|
|
register_node_type_cmp_rgbtobw(ttype);
|
|
|
|
register_node_type_cmp_setalpha(ttype);
|
|
|
|
register_node_type_cmp_idmask(ttype);
|
|
|
|
register_node_type_cmp_math(ttype);
|
|
|
|
register_node_type_cmp_seprgba(ttype);
|
|
|
|
register_node_type_cmp_combrgba(ttype);
|
|
|
|
register_node_type_cmp_sephsva(ttype);
|
|
|
|
register_node_type_cmp_combhsva(ttype);
|
|
|
|
register_node_type_cmp_sepyuva(ttype);
|
|
|
|
register_node_type_cmp_combyuva(ttype);
|
|
|
|
register_node_type_cmp_sepycca(ttype);
|
|
|
|
register_node_type_cmp_combycca(ttype);
|
|
|
|
register_node_type_cmp_premulkey(ttype);
|
|
|
|
|
|
|
|
register_node_type_cmp_diff_matte(ttype);
|
|
|
|
register_node_type_cmp_distance_matte(ttype);
|
|
|
|
register_node_type_cmp_chroma_matte(ttype);
|
|
|
|
register_node_type_cmp_color_matte(ttype);
|
|
|
|
register_node_type_cmp_channel_matte(ttype);
|
|
|
|
register_node_type_cmp_color_spill(ttype);
|
|
|
|
register_node_type_cmp_luma_matte(ttype);
|
2012-03-24 07:36:32 +00:00
|
|
|
register_node_type_cmp_doubleedgemask(ttype);
|
2012-01-13 16:00:24 +00:00
|
|
|
|
2011-11-20 16:13:27 +00:00
|
|
|
register_node_type_cmp_translate(ttype);
|
|
|
|
register_node_type_cmp_rotate(ttype);
|
|
|
|
register_node_type_cmp_scale(ttype);
|
|
|
|
register_node_type_cmp_flip(ttype);
|
|
|
|
register_node_type_cmp_crop(ttype);
|
|
|
|
register_node_type_cmp_displace(ttype);
|
|
|
|
register_node_type_cmp_mapuv(ttype);
|
|
|
|
register_node_type_cmp_glare(ttype);
|
|
|
|
register_node_type_cmp_tonemap(ttype);
|
|
|
|
register_node_type_cmp_lensdist(ttype);
|
|
|
|
register_node_type_cmp_transform(ttype);
|
|
|
|
register_node_type_cmp_stabilize2d(ttype);
|
|
|
|
register_node_type_cmp_moviedistortion(ttype);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
|
|
|
register_node_type_cmp_colorcorrection(ttype);
|
|
|
|
register_node_type_cmp_boxmask(ttype);
|
|
|
|
register_node_type_cmp_ellipsemask(ttype);
|
|
|
|
register_node_type_cmp_bokehimage(ttype);
|
|
|
|
register_node_type_cmp_bokehblur(ttype);
|
|
|
|
register_node_type_cmp_switch(ttype);
|
2011-11-20 16:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void registerShaderNodes(bNodeTreeType *ttype)
|
|
|
|
{
|
|
|
|
register_node_type_frame(ttype);
|
|
|
|
|
|
|
|
register_node_type_sh_group(ttype);
|
|
|
|
//register_node_type_sh_forloop(ttype);
|
|
|
|
//register_node_type_sh_whileloop(ttype);
|
|
|
|
|
|
|
|
register_node_type_sh_output(ttype);
|
|
|
|
register_node_type_sh_material(ttype);
|
|
|
|
register_node_type_sh_camera(ttype);
|
2011-12-16 20:35:06 +00:00
|
|
|
register_node_type_sh_gamma(ttype);
|
2012-01-24 16:32:31 +00:00
|
|
|
register_node_type_sh_brightcontrast(ttype);
|
2011-11-20 16:13:27 +00:00
|
|
|
register_node_type_sh_value(ttype);
|
|
|
|
register_node_type_sh_rgb(ttype);
|
|
|
|
register_node_type_sh_mix_rgb(ttype);
|
|
|
|
register_node_type_sh_valtorgb(ttype);
|
|
|
|
register_node_type_sh_rgbtobw(ttype);
|
|
|
|
register_node_type_sh_texture(ttype);
|
|
|
|
register_node_type_sh_normal(ttype);
|
|
|
|
register_node_type_sh_geom(ttype);
|
|
|
|
register_node_type_sh_mapping(ttype);
|
|
|
|
register_node_type_sh_curve_vec(ttype);
|
|
|
|
register_node_type_sh_curve_rgb(ttype);
|
|
|
|
register_node_type_sh_math(ttype);
|
|
|
|
register_node_type_sh_vect_math(ttype);
|
|
|
|
register_node_type_sh_squeeze(ttype);
|
|
|
|
//register_node_type_sh_dynamic(ttype);
|
|
|
|
register_node_type_sh_material_ext(ttype);
|
|
|
|
register_node_type_sh_invert(ttype);
|
|
|
|
register_node_type_sh_seprgb(ttype);
|
|
|
|
register_node_type_sh_combrgb(ttype);
|
|
|
|
register_node_type_sh_hue_sat(ttype);
|
|
|
|
|
|
|
|
register_node_type_sh_attribute(ttype);
|
|
|
|
register_node_type_sh_geometry(ttype);
|
|
|
|
register_node_type_sh_light_path(ttype);
|
2012-05-07 20:24:38 +00:00
|
|
|
register_node_type_sh_light_falloff(ttype);
|
2012-05-21 12:52:28 +00:00
|
|
|
register_node_type_sh_object_info(ttype);
|
2011-11-20 16:13:27 +00:00
|
|
|
register_node_type_sh_fresnel(ttype);
|
|
|
|
register_node_type_sh_layer_weight(ttype);
|
|
|
|
register_node_type_sh_tex_coord(ttype);
|
|
|
|
|
|
|
|
register_node_type_sh_background(ttype);
|
|
|
|
register_node_type_sh_bsdf_diffuse(ttype);
|
|
|
|
register_node_type_sh_bsdf_glossy(ttype);
|
|
|
|
register_node_type_sh_bsdf_glass(ttype);
|
|
|
|
register_node_type_sh_bsdf_translucent(ttype);
|
|
|
|
register_node_type_sh_bsdf_transparent(ttype);
|
|
|
|
register_node_type_sh_bsdf_velvet(ttype);
|
|
|
|
register_node_type_sh_emission(ttype);
|
|
|
|
register_node_type_sh_holdout(ttype);
|
|
|
|
//register_node_type_sh_volume_transparent(ttype);
|
|
|
|
//register_node_type_sh_volume_isotropic(ttype);
|
|
|
|
register_node_type_sh_mix_shader(ttype);
|
|
|
|
register_node_type_sh_add_shader(ttype);
|
|
|
|
|
|
|
|
register_node_type_sh_output_lamp(ttype);
|
|
|
|
register_node_type_sh_output_material(ttype);
|
|
|
|
register_node_type_sh_output_world(ttype);
|
|
|
|
|
|
|
|
register_node_type_sh_tex_image(ttype);
|
|
|
|
register_node_type_sh_tex_environment(ttype);
|
|
|
|
register_node_type_sh_tex_sky(ttype);
|
|
|
|
register_node_type_sh_tex_noise(ttype);
|
|
|
|
register_node_type_sh_tex_wave(ttype);
|
|
|
|
register_node_type_sh_tex_voronoi(ttype);
|
|
|
|
register_node_type_sh_tex_musgrave(ttype);
|
|
|
|
register_node_type_sh_tex_gradient(ttype);
|
|
|
|
register_node_type_sh_tex_magic(ttype);
|
2012-01-08 14:55:43 +00:00
|
|
|
register_node_type_sh_tex_checker(ttype);
|
2011-11-20 16:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void registerTextureNodes(bNodeTreeType *ttype)
|
|
|
|
{
|
|
|
|
register_node_type_frame(ttype);
|
|
|
|
|
|
|
|
register_node_type_tex_group(ttype);
|
|
|
|
// register_node_type_tex_forloop(ttype);
|
|
|
|
// register_node_type_tex_whileloop(ttype);
|
|
|
|
|
|
|
|
register_node_type_tex_math(ttype);
|
|
|
|
register_node_type_tex_mix_rgb(ttype);
|
|
|
|
register_node_type_tex_valtorgb(ttype);
|
|
|
|
register_node_type_tex_rgbtobw(ttype);
|
|
|
|
register_node_type_tex_valtonor(ttype);
|
|
|
|
register_node_type_tex_curve_rgb(ttype);
|
|
|
|
register_node_type_tex_curve_time(ttype);
|
|
|
|
register_node_type_tex_invert(ttype);
|
|
|
|
register_node_type_tex_hue_sat(ttype);
|
|
|
|
register_node_type_tex_coord(ttype);
|
|
|
|
register_node_type_tex_distance(ttype);
|
|
|
|
register_node_type_tex_compose(ttype);
|
|
|
|
register_node_type_tex_decompose(ttype);
|
|
|
|
|
|
|
|
register_node_type_tex_output(ttype);
|
|
|
|
register_node_type_tex_viewer(ttype);
|
|
|
|
|
|
|
|
register_node_type_tex_checker(ttype);
|
|
|
|
register_node_type_tex_texture(ttype);
|
|
|
|
register_node_type_tex_bricks(ttype);
|
|
|
|
register_node_type_tex_image(ttype);
|
|
|
|
|
|
|
|
register_node_type_tex_rotate(ttype);
|
|
|
|
register_node_type_tex_translate(ttype);
|
|
|
|
register_node_type_tex_scale(ttype);
|
|
|
|
register_node_type_tex_at(ttype);
|
|
|
|
|
|
|
|
register_node_type_tex_proc_voronoi(ttype);
|
|
|
|
register_node_type_tex_proc_blend(ttype);
|
|
|
|
register_node_type_tex_proc_magic(ttype);
|
|
|
|
register_node_type_tex_proc_marble(ttype);
|
|
|
|
register_node_type_tex_proc_clouds(ttype);
|
|
|
|
register_node_type_tex_proc_wood(ttype);
|
|
|
|
register_node_type_tex_proc_musgrave(ttype);
|
|
|
|
register_node_type_tex_proc_noise(ttype);
|
|
|
|
register_node_type_tex_proc_stucci(ttype);
|
|
|
|
register_node_type_tex_proc_distnoise(ttype);
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void free_dynamic_typeinfo(bNodeType *ntype)
|
2008-02-09 23:17:15 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->type==NODE_DYNAMIC) {
|
|
|
|
if (ntype->inputs) {
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(ntype->inputs);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->outputs) {
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(ntype->outputs);
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->name) {
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN((void *)ntype->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_typeinfos(ListBase *list)
|
|
|
|
{
|
|
|
|
bNodeType *ntype, *next;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (ntype=list->first; ntype; ntype=next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
next = ntype->next;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->type==NODE_DYNAMIC)
|
2011-09-05 21:01:50 +00:00
|
|
|
free_dynamic_typeinfo(ntype);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ntype->needs_free)
|
2011-09-05 21:01:50 +00:00
|
|
|
MEM_freeN(ntype);
|
2008-02-09 23:17:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-26 15:07:38 +00:00
|
|
|
void init_nodesystem(void)
|
|
|
|
{
|
2011-11-20 16:13:27 +00:00
|
|
|
registerCompositNodes(ntreeGetType(NTREE_COMPOSIT));
|
|
|
|
registerShaderNodes(ntreeGetType(NTREE_SHADER));
|
|
|
|
registerTextureNodes(ntreeGetType(NTREE_TEXTURE));
|
2007-03-26 15:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void free_nodesystem(void)
|
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
free_typeinfos(&ntreeGetType(NTREE_COMPOSIT)->node_types);
|
|
|
|
free_typeinfos(&ntreeGetType(NTREE_SHADER)->node_types);
|
|
|
|
free_typeinfos(&ntreeGetType(NTREE_TEXTURE)->node_types);
|
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-03-24 06:18:31 +00:00
|
|
|
for (sce1= bmain->scene.first; sce1; sce1=sce1->id.next) {
|
|
|
|
if (sce1!=sce) {
|
|
|
|
if (sce1->nodetree) {
|
|
|
|
for (node= sce1->nodetree->nodes.first; node; node= node->next) {
|
|
|
|
if (node->type==CMP_NODE_R_LAYERS) {
|
2009-08-15 16:43:03 +00:00
|
|
|
Scene *nodesce= (Scene *)node->id;
|
|
|
|
|
|
|
|
if (nodesce==sce) node->id = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|