[Bf-blender-cvs] [ec5160ee946] temp-geometry-nodes-fields-prototype-visualization: change link colors slightly
Jacques Lucke
noreply at git.blender.org
Tue Aug 24 13:41:26 CEST 2021
Commit: ec5160ee946ae625991556a056f0379a1faefb6d
Author: Jacques Lucke
Date: Tue Aug 24 13:38:53 2021 +0200
Branches: temp-geometry-nodes-fields-prototype-visualization
https://developer.blender.org/rBec5160ee946ae625991556a056f0379a1faefb6d
change link colors slightly
===================================================================
M source/blender/editors/space_node/drawnode.cc
M source/blender/editors/space_node/node_draw.cc
M source/blender/editors/space_node/node_intern.h
M source/blender/nodes/function/nodes/node_fn_input_vector.cc
===================================================================
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index 0f7a911e3ce..6f8c0a513da 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -4278,6 +4278,28 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
}
}
+ if (link->fromsock) {
+ const SocketSingleState from_single_state = get_socket_single_state(
+ snode->edittree, link->fromnode, link->fromsock);
+ if (ELEM(from_single_state,
+ SocketSingleState::RequiredSingle,
+ SocketSingleState::CurrentlySingle)) {
+ th_col1 = th_col2 = TH_ACTIVE;
+ }
+ }
+
+ if (link->fromsock && link->tosock) {
+ const SocketSingleState to_single_state = get_socket_single_state(
+ snode->edittree, link->tonode, link->tosock);
+ const SocketSingleState from_single_state = get_socket_single_state(
+ snode->edittree, link->fromnode, link->fromsock);
+
+ if (to_single_state == SocketSingleState::RequiredSingle &&
+ from_single_state == SocketSingleState::MaybeField) {
+ th_col1 = th_col2 = TH_REDALERT;
+ }
+ }
+
node_draw_link_bezier(v2d, snode, link, th_col1, th_col2, th_col3);
}
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 23169809fc7..2de8cbaf7ee 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -789,12 +789,6 @@ static void node_socket_draw_rounded_rectangle(const float color[4],
&rect, color, nullptr, 1.0f, color_outline, outline_width, width - outline_width * 0.5f);
}
-enum class SocketSingleState {
- RequiredSingle,
- CurrentlySingle,
- MaybeField,
-};
-
#define PRIMITIVE_SOCKETS SOCK_FLOAT, SOCK_VECTOR, SOCK_INT, SOCK_BOOLEAN, SOCK_RGBA
static bool is_required_single(const bNodeTree *node_tree,
@@ -833,13 +827,18 @@ static bool is_maybe_field(const bNodeTree *node_tree,
return true;
}
if (socket->in_out == SOCK_IN) {
+ bool found_link = false;
LISTBASE_FOREACH (const bNodeLink *, link, &node_tree->links) {
if (link->tosock == socket) {
+ found_link = true;
if (is_maybe_field(node_tree, link->fromnode, link->fromsock)) {
return true;
}
}
}
+ if (!found_link && (socket->flag & SOCK_HIDE_VALUE) && socket->type == SOCK_VECTOR) {
+ return true;
+ }
}
else {
LISTBASE_FOREACH (const bNodeSocket *, input, &node->inputs) {
@@ -853,9 +852,9 @@ static bool is_maybe_field(const bNodeTree *node_tree,
return false;
}
-static SocketSingleState get_socket_single_state(const bNodeTree *node_tree,
- const bNode *node,
- const bNodeSocket *socket)
+SocketSingleState get_socket_single_state(const bNodeTree *node_tree,
+ const bNode *node,
+ const bNodeSocket *socket)
{
if (node_tree->type != NTREE_GEOMETRY) {
return SocketSingleState::MaybeField;
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index df20420e472..394abb5e207 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -340,3 +340,14 @@ extern const char *node_context_dir[];
#ifdef __cplusplus
}
#endif
+
+#ifdef __cplusplus
+enum class SocketSingleState {
+ RequiredSingle,
+ CurrentlySingle,
+ MaybeField,
+};
+SocketSingleState get_socket_single_state(const struct bNodeTree *node_tree,
+ const struct bNode *node,
+ const struct bNodeSocket *socket);
+#endif
diff --git a/source/blender/nodes/function/nodes/node_fn_input_vector.cc b/source/blender/nodes/function/nodes/node_fn_input_vector.cc
index 2cd4eb1d9df..9f88da90ea4 100644
--- a/source/blender/nodes/function/nodes/node_fn_input_vector.cc
+++ b/source/blender/nodes/function/nodes/node_fn_input_vector.cc
@@ -22,7 +22,7 @@
#include "UI_resources.h"
static bNodeSocketTemplate fn_node_input_vector_out[] = {
- {SOCK_VECTOR, N_("Vector")},
+ {SOCK_VECTOR, N_("Vector"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_ALWAYS_SINGLE},
{-1, ""},
};
More information about the Bf-blender-cvs
mailing list