Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2021-07-06 20:36:11 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2021-07-06 20:36:11 +0300
commit586cf8b1905257bf0f7d9c20b5333271f9cab3e9 (patch)
tree5fa77626641c47f4274b9145a1f1702512fc92b6 /source/blender/nodes/geometry/node_geometry_tree.cc
parent933eddc9a113b40849895922f2dc350305809ebd (diff)
Nodes: Adds button to groups to change type of sockets.
The menu lists all socket types that are valid for the node tree. Changing a socket type updates all instances of the group and keeps existing links to the socket. If changing the socket type leads to incorrect node connections the links are flagged as invalid (red) and ignored but not removed. This is so users don't lose information and can then fix resulting issues. For example: Changing a Color socket to a Shader socket can cause an invalid Shader-to-Color connection. Implementation details: The new `NODE_OT_tree_socket_change_type` operator uses the generic `rna_node_socket_type_itemf` function to list all eligible socket types. It uses the tree type's `valid_socket_type` callback to test for valid types. In addition it also checks the subtype, because multiple RNA types are registered for the same base type. The `valid_socket_type` callback has been modified slightly to accept full socket types instead of just the base type enum, so that custom (python) socket types can be used by this operator. The `nodeModifySocketType` function is now called when group nodes encounter a socket type mismatch, instead of replacing the socket entirely. This ensures that links are kept to/from group nodes as well as group input/output nodes. The `nodeModifySocketType` function now also takes a full `bNodeSocketType` instead of just the base and subtype enum (a shortcut `nodeModifySocketTypeStatic` exists for when only static types are used). Differential Revision: https://developer.blender.org/D10912
Diffstat (limited to 'source/blender/nodes/geometry/node_geometry_tree.cc')
-rw-r--r--source/blender/nodes/geometry/node_geometry_tree.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc
index f4cd00b88ed..07a89a1fa8c 100644
--- a/source/blender/nodes/geometry/node_geometry_tree.cc
+++ b/source/blender/nodes/geometry/node_geometry_tree.cc
@@ -95,21 +95,21 @@ static bool geometry_node_tree_validate_link(bNodeTree *UNUSED(ntree), bNodeLink
return (link->tosock->type == link->fromsock->type);
}
-static bool geometry_node_tree_socket_type_valid(eNodeSocketDatatype socket_type,
- bNodeTreeType *UNUSED(ntreetype))
+static bool geometry_node_tree_socket_type_valid(bNodeTreeType *UNUSED(ntreetype),
+ bNodeSocketType *socket_type)
{
- return ELEM(socket_type,
- SOCK_FLOAT,
- SOCK_VECTOR,
- SOCK_RGBA,
- SOCK_BOOLEAN,
- SOCK_INT,
- SOCK_STRING,
- SOCK_OBJECT,
- SOCK_GEOMETRY,
- SOCK_COLLECTION,
- SOCK_TEXTURE,
- SOCK_MATERIAL);
+ return nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type,
+ SOCK_FLOAT,
+ SOCK_VECTOR,
+ SOCK_RGBA,
+ SOCK_BOOLEAN,
+ SOCK_INT,
+ SOCK_STRING,
+ SOCK_OBJECT,
+ SOCK_GEOMETRY,
+ SOCK_COLLECTION,
+ SOCK_TEXTURE,
+ SOCK_MATERIAL);
}
void register_node_tree_type_geo(void)