19912457c6
The goal here is to reduce the number of files that need to be edited when adding a new node. To register a node, one currently has to add a line to `node_geometry_register.cc` and `node_geometry_register.hh` (for geometry nodes). Those files can be generated automatically. There is a new `NOD_REGISTER_NODE` macro that nodes can use to register themselves. The macro is then discovered by `discover_nodes.py` that generates code that calls all the registration functions. The script also works when the register functions are in arbitrary namespaces. This allows simplifying the node code as well. In the past I tried a few times to get auto-registration working without resorting to code generation, but that never ended up working. The general idea for that would be to use non-trivial initialization for static variables. The issue always ends up being that the linker just discards those variables, because they are unused and it doesn't care if there are side effects in the initialization. Related discussion regarding using Python for code generation: https://devtalk.blender.org/t/code-generation-with-python/30558 Pull Request: https://projects.blender.org/blender/blender/pulls/110686
29 lines
556 B
C++
29 lines
556 B
C++
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include <string.h>
|
|
|
|
#include "BLI_math_vector.hh"
|
|
#include "BLI_utildefines.h"
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "BKE_node.hh"
|
|
|
|
#include "NOD_multi_function.hh"
|
|
#include "NOD_register.hh"
|
|
#include "NOD_socket_declarations.hh"
|
|
|
|
#include "node_util.hh"
|
|
|
|
#include "FN_multi_function_builder.hh"
|
|
|
|
#include "RNA_access.h"
|
|
|
|
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass);
|