Nodes: Panels integration with blend files and UI #111348

Merged
Lukas Tönne merged 96 commits from LukasTonne/blender:node-panels-final into main 2023-08-30 12:37:28 +02:00

96 Commits

Author SHA1 Message Date
Lukas Tönne f02bef4918 Removed unused headers.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-30 11:32:06 +02:00
Lukas Tönne 7ee2bf9227 Change order of default empty node group sockets to outputs..inputs. 2023-08-30 10:56:34 +02:00
Lukas Tönne 816286daac Cleanup: comment formatting. 2023-08-30 10:49:24 +02:00
Lukas Tönne 7b54b3ba97 Set legacy pointer to null after versioning. 2023-08-30 10:48:14 +02:00
Lukas Tönne 8fb321c713 Bump subversion to 20. 2023-08-30 10:46:57 +02:00
Lukas Tönne 157d079d12 Merge branch 'main' into node-panels-final 2023-08-30 10:43:58 +02:00
Lukas Tönne ae7a5b6d57 When a panel is selected, insert socket into it instead of next to it. 2023-08-29 17:20:17 +02:00
Lukas Tönne b27f21c012 Make subtype, in_out type and socket_type non-animatable properties. 2023-08-29 16:57:28 +02:00
Lukas Tönne 452bf82a0f Pass subtype set by reference. 2023-08-29 16:51:36 +02:00
Lukas Tönne 1403d8a6dd Removed unwanted newline. 2023-08-29 16:50:51 +02:00
Lukas Tönne 9faa8b62c5 Simplified code for cleaning up legacy socket lists after versioning. 2023-08-29 16:47:12 +02:00
Lukas Tönne 73abe76429 Simpler way of populated versioned interface without pointer reference. 2023-08-29 16:43:27 +02:00
Lukas Tönne 09fa101b69 Removed unused include. 2023-08-29 16:38:50 +02:00
Lukas Tönne 4e45d8f2c3 Remove "Type" from "Input/Output Type" label. 2023-08-29 16:37:54 +02:00
Lukas Tönne 85ea0fcf62 Merge branch 'main' into node-panels-final 2023-08-29 16:10:03 +02:00
Lukas Tönne eaeb6c0ef4 Cleanup: Formatting.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-29 13:03:41 +02:00
Lukas Tönne f885ad1237 Merge branch 'main' into node-panels-final 2023-08-29 13:02:19 +02:00
Lukas Tönne c896561262 Replaced `interface_cache` with getters for inputs, outputs, and items. 2023-08-29 13:01:17 +02:00
Lukas Tönne 9c3bc873df Refactored versioning for sockets to avoid using external functions. 2023-08-29 12:43:18 +02:00
Lukas Tönne c0461c55e4 Added subtype properties to socket float, int, vector RNA structs. 2023-08-29 11:27:09 +02:00
Lukas Tönne 1123692d23 Show socket type above other properties as "Type". 2023-08-29 10:45:14 +02:00
Lukas Tönne 3694200093 Draw geometry domain details above default value details. 2023-08-29 10:44:07 +02:00
Lukas Tönne 12df4dd1dd Use "Input/Output Type" for the socket kind for now. 2023-08-29 10:26:25 +02:00
Lukas Tönne efeda653c3 Enable property split for node socket details. 2023-08-29 10:20:37 +02:00
Lukas Tönne de5c03b712 Removed the name button in socket details, can be done in the tree view. 2023-08-29 10:10:30 +02:00
Lukas Tönne e0b4d69dfe Moved the socket copy operator into a dropdown menu for consistency. 2023-08-29 10:08:34 +02:00
Lukas Tönne 5cb876f893 Removed the "Socket" suffix from operator enum for adding input/output. 2023-08-29 09:59:29 +02:00
Lukas Tönne 6342365c0c Fixed typo in the bl_node_group_interface test.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-28 11:05:17 +02:00
Lukas Tönne b30255ad02 Cleanup: formatting. 2023-08-28 10:57:30 +02:00
Lukas Tönne 42556bbb75 Show `default_closed` property for panels with "Closed by Default" text.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-28 10:54:23 +02:00
Lukas Tönne d6b5c04f32 Avoid small offsets when placing items in a collapsed panel. 2023-08-28 10:49:49 +02:00
Lukas Tönne c010de1200 Swap order of inputs and outputs when making a node group.
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.
2023-08-28 10:38:43 +02:00
Lukas Tönne ecd4c3a22f Restore alignment rules for sockets to their previous behavior. 2023-08-28 10:30:28 +02:00
Lukas Tönne 45ec9915ea Merge branch 'main' into node-panels-final 2023-08-28 09:47:47 +02:00
Lukas Tönne 809ae99ba1 Extend panel background slightly beyond the last item. 2023-08-25 18:09:09 +02:00
Lukas Tönne cd7c71478a Ignore empty panels when generating declarations. 2023-08-25 18:04:35 +02:00
Lukas Tönne 62023ece9d Nicer background drawing for node panels.
- Use agreed-upon colors for the panel background.
- Fix overlap with the node boundary
- Don't draw panel background when collapsed.
2023-08-25 17:40:57 +02:00
Lukas Tönne 135f42f238 Remove const from by-value parameters in declarations. 2023-08-25 16:17:27 +02:00
Lukas Tönne a7aa5a9c8c Update comments, `e` prefix has been removed from flag type names. 2023-08-25 16:15:56 +02:00
Lukas Tönne f977a66909 Use `this->` prefix for flag to avoid ambiguity with parameters. 2023-08-25 16:14:30 +02:00
Lukas Tönne de9a259181 Use `interface_cache` to avoid ambiguity. 2023-08-25 16:11:58 +02:00
Lukas Tönne f4015e5b53 Renamed `declaration` in node group ui template to `interface`. 2023-08-25 16:09:51 +02:00
Lukas Tönne aa1446fb14 Merge branch 'main' into node-panels-final 2023-08-25 16:01:16 +02:00
Lukas Tönne 9236aa6949 Renamed "Sockets" panel to "Interface". 2023-08-25 16:00:44 +02:00
Lukas Tönne 7c2b6dc50d Move topology cache update closer to the code that needs it. 2023-08-25 15:35:21 +02:00
Lukas Tönne 3a0db7cba9 Fix for consistent panel states: Copy the old states before replacing.
Also renamed `uid` in bNodePanelState and PanelDeclaration to
`identifier`.
2023-08-25 15:28:24 +02:00
Lukas Tönne 93aa416fa6 Replace `is_input`/`is_output` flags with an enum for `in_out` flags.
This also avoids users setting neither input nor output flags.
2023-08-25 13:52:48 +02:00
Lukas Tönne 6745adac51 Insert new items after the current active. 2023-08-25 13:01:04 +02:00
Lukas Tönne b0765a1991 Set a sensible interface active item index when removing or copying. 2023-08-25 12:54:20 +02:00
Lukas Tönne 2eb9c31a9d Fix active item callback for interface tree view.
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.
2023-08-25 12:49:15 +02:00
Lukas Tönne d0844d3d2c Fix insert location for drag+drop.
The last+1 index of the items list is a valid insert position. Indices
of items are shifted down when move from a lower position.
2023-08-25 12:25:11 +02:00
Lukas Tönne efa5ce9660 Fix interface test, take new sockets..panels ordering into account. 2023-08-25 12:06:06 +02:00
Lukas Tönne c91afe3f3a Fix insertion constraint function, inserting shifts item at that pos. 2023-08-25 12:05:21 +02:00
Lukas Tönne effb72cb4a Merge branch 'main' into node-panels-final 2023-08-25 11:05:34 +02:00
Lukas Tönne 73a8499119 Added flag to keep panels grouped at the bottom of the list.
This is just another panel flag, so it could be disabled or removed
easily.
2023-08-24 18:42:21 +02:00
Lukas Tönne a3dcc27447 Generate sockets in outputs..inputs order when both are enabled.
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.
2023-08-24 16:21:17 +02:00
Lukas Tönne cdb3b8e096 Fix versioning, still wasn't copying 'default_value' from old sockets.
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.
2023-08-24 16:16:51 +02:00
Lukas Tönne 408b3b7164 Removed the up/down buttons.
Drag+drop can be the primary method for moving items in the UI now.
2023-08-24 16:01:54 +02:00
Lukas Tönne 6e689bd2d5 Fix versioning: outputs/inputs socket order and missing attribute info.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-24 13:14:39 +02:00
Lukas Tönne e6f047756e Updated custom_nodes.py template with less convoluted properties. 2023-08-24 12:57:01 +02:00
Lukas Tönne 16996a7c58 Ignore `FUNC_USE_SELF_ID` flag for the draw method, doesn't do anything. 2023-08-24 12:55:45 +02:00
Lukas Tönne 6b3759f3cd Fix crash when saving a blend file with undefined sockets.
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.
2023-08-24 12:52:30 +02:00
Lukas Tönne 8332dabbd8 Fix registerable draw_color_simple callback, must not have SELF_TYPE.
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.
2023-08-24 12:35:08 +02:00
Lukas Tönne ca82f437fc Augmented socket callbacks with a simplified color function.
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.
2023-08-24 11:49:48 +02:00
Lukas Tönne fd4a280091 Merge branch 'main' into node-panels-final 2023-08-24 10:46:11 +02:00
Lukas Tönne 7a6a6e5114 Update active item index after moving in a more reliable way. 2023-08-24 10:45:32 +02:00
Lukas Tönne 827991217c Use position instead of global index for moving items. 2023-08-23 19:47:13 +02:00
Lukas Tönne c10fc7d810 Fixed crash when using repeat zones caused by invalid socket reference.
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.
2023-08-23 18:32:41 +02:00
Lukas Tönne 8d857b9d91 Merge branch 'main' into node-panels-final 2023-08-23 18:09:01 +02:00
Lukas Tönne ed494e9ff5 Subversion bump to avoid using DNA struct type check for versioning.
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.
2023-08-23 17:49:02 +02:00
Lukas Tönne f9e5cb7424 Fix socket type assert when casting from a socket subtype.
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.
2023-08-23 17:42:33 +02:00
Lukas Tönne ccaf3aa562 Updated bpy.types classes for the new socket interface. 2023-08-23 16:51:30 +02:00
Lukas Tönne 6632f900e6 Added a flag to ensure built-in nodes use conventional socket order.
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.
2023-08-23 16:37:12 +02:00
Lukas Tönne 0829157962 Copy all properties and flags when constructing legacy sockets.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-23 14:43:27 +02:00
Lukas Tönne e2e019f573 Ensure the legacy sockets are always freed after versioning. 2023-08-23 14:43:00 +02:00
Lukas Tönne f8c1fe3830 Fix forward compatibility for node group interfaces.
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.
2023-08-23 13:12:22 +02:00
Lukas Tönne 8ae73bdaa6 Merge branch 'main' into node-panels-final 2023-08-23 10:01:45 +02:00
Lukas Tönne 4255705f4b Removed legacy sockets from copy/free code, not needed. 2023-08-22 11:10:39 +02:00
Lukas Tönne 76a8e6994f const pointers for writing where possible. 2023-08-22 11:05:54 +02:00
Lukas Tönne c87e7af6da Added comment to explain why const_cast is needed when building cache. 2023-08-22 10:50:50 +02:00
Lukas Tönne f1a88f079a Moved versioning code back to where it belongs after merge. 2023-08-22 10:45:11 +02:00
Lukas Tönne e6bafce090 Move class member variables to the top. 2023-08-22 10:42:51 +02:00
Lukas Tönne d57c03023f Formatting fixes. 2023-08-22 10:39:09 +02:00
Lukas Tönne bfd317d939 C++ static cast. 2023-08-22 10:00:47 +02:00
Lukas Tönne 623c92ff74 Removed `is_child_panel_allowed` property. 2023-08-22 09:57:51 +02:00
Lukas Tönne cfc0a12329 Formatting fix. 2023-08-22 09:55:03 +02:00
Lukas Tönne 389fa71a88 Merge branch 'main' into node-panels-final 2023-08-22 09:52:13 +02:00
Lukas Tönne f1ef48e373 Add a little bit of space between node items, match previous layout.
buildbot/vexp-code-patch-coordinator Build done. Details
2023-08-21 16:46:05 +02:00
Lukas Tönne 4be946e674 Fix crash due to socket identifier string not being written.
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.
2023-08-21 16:38:25 +02:00
Lukas Tönne a837b068eb Check if child panels are allowed before trying to create them. 2023-08-21 15:48:58 +02:00
Lukas Tönne 2cb1aa06ee Allow child panels in the interface root panel. 2023-08-21 15:48:58 +02:00
Lukas Tönne 53c0a3ee04 Added a flag to control when a panel is allowed to contain other panels. 2023-08-21 15:48:58 +02:00
Lukas Tönne 92b382f859 Cleanup: Fixed TODO comment. 2023-08-21 15:48:58 +02:00
Lukas Tönne 74081c3b00 Added description and "default closed" flags to panel declarations. 2023-08-21 15:48:58 +02:00
Lukas Tönne 5a19e46285 Extented drop down for adding sockets to quickly add input or output.
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.
2023-08-21 15:48:58 +02:00
Lukas Tönne a876ee9a6f Part 3/3 of #109135, #110272
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.
2023-08-21 15:48:58 +02:00