diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-03-18 20:34:57 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-03-18 20:34:57 +0400 |
commit | 4638e5f99a9ba59ad0b8a1fd52b12e876480b9e8 (patch) | |
tree | 2444f12b4612440f44cf02835cdf5951b6564e92 /source/blender/nodes/composite/node_composite_tree.c | |
parent | 7bfef29f2f2a1b262d28abdc6e30fcd9c1f1caad (diff) |
Merge of the PyNodes branch (aka "custom nodes") into trunk.
PyNodes opens up the node system in Blender to scripters and adds a number of UI-level improvements.
=== Dynamic node type registration ===
Node types can now be added at runtime, using the RNA registration mechanism from python. This enables addons such as render engines to create a complete user interface with nodes.
Examples of how such nodes can be defined can be found in my personal wiki docs atm [1] and as a script template in release/scripts/templates_py/custom_nodes.py [2].
=== Node group improvements ===
Each node editor now has a tree history of edited node groups, which allows opening and editing nested node groups. The node editor also supports pinning now, so that different spaces can be used to edit different node groups simultaneously. For more ramblings and rationale see (really old) blog post on code.blender.org [3].
The interface of node groups has been overhauled. Sockets of a node group are no longer displayed in columns on either side, but instead special input/output nodes are used to mirror group sockets inside a node tree. This solves the problem of long node lines in groups and allows more adaptable node layout. Internal sockets can be exposed from a group by either connecting to the extension sockets in input/output nodes (shown as empty circle) or by adding sockets from the node property bar in the "Interface" panel. Further details such as the socket name can also be changed there.
[1] http://wiki.blender.org/index.php/User:Phonybone/Python_Nodes
[2] http://projects.blender.org/scm/viewvc.php/trunk/blender/release/scripts/templates_py/custom_nodes.py?view=markup&root=bf-blender
[3] http://code.blender.org/index.php/2012/01/improving-node-group-interface-editing/
Diffstat (limited to 'source/blender/nodes/composite/node_composite_tree.c')
-rw-r--r-- | source/blender/nodes/composite/node_composite_tree.c | 108 |
1 files changed, 41 insertions, 67 deletions
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 999bcb9bba5..d10ab9d8d49 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -44,6 +44,7 @@ #include "BKE_animsys.h" #include "BKE_colortools.h" +#include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_main.h" @@ -64,14 +65,17 @@ #include "COM_compositor.h" #endif -static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) +static void composite_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from) { - Scene *sce; - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->nodetree) { - func(calldata, &sce->id, sce->nodetree); - } - } + Scene *scene = CTX_data_scene(C); + + *r_from = NULL; + *r_id = &scene->id; + *r_ntree = scene->nodetree; + + /* update output sockets based on available layers */ + ntreeCompositForceHidden(scene->nodetree, scene); + } static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func) @@ -85,6 +89,7 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa func(calldata, NODE_CLASS_MATTE, N_("Matte")); func(calldata, NODE_CLASS_DISTORT, N_("Distort")); func(calldata, NODE_CLASS_GROUP, N_("Group")); + func(calldata, NODE_CLASS_INTERFACE, N_("Interface")); func(calldata, NODE_CLASS_LAYOUT, N_("Layout")); } @@ -106,22 +111,6 @@ static void free_cache(bNodeTree *ntree) free_node_cache(ntree, node); } -static void update_node(bNodeTree *ntree, bNode *node) -{ - bNodeSocket *sock; - - for (sock= node->outputs.first; sock; sock= sock->next) { - if (sock->cache) { - //free_compbuf(sock->cache); - //sock->cache= NULL; - } - } - node->need_exec= 1; - /* individual node update call */ - if (node->typeinfo->updatefunc) - node->typeinfo->updatefunc(ntree, node); -} - /* local tree then owns all compbufs */ static void localize(bNodeTree *localtree, bNodeTree *ntree) { @@ -145,16 +134,6 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) } } - /* copy over the preview buffers to update graduatly */ - if (node->preview) { - bNodePreview *preview = MEM_callocN(sizeof(bNodePreview), "Preview"); - preview->pad = node->preview->pad; - preview->xsize = node->preview->xsize; - preview->ysize = node->preview->ysize; - preview->rect = MEM_dupallocN(node->preview->rect); - node->new_node->preview = preview; - } - for (sock= node->outputs.first; sock; sock= sock->next) { sock->new_sock->cache= sock->cache; sock->cache= NULL; @@ -183,24 +162,8 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) } } -static void local_sync(bNodeTree *localtree, bNodeTree *ntree) +static void local_sync(bNodeTree *UNUSED(localtree), bNodeTree *UNUSED(ntree)) { - bNode *lnode; - - /* move over the compbufs and previews */ - for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { - if ( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) { - if (ntreeNodeExists(ntree, lnode->new_node)) { - - if (lnode->preview && lnode->preview->rect) { - nodeFreePreview(lnode->new_node); - lnode->new_node->preview= lnode->preview; - lnode->preview= NULL; - } - - } - } - } } static void local_merge(bNodeTree *localtree, bNodeTree *ntree) @@ -245,27 +208,38 @@ static void update(bNodeTree *ntree) ntreeSetOutput(ntree); ntree_update_reroute_nodes(ntree); + + if (ntree->update & NTREE_UPDATE_NODES) { + /* clean up preview cache, in case nodes have been removed */ + BKE_node_preview_remove_unused(ntree); + } } -bNodeTreeType ntreeType_Composite = { - /* type */ NTREE_COMPOSIT, - /* idname */ "NTCompositing Nodetree", +bNodeTreeType *ntreeType_Composite; + +void register_node_tree_type_cmp() +{ + bNodeTreeType *tt = ntreeType_Composite = MEM_callocN(sizeof(bNodeTreeType), "compositor node tree type"); - /* node_types */ { NULL, NULL }, + tt->type = NTREE_COMPOSIT; + strcpy(tt->idname, "CompositorNodeTree"); + strcpy(tt->ui_name, "Compositing"); + tt->ui_icon = 0; /* defined in drawnode.c */ + strcpy(tt->ui_description, ""); - /* free_cache */ free_cache, - /* free_node_cache */ free_node_cache, - /* foreach_nodetree */ foreach_nodetree, - /* foreach_nodeclass */ foreach_nodeclass, - /* localize */ localize, - /* local_sync */ local_sync, - /* local_merge */ local_merge, - /* update */ update, - /* update_node */ update_node, - /* validate_link */ NULL, - /* update_internal_links */ node_update_internal_links_default -}; - + tt->free_cache = free_cache; + tt->free_node_cache = free_node_cache; + tt->foreach_nodeclass = foreach_nodeclass; + tt->localize = localize; + tt->local_sync = local_sync; + tt->local_merge = local_merge; + tt->update = update; + tt->get_from_context = composite_get_from_context; + + tt->ext.srna = &RNA_CompositorNodeTree; + + ntreeTypeAdd(tt); +} void *COM_linker_hack = NULL; |