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:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-07-27 15:03:23 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-08-04 11:29:16 +0300
commit9306037ed3d14a7afce607738f83c8b9968d478d (patch)
tree6a0855906983fa33367060ef540ad611c1a83382 /source/blender/editors/space_node
parentb016e7f258a5be68af56574f185dd4acd08d9af5 (diff)
Node Groups: expose the SOCK_HIDE_VALUE flag for node group inputs.
This flag specifies that even when the socket is not connected, the node should not display the input field for the constant input value. This is useful for inputs like Normal, which have special handling for the missing input case and don't use a constant value. Currently there is no way to change this flag from Python, and through UI it can only be done by re-creating the socket. This patch exposes the flag through RNA and UI, makes sure it is properly updated when changed, and adds special handling to ensure that it is correctly set when creating a node group from a node set that includes reroute nodes. Differential Revision: https://developer.blender.org/D8395
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/drawnode.c2
-rw-r--r--source/blender/editors/space_node/node_group.c34
2 files changed, 25 insertions, 11 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 695214bcc2f..01883f1c086 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3576,6 +3576,8 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout
break;
}
}
+
+ uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, NULL, 0);
}
void ED_init_standard_node_socket_type(bNodeSocketType *stype)
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 2f34e7048ab..8dc67ad48f5 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -56,6 +56,7 @@
#include "UI_resources.h"
#include "NOD_common.h"
+#include "NOD_socket.h"
#include "node_intern.h" /* own include */
static bool node_group_operator_active(bContext *C)
@@ -719,8 +720,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
Main *bmain = CTX_data_main(C);
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeLink *link, *linkn;
- bNode *node, *nextn;
- bNodeSocket *sock;
+ bNode *node, *nextn, *link_node;
+ bNodeSocket *sock, *link_sock;
ListBase anim_basepaths = {NULL, NULL};
float min[2], max[2], real_min[2], real_max[2], center[2];
int totselect;
@@ -821,12 +822,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
*/
nodeRemLink(ntree, link);
}
- else if (fromselect && toselect) {
- BLI_remlink(&ntree->links, link);
- BLI_addtail(&ngroup->links, link);
- }
- else if (toselect) {
- bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock);
+ else if (toselect && !fromselect) {
+ node_socket_skip_reroutes(&ntree->links, link->tonode, link->tosock, &link_node, &link_sock);
+ bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock);
bNodeSocket *input_sock;
/* update the group node and interface node sockets,
@@ -843,7 +841,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
link->tonode = gnode;
link->tosock = node_group_find_input_socket(gnode, iosock->identifier);
}
- else if (fromselect) {
+ else if (fromselect && !toselect) {
/* First check whether the source of this link is already connected to an output.
* If yes, reuse that output instead of duplicating it. */
bool connected = false;
@@ -859,8 +857,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
if (!connected) {
- bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(
- ngroup, link->fromnode, link->fromsock);
+ node_socket_skip_reroutes(
+ &ntree->links, link->fromnode, link->fromsock, &link_node, &link_sock);
+ bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock);
bNodeSocket *output_sock;
/* update the group node and interface node sockets,
@@ -880,6 +879,19 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
}
+ /* move internal links */
+ for (link = ntree->links.first; link; link = linkn) {
+ int fromselect = node_group_make_use_node(link->fromnode, gnode);
+ int toselect = node_group_make_use_node(link->tonode, gnode);
+
+ linkn = link->next;
+
+ if (fromselect && toselect) {
+ BLI_remlink(&ntree->links, link);
+ BLI_addtail(&ngroup->links, link);
+ }
+ }
+
/* move nodes in the group to the center */
for (node = ngroup->nodes.first; node; node = node->next) {
if (node_group_make_use_node(node, gnode) && !node->parent) {