Nodes have a feature for moving existing links to unoccupied sockets when connecting to an already used input. This is based on the standard legacy socket types (value/float, vector, color/rgba) and works reasonably well for shader, compositor and texture nodes. For new pynode systems, however, the hardcoded nature of that feature has major drawbacks: * It does not take different type systems into account, leading to meaningless connections when sockets are swapped and making the feature useless or outright debilitating. * Advanced socket behaviors would be possible with a registerable callback, e.g. creating extensible input lists that move existing connections down to make room for a new link. Now any handling of new links is done via the 'insert_links' callback, which can also be registered through the RNA API. For the legacy shader/compo/tex nodes the behavior is the same, using a C callback. Note on the 'use_swap' flag: this has been removed because it was meaningless anyway: It was disabled only for the insert-node-on-link feature, which works only for completely unconnected nodes anyway, so there would be nothing to swap in the first place.
61 lines
1.8 KiB
C
61 lines
1.8 KiB
C
/*
|
|
* ***** 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,
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
* All rights reserved.
|
|
*
|
|
* The Original Code is: all of this file.
|
|
*
|
|
* Contributor(s): none yet.
|
|
*
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
*/
|
|
|
|
/** \file blender/nodes/composite/node_composite_util.c
|
|
* \ingroup nodes
|
|
*/
|
|
|
|
#include "node_composite_util.h"
|
|
|
|
|
|
int cmp_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
|
|
{
|
|
return STREQ(ntree->idname, "CompositorNodeTree");
|
|
}
|
|
|
|
void cmp_node_update_default(bNodeTree *UNUSED(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;
|
|
}
|
|
|
|
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
|
|
{
|
|
node_type_base(ntype, type, name, nclass, flag);
|
|
|
|
ntype->poll = cmp_node_poll_default;
|
|
ntype->updatefunc = cmp_node_update_default;
|
|
ntype->insert_link = node_insert_link_default;
|
|
ntype->update_internal_links = node_update_internal_links_default;
|
|
}
|