Previously the order didn't matter because inputs and outputs were
always separate. Now we have to take care to add sockets in the desired
order. Node groups will keep the familiar outputs..inputs order by
default.
Item references for the callback have to be captured by reference to get
comparable pointers. Ideally bNodeTreeInterfaceSocket would not be
copyable in the first place, but it's still a C DNA struct.
Node group items can be specified as both input and output. This will
eventually generate sockets in the same vertical slot, but for now
generate sockets in the conventional layout.
This slips through testing easily because the actual node instance
input values remain the same, only the node group settings for new
nodes are affected.
This can happen when loading a file with custom python nodes and the
script defining them has not run or has failed. The forward-
compatibility code that creates equivalent socket cannot create copies
for unknown socket types, so it has to ignore such sockets.
This is very confusing RNA behavior: When a registerable method is
supposed to be a @classmethod it needs to have the `FUNC_NO_SELF` flag
set but NOT the `FUNC_USE_SELF_TYPE` flag (see
`bpy_class_validate_recursive` TODO comments). The overridden function
in the `NodeSocketStandard` subclass that has a built-in implementation,
however, needs the `FUNC_USE_SELF_TYPE` flag.
The new `draw_color_simple` callback does not depend on context or
a socket pointer or a node pointer, it only requires the socket
typeinfo (`bNodeSocketType`). In Python it's a registerable classmethod.
The existing `draw_color` callback also becomes optional in order to not
break existing scripts. One of the two functions should be implemented
by custom python nodes, preferably the `draw_color_simple` variant.
The declaration code for these nodes calculates the output field
dependency index based on the number of existing inputs, which requires
that input declarations are added to the list right away. It was
producing -1 index because the inputs list lagged behind by 1.
The `bNodeTreeInterface` DNA type has been added in main a while ago,
and new test files have been added in the meantime. This makes the
DNA check for versioning unreliable, it will skip versioning test files
which already have the DNA struct but need to be versioned.
Using a subversion bump is much more reliable.
The `socket_data_is_type` function was only considering base types,
but can be called for socket subtypes in some circumstances.
Use the same list as RNA to find a match among the subtypes too.
Custom socket order and panels can be enabled by setting the
`use_custom_socket_order` flag on node declarations. This is currently
only enabled for group nodes.
The legacy input/output sockets ListBases must be constructed _before_
the ID struct of the bNodeTree is written, since it writes the
first/last pointer addresses of these lists.
Versioning code now also avoids calling BKE functions.
This is a recent regression: The original int uid was copied implicitly,
the string was only a transient identifier for legacy sockets. Now all
sockets use string identifiers again.
The socket added by the "Socket" drop down option was neither input nor
output, which is confusing. To get sensible defaults, the menu now has
separate "Input" and "Output" options.
Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.
The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces
All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.
Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.
The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.
A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.