From ad489b71646a2e03e2ce9b0d193d541e3987b4cd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 3 Feb 2020 09:02:00 +0100 Subject: Cleanup: add type inheritance for Cycles nodes --- intern/cycles/graph/node_type.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'intern/cycles/graph/node_type.h') diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h index e9496a42658..a4461ec7abb 100644 --- a/intern/cycles/graph/node_type.h +++ b/intern/cycles/graph/node_type.h @@ -103,7 +103,7 @@ struct SocketType { struct NodeType { enum Type { NONE, SHADER }; - explicit NodeType(Type type = NONE); + explicit NodeType(Type type = NONE, const NodeType *base = NULL); ~NodeType(); void register_input(ustring name, @@ -124,11 +124,15 @@ struct NodeType { ustring name; Type type; + const NodeType *base; vector> inputs; vector> outputs; CreateFunc create; - static NodeType *add(const char *name, CreateFunc create, Type type = NONE); + static NodeType *add(const char *name, + CreateFunc create, + Type type = NONE, + const NodeType *base = NULL); static const NodeType *find(ustring name); static unordered_map &types(); }; @@ -148,6 +152,14 @@ struct NodeType { } \ template const NodeType *structname::register_type() +#define NODE_ABSTRACT_DECLARE \ + template static const NodeType *register_type(); \ + static const NodeType *node_type; + +#define NODE_ABSTRACT_DEFINE(structname) \ + const NodeType *structname::node_type = structname::register_type(); \ + template const NodeType *structname::register_type() + /* Sock Definition Macros */ #define SOCKET_OFFSETOF(T, name) (((char *)&(((T *)1)->name)) - (char *)1) -- cgit v1.2.3