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:
authorHans Goudey <h.goudey@me.com>2021-12-16 03:05:45 +0300
committerHans Goudey <h.goudey@me.com>2021-12-16 03:05:45 +0300
commitb265b447b639601ab53d1dc3cae0c3a95020cd64 (patch)
tree76bda73cece22524358a78fab7f593584406a09f /source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
parent36a830b4d36d31ae29166e0defa6ed62a9a7a321 (diff)
Fix various cases of incorrect filtering in node link drag search
Some nodes didn't check the type of the link's socket for filtering. Do this with a combination of manually calling the node tree's validate links function and using the helper function for declarations. Also clean up a few cases that added geometry sockets manually when they can use the simpler helper function.
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc36
1 files changed, 19 insertions, 17 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
index c6908cb8ed0..746392a66cc 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
@@ -90,26 +90,28 @@ static void node_update(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, end_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH);
}
+class SocketSearchOp {
+ public:
+ StringRef socket_name;
+ GeometryNodeCurveSampleMode mode;
+ void operator()(LinkSearchOpParams &params)
+ {
+ bNode &node = params.add_node("GeometryNodeTrimCurve");
+ node_storage(node).mode = mode;
+ params.update_and_connect_available_socket(node, socket_name);
+ }
+};
+
static void node_gather_link_searches(GatherLinkSearchOpParams &params)
{
- class SocketSearchOp {
- public:
- StringRef socket_name;
- GeometryNodeCurveSampleMode mode;
- void operator()(LinkSearchOpParams &params)
- {
- bNode &node = params.add_node("GeometryNodeTrimCurve");
- node_storage(node).mode = mode;
- params.update_and_connect_available_socket(node, socket_name);
- }
- };
+ const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
- if (params.in_out() == SOCK_OUT) {
- params.add_item(IFACE_("Curve"), SocketSearchOp{"Curve", GEO_NODE_CURVE_SAMPLE_FACTOR});
- }
- else {
- params.add_item(IFACE_("Curve"), SocketSearchOp{"Curve", GEO_NODE_CURVE_SAMPLE_FACTOR});
- if (params.other_socket().type == SOCK_FLOAT) {
+ search_link_ops_for_declarations(params, declaration.outputs());
+ search_link_ops_for_declarations(params, declaration.inputs().take_front(1));
+
+ if (params.in_out() == SOCK_IN) {
+ if (params.node_tree().typeinfo->validate_link(
+ static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
params.add_item(IFACE_("Start (Factor)"),
SocketSearchOp{"Start", GEO_NODE_CURVE_SAMPLE_FACTOR});
params.add_item(IFACE_("End (Factor)"), SocketSearchOp{"End", GEO_NODE_CURVE_SAMPLE_FACTOR});