Fix inconsistent creation of `NodeTreeTypeUndefined` type of node tree
Currently, when creating a new node tree ID, its `typeinfo` is set to `NodeTreeTypeUndefined`, but its `type` enum value is left to `0`, aka `NTREE_SHADER`. This patch adds a new `NTREE_UNDIFINED` value, and use it for `NodeTreeTypeUndefined` types of node trees. NOTE: While it is not clear whether that actually fixes issues currently, quite a bit of code still relies on the value of `type`, so think it makes sense to sanitize this. NOTE: Would have been ideal to reserve `0` value to undefined type, but at this point this is not possible anymore, so chose to use `-2` instead. Reviewed By: JacquesLucke Differential Revision: https://developer.blender.org/D13123
This commit is contained in:
parent
fc373af8f5
commit
d6e2210935
|
@ -1160,15 +1160,15 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo)
|
|||
{
|
||||
if (typeinfo) {
|
||||
ntree->typeinfo = typeinfo;
|
||||
|
||||
/* deprecated integer type */
|
||||
ntree->type = typeinfo->type;
|
||||
}
|
||||
else {
|
||||
ntree->typeinfo = &NodeTreeTypeUndefined;
|
||||
|
||||
ntree->init &= ~NTREE_TYPE_INIT;
|
||||
}
|
||||
|
||||
/* Deprecated integer type. */
|
||||
ntree->type = ntree->typeinfo->type;
|
||||
}
|
||||
|
||||
static void node_set_typeinfo(const struct bContext *C,
|
||||
|
@ -5533,6 +5533,7 @@ static void register_undefined_types()
|
|||
* they are just used as placeholders in case the actual types are not registered.
|
||||
*/
|
||||
|
||||
NodeTreeTypeUndefined.type = NTREE_UNDEFINED;
|
||||
strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined");
|
||||
strcpy(NodeTreeTypeUndefined.ui_name, N_("Undefined"));
|
||||
strcpy(NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type"));
|
||||
|
|
|
@ -577,7 +577,9 @@ typedef struct bNodeTree {
|
|||
} bNodeTree;
|
||||
|
||||
/* ntree->type, index */
|
||||
#define NTREE_CUSTOM -1 /* for dynamically registered custom types */
|
||||
|
||||
#define NTREE_UNDEFINED -2 /* Represents #NodeTreeTypeUndefined type. */
|
||||
#define NTREE_CUSTOM -1 /* for dynamically registered custom types */
|
||||
#define NTREE_SHADER 0
|
||||
#define NTREE_COMPOSIT 1
|
||||
#define NTREE_TEXTURE 2
|
||||
|
|
|
@ -12753,6 +12753,11 @@ static void rna_def_nodetree(BlenderRNA *brna)
|
|||
PropertyRNA *parm;
|
||||
|
||||
static const EnumPropertyItem static_type_items[] = {
|
||||
{NTREE_UNDEFINED,
|
||||
"UNDEFINED",
|
||||
ICON_QUESTION,
|
||||
"Undefined",
|
||||
"Undefined type of nodes (can happen e.g. when a linked node tree goes missing)"},
|
||||
{NTREE_SHADER, "SHADER", ICON_MATERIAL, "Shader", "Shader nodes"},
|
||||
{NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes"},
|
||||
{NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes"},
|
||||
|
|
Loading…
Reference in New Issue