[Bf-blender-cvs] [71468f475b4] master: Nodes: Weight drag link search for Math nodes
Charlie Jolly
noreply at git.blender.org
Fri Dec 31 03:36:55 CET 2021
Commit: 71468f475b449fc2c72d9c0438db9b37788058ab
Author: Charlie Jolly
Date: Fri Dec 31 02:32:28 2021 +0000
Branches: master
https://developer.blender.org/rB71468f475b449fc2c72d9c0438db9b37788058ab
Nodes: Weight drag link search for Math nodes
As @hooglyboogly suggested in D13680, this patch adds weighting
to the search results. Dragging from a vector/rgba socket weights
the Vector Math node higher than a float Math node, and vice versa.
Reviewed By: HooglyBoogly
Differential Revision: https://developer.blender.org/D13691
===================================================================
M source/blender/nodes/shader/nodes/node_shader_math.cc
M source/blender/nodes/shader/nodes/node_shader_vector_math.cc
===================================================================
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc
index 7337a1172bf..1b450a6414b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_math.cc
@@ -70,11 +70,15 @@ static void sh_node_math_gather_link_searches(GatherLinkSearchOpParams ¶ms)
/* Expose first Value socket. */
if (params.node_tree().typeinfo->validate_link(
static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
+
+ const int weight = ELEM(params.other_socket().type, SOCK_FLOAT, SOCK_BOOLEAN, SOCK_INT) ? 0 :
+ -1;
+
for (const EnumPropertyItem *item = rna_enum_node_math_items; item->identifier != nullptr;
item++) {
if (item->name != nullptr && item->identifier != "") {
- params.add_item(IFACE_(item->name),
- SocketSearchOp{"Value", (NodeMathOperation)item->value});
+ params.add_item(
+ IFACE_(item->name), SocketSearchOp{"Value", (NodeMathOperation)item->value}, weight);
}
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
index 0218e759bea..a488e709373 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
@@ -64,6 +64,8 @@ static void sh_node_vector_math_gather_link_searches(GatherLinkSearchOpParams &p
return;
}
+ const int weight = ELEM(params.other_socket().type, SOCK_VECTOR, SOCK_RGBA) ? 0 : -1;
+
for (const EnumPropertyItem *item = rna_enum_node_vec_math_items; item->identifier != nullptr;
item++) {
if (item->name != nullptr && item->identifier != "") {
@@ -72,11 +74,13 @@ static void sh_node_vector_math_gather_link_searches(GatherLinkSearchOpParams &p
NODE_VECTOR_MATH_DISTANCE,
NODE_VECTOR_MATH_DOT_PRODUCT)) {
params.add_item(IFACE_(item->name),
- SocketSearchOp{"Value", (NodeVectorMathOperation)item->value});
+ SocketSearchOp{"Value", (NodeVectorMathOperation)item->value},
+ weight);
}
else {
params.add_item(IFACE_(item->name),
- SocketSearchOp{"Vector", (NodeVectorMathOperation)item->value});
+ SocketSearchOp{"Vector", (NodeVectorMathOperation)item->value},
+ weight);
}
}
}
More information about the Bf-blender-cvs
mailing list