Page MenuHome

Nodes: Add more flexible method to declare the sockets of a node.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Aug 27 2021, 5:16 PM.

Details

Summary

This is a first step towards the following goals:

  • Make it easier to have a dynamic number of sockets in a node.
  • Get rid of bNodeSocketTemplate, which is quite annoying to use for some socket types.
  • Add support for some type inferencing features.

Right now this patch is designed as a refactor that only focusses on replacing bNodeSocketTemplate with a function that can be called at runtime. Other features will be much easier to build on top of this instead of bNodeSocketTemplate. The rollout of this new approach can be gradual, it can live side by side with bNodeSocketTemplate for a while. Therefore, I don't intend to update all nodes in this patch.

Diff Detail

Repository
rB Blender
Branch
temp-node-socket-declaration (branched from master)
Build Status
Buildable 16686
Build 16686: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Aug 27 2021, 5:16 PM
Jacques Lucke (JacquesLucke) created this revision.
  • Merge branch 'master' into temp-node-socket-declaration
  • fix id user counting
  • update curve trim node
  • update transform node
  • cleanup patch
Jacques Lucke (JacquesLucke) retitled this revision from Nodes: Add more flexible method to declare the sockets of a node. (WIP) to Nodes: Add more flexible method to declare the sockets of a node..Aug 30 2021, 12:56 PM
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)

Looks like a good improvement to me! And the start of some important changes : )

Only relatively minor things noted inline.

source/blender/blenkernel/intern/node.cc
891

I wonder if the check for the new declaration callback could be done here instead, to avoid reusing the socket template function name.

Alternatively that function could be renamed I suppose.

source/blender/nodes/NOD_node_declaration.hh
48

Maybe it's worth having using SocketDeclarationPtr = std::unique_ptr<SocketDeclaration>;?

source/blender/nodes/NOD_socket_declarations.hh
31–32

How about using soft_min_ and soft_max_ here? It could skip the confusion I had a year or two ago why I could make the value lower than the min

source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
49

I think we should keep the socket declarations at the top of the file, it's nice to have them in a consistent place. If it's necessary, like in this case, we could add the layout and init functions to the blender::nodes namespace.

source/blender/nodes/intern/node_socket.cc
194

Use const

197

Looks like this is basically just used as an assertion that a socket hasn't been added before?

229

Could just use else, right?

This revision is now accepted and ready to land.Aug 30 2021, 3:53 PM
source/blender/nodes/intern/node_socket.cc
197

Nevermind!

Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • rename to node_verify_sockets
  • use SocketDeclarationPtr
  • use soft_*
  • cleanup