Node panels: RNA for node group interfaces #110952

Merged
Lukas Tönne merged 10 commits from LukasTonne/blender:node-panels-rna into main 2023-08-21 15:40:27 +02:00
Member

Part 2/3 of #109135, #110272

Defines the RNA API for the new node tree interfaces.

The bulk of the RNA definition lives in rna_node_tree_interface.cc. The legacy socket interfaces remain in place and will be removed later.

Since the socket items share the bNodeSocketValueXXX structs with the bNodeSocket types they also use the same RNA. The rna_def_node_socket_interface_subtypes function is exposed so that when defining the interface RNA it can use the same code as the regular socket RNA.

Part 2/3 of #109135, #110272 Defines the RNA API for the new node tree interfaces. The bulk of the RNA definition lives in `rna_node_tree_interface.cc`. The legacy socket interfaces remain in place and will be removed later. Since the socket items share the `bNodeSocketValueXXX` structs with the `bNodeSocket` types they also use the same RNA. The `rna_def_node_socket_interface_subtypes` function is exposed so that when defining the interface RNA it can use the same code as the regular socket RNA.
Lukas Tönne added 1 commit 2023-08-09 12:57:19 +02:00
Lukas Tönne requested review from Jacques Lucke 2023-08-09 12:57:27 +02:00
Lukas Tönne requested review from Hans Goudey 2023-08-09 12:57:33 +02:00
Lukas Tönne added this to the Nodes & Physics project 2023-08-09 12:57:39 +02:00
Lukas Tönne reviewed 2023-08-09 13:00:04 +02:00
@ -50,6 +50,7 @@ const EnumPropertyItem *rna_node_tree_type_itemf(void *data,
bool (*poll)(void *data, struct bNodeTreeType *),
bool *r_free);
int rna_node_socket_idname_to_enum(const char *idname);
Author
Member

This was removed in an earlier commit, but interfaces use it to create selectable socket type buttons. The previous interface implementation used an operator with its own enum for this purpose, but the new interface can do this with a regular property.

This was removed in an earlier commit, but interfaces use it to create selectable socket type buttons. The previous interface implementation used an operator with its own enum for this purpose, but the new interface can do this with a regular property.
Lukas Tönne reviewed 2023-08-09 13:01:07 +02:00
@ -561,2 +563,3 @@
/* ******** Node Socket Subtypes ******** */
static void rna_NodeSocketStandard_float_range(
void rna_NodeSocketStandard_float_range(
Author
Member

The interface definition uses the same range callbacks as node sockets, but gets defined in a different compilation unit, so they need to be exposed.

The interface definition uses the same range callbacks as node sockets, but gets defined in a different compilation unit, so they need to be exposed.
Hans Goudey reviewed 2023-08-11 19:06:45 +02:00
Hans Goudey left a comment
Member

Generally seems okay. I think I might have been misreading some of the diff, since you mentioned in the description that you were keeping the old interface RNA definitions temporarily. But I guess it wasn't clear which parts you want to keep or remove long term.

Generally seems okay. I think I might have been misreading some of the diff, since you mentioned in the description that you were keeping the old interface RNA definitions temporarily. But I guess it wasn't clear which parts you want to keep or remove long term.
@ -4727,6 +4727,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_nla.cc", nullptr, RNA_def_nla},
{"rna_nodetree.cc", nullptr, RNA_def_nodetree},
{"rna_node_socket.cc", nullptr, RNA_def_node_socket_subtypes},
{"rna_node_tree_interface.cc", NULL, RNA_def_node_tree_interface},
Member

nullptr

`nullptr`
LukasTonne marked this conversation as resolved
@ -942,0 +992,4 @@
func, "color", 4, default_draw_color, 0.0f, 1.0f, "Color", "", 0.0f, 1.0f);
RNA_def_function_output(func, parm);
/* XXX Legacy socket interface, this will be removed. */
Member

It's a bit confusing reading "legacy, will be removed" in new code in a PR for a system that's replacing the old interface-- is this comment still relevant? Maybe a chance to do it right or remove deprecated methods? Am I missing something?

It's a bit confusing reading "legacy, will be removed" in new code in a PR for a system that's replacing the old interface-- is this comment still relevant? Maybe a chance to do it right or remove deprecated methods? Am I missing something?
Author
Member

Yeah, splitting up PRs can get a bit confusing, i'm replacing the comment with

    /* Note: Legacy socket interface below.
     * The new interface RNA is defined in a separate file,
     * the NodeSocketInterface struct will be replaced. */

Reason this shows up as "new code" is that i've moved the final socket subtypes definitions. Previously rna_def_node_socket_standard_types included both the NodeSocketInterfaceStandard base struct and the final types (NodeSocketFloatUnsigned etc.).

Final types are now defined in rna_def_node_socket_subtypes, and a similar function rna_def_node_socket_interface_subtypes is called for defining the respective interface structs.

Yeah, splitting up PRs can get a bit confusing, i'm replacing the comment with ``` /* Note: Legacy socket interface below. * The new interface RNA is defined in a separate file, * the NodeSocketInterface struct will be replaced. */ ``` Reason this shows up as "new code" is that i've moved the final socket subtypes definitions. Previously `rna_def_node_socket_standard_types` included both the `NodeSocketInterfaceStandard` base struct and the final types (`NodeSocketFloatUnsigned` etc.). Final types are now defined in `rna_def_node_socket_subtypes`, and a similar function `rna_def_node_socket_interface_subtypes` is called for defining the respective interface structs.
LukasTonne marked this conversation as resolved
@ -1681,0 +2014,4 @@
const char *label;
};
/* XXX would like to have this in BKE and base all the subtype stuff (nodeStaticSocketType***)
Member

I'd rephrase this comment as a "note" or something, or change it in this PR. Or maybe you had a different plan

I'd rephrase this comment as a "note" or something, or change it in this PR. Or maybe you had a different plan
LukasTonne marked this conversation as resolved
@ -1681,0 +2018,4 @@
* on the same central list instead of repeating the same switch statements everywhere.
* But makesrna cannot have a dependency on BKE, so this list would have to live in RNA itself,
* with BKE etc. accessing the RNA API to get the subtypes info. */
static blender::Span<bNodeSocketStaticTypeInfo> nodeSocketStaticTypeInfo()
Member

Might be nice to use snake_case here like most other "new" functions

Might be nice to use snake_case here like most other "new" functions
LukasTonne marked this conversation as resolved
@ -1681,0 +2020,4 @@
* with BKE etc. accessing the RNA API to get the subtypes info. */
static blender::Span<bNodeSocketStaticTypeInfo> nodeSocketStaticTypeInfo()
{
static const blender::Array<bNodeSocketStaticTypeInfo> node_socket_subtypes = {
Member

I think std::array is generally preferred for static arrays since it doesn't allocate or store the size

I think `std::array` is generally preferred for static arrays since it doesn't allocate or store the size
Author
Member

Using a simple static const bNodeSocketStaticTypeInfo node_socket_subtypes[] now.
TIL C++ range-based loops actually also work for such plain arrays :)
https://stackoverflow.com/questions/7939399/how-does-the-range-based-for-work-for-plain-arrays

Using a simple `static const bNodeSocketStaticTypeInfo node_socket_subtypes[]` now. TIL C++ range-based loops actually also work for such plain arrays :) https://stackoverflow.com/questions/7939399/how-does-the-range-based-for-work-for-plain-arrays
LukasTonne marked this conversation as resolved
Lukas Tönne added 3 commits 2023-08-17 10:20:59 +02:00
Lukas Tönne added 1 commit 2023-08-17 10:32:58 +02:00
Lukas Tönne added 1 commit 2023-08-17 10:34:56 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
8275674cd8
Cleanup: nullptr instead of NULL.
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey approved these changes 2023-08-19 23:24:52 +02:00
Hans Goudey left a comment
Member

I find the way this is split from the other change confusing, with old code looking new in the diff, and new code commented out. But I don't have a good enough understanding to suggest a better way to organize things, and the next step will come soon anyway I suppose.

Only idea I'd have is possibly removing or re-adding some code in a separate commit.

I find the way this is split from the other change confusing, with old code looking new in the diff, and new code commented out. But I don't have a good enough understanding to suggest a better way to organize things, and the next step will come soon anyway I suppose. Only idea I'd have is possibly removing or re-adding some code in a separate commit.
@ -0,0 +32,4 @@
# include "WM_api.hh"
/* Internal RNA function declarations, used to invoke registered callbacks. */
extern "C" {
Member

Do these have to be declared with "extern C" still?

Do these have to be declared with "extern C" still?
Author
Member

Correct, this extern "C" doesn't seem to be needed any more. makesrna generates .cc files now with regular C++ linkage for these functions (and for some reason declares these functions as extern but defines them in the same file anyway). Nodes RNA seems to be the last place using extern "C" declarations for registerable function implementations, will fix those. It probably works either way because these are free functions at root namespace level.

Correct, this `extern "C"` doesn't seem to be needed any more. makesrna generates .cc files now with regular C++ linkage for these functions (and for some reason declares these functions as `extern` but defines them in the same file anyway). Nodes RNA seems to be the last place using extern "C" declarations for registerable function implementations, will fix those. It probably works either way because these are free functions at root namespace level.
LukasTonne marked this conversation as resolved
@ -0,0 +59,4 @@
if (socket_typeinfo && socket_typeinfo->ext_interface.srna) {
return socket_typeinfo->ext_interface.srna;
}
else {
Member

else after return

else after return
LukasTonne marked this conversation as resolved
Lukas Tönne added 3 commits 2023-08-21 10:54:46 +02:00
8f3a01b9cf Removed unnecessary `extern "C"` from RNA function declarations.
Makesrna now generates fully C++ code, the "C" linkage declaration is
no longer necessary.
buildbot/vexp-code-patch-coordinator Build done. Details
9ba141b0b3
Cleanup: removed else after return.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2023-08-21 13:02:55 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
4f73c68cc6
Merge branch 'main' into node-panels-rna
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne merged commit ea3d85b9d7 into main 2023-08-21 15:40:27 +02:00
Lukas Tönne deleted branch node-panels-rna 2023-08-21 15:40:29 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#110952
No description provided.