Blender
In addition to a file that defines the function of a node, there are several files that need to be updated to reference that new code as well. This document will create a new geometry node called Stub. The instructions will also reference changes to the stub code for creating a function node.
source/blender/blenkernel/BKE_node.h
BKE_node contains a mapping of a static number to a human readable name that will refernce the node. A search of GEO_NODE_ or FN_NODE_ (depending on the type of node) in this file will reveal a list of #define statements. At the bottom of this list choose an unused incremented number and assign it a name.
#define GEO_NODE_STUB 1111
Your Node Source Code File
This file will contain the logic and layout information for your node. This file will live in the folder appropriate to its type:
For the purposes of this documentation, we will create a geometry node stub called
source/blender/nodes/geometry/nodes/node_geo_stub.cc
The contents of this file will vary based on whether we are coding a geometry node or a function node. The main similarity will be a node registration function that the other files will reference. The layout of the main node file will be covered in another document.
void register_node_type_geo_stub()
{
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_STUB, "Geometry Stub Example", NODE_CLASS_GEOMETRY, 0);
// OTHER Node definitions and function references here
nodeRegisterType(&ntype);
}
There are a few items to note in this code.
Declare a bNodeType variable.
The geo_node_type_base() function takes the following parameters:
source/blender/blenkernel/intern/node.cc
There is a function called registerGeometryNodes() in which to call the registration function defined in the node source file.
register_node_type_geo_stub()
source/blender/nodes/CMakeLists.txt
In the CMakeLists file go to the secion of files in the geometry/nodes/ folder and add the node source file in alphabetical order:
geometry/nodes/node_geo_stub.cc
source/blender/nodes/NOD_geometry.h or
source/blender/nodes/NOD_funcation.h
In the file corresponding to the type of node being created, add the function prototype of the node registration function in aplhabetical order:
void register_node_type_geo_stub(void);
source/blender/nodes/NOD_static_types.h
This file contains the node definitions. In alphabetical order add the DefNode line for the new node
DefNode(GeometryNode, GEO_NODE_STUB, 0, "STUB", Stub, "Stub Node", "")
The parameters are as follows:
release/scripts/startup/nodeitems_builtins.py
This file contains the definition for the Add Nodes Menu.
Search for the appropriate GeometryNodeCategory to add an entry. The NodeItem name is a combination of the NodeType from the DefNode entry and the Pascal case version of the name.
NodeItem("GeometryNodeStub"),