2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2006 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup nodes
|
2013-03-18 16:34:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-11-18 14:03:00 +01:00
|
|
|
#include "BKE_node_runtime.hh"
|
|
|
|
|
|
2021-12-15 09:51:57 -06:00
|
|
|
#include "NOD_socket_search_link.hh"
|
|
|
|
|
|
2021-09-28 15:29:16 -04:00
|
|
|
#include "node_composite_util.hh"
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2022-12-28 20:15:41 -05:00
|
|
|
bool cmp_node_poll_default(const bNodeType * /*ntype*/,
|
|
|
|
|
const bNodeTree *ntree,
|
|
|
|
|
const char **r_disabled_hint)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2021-04-12 18:43:23 +02:00
|
|
|
if (!STREQ(ntree->idname, "CompositorNodeTree")) {
|
2021-12-01 21:55:04 -05:00
|
|
|
*r_disabled_hint = TIP_("Not a compositor node tree");
|
2021-04-12 18:43:23 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
void cmp_node_update_default(bNodeTree * /*ntree*/, bNode *node)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2022-11-18 12:46:20 +01:00
|
|
|
node->runtime->need_exec = 1;
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
2022-01-03 19:32:33 -05:00
|
|
|
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2023-05-15 15:14:22 +02:00
|
|
|
blender::bke::node_type_base(ntype, type, name, nclass);
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntype->poll = cmp_node_poll_default;
|
|
|
|
|
ntype->updatefunc = cmp_node_update_default;
|
Node callback for handling link insertion and swapping of occupied inputs.
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.
2015-12-03 12:51:29 +01:00
|
|
|
ntype->insert_link = node_insert_link_default;
|
2021-12-15 09:51:57 -06:00
|
|
|
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|