Fix: Nodes: update supported node types check for dynamic legacy types
Newer nodes may not have a fixed `legacy_type`. This was not accounted for correctly when reading nodes. Such newer nodes are exclusively identified by their idname. Fortunately, Blender 4.4 was released without any new nodes that don't have a fixed `legacy_type`. So this does not have to be backported. Pull Request: https://projects.blender.org/blender/blender/pulls/136431
This commit is contained in:
@@ -4028,22 +4028,25 @@ static Set<int> get_known_node_types_set()
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool can_read_node_type(const int type)
|
||||
static bool can_read_node_type(const bNode &node)
|
||||
{
|
||||
/* Can always read custom node types. */
|
||||
if (ELEM(type, NODE_CUSTOM, NODE_CUSTOM_GROUP)) {
|
||||
if (ELEM(node.type_legacy, NODE_CUSTOM, NODE_CUSTOM_GROUP)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check known built-in types. */
|
||||
static Set<int> known_types = get_known_node_types_set();
|
||||
return known_types.contains(type);
|
||||
if (node.type_legacy < NODE_LEGACY_TYPE_GENERATION_START) {
|
||||
/* Check known built-in types. */
|
||||
static Set<int> known_types = get_known_node_types_set();
|
||||
return known_types.contains(node.type_legacy);
|
||||
}
|
||||
/* Nodes with larger legacy_type are only identified by their idname. */
|
||||
return node_type_find(node.idname) != nullptr;
|
||||
}
|
||||
|
||||
static void node_replace_undefined_types(bNode *node)
|
||||
{
|
||||
/* If the integer type is unknown then this node cannot be read. */
|
||||
if (!can_read_node_type(node->type_legacy)) {
|
||||
/* If the node type is built-in but unknown, the node cannot be read. */
|
||||
if (!can_read_node_type(*node)) {
|
||||
node->type_legacy = NODE_CUSTOM;
|
||||
/* This type name is arbitrary, it just has to be unique enough to not match a future node
|
||||
* idname. Includes the old type identifier for debugging purposes. */
|
||||
|
||||
Reference in New Issue
Block a user