[Bf-blender-cvs] [b265b447b63] master: Fix various cases of incorrect filtering in node link drag search

Hans Goudey noreply at git.blender.org
Thu Dec 16 01:05:52 CET 2021


Commit: b265b447b639601ab53d1dc3cae0c3a95020cd64
Author: Hans Goudey
Date:   Wed Dec 15 18:05:45 2021 -0600
Branches: master
https://developer.blender.org/rBb265b447b639601ab53d1dc3cae0c3a95020cd64

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.

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
M	source/blender/nodes/geometry/nodes/node_geo_raycast.cc
M	source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
M	source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc
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/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
index 22a9e4a0c33..be0baa706af 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
@@ -96,17 +96,14 @@ static void node_update(bNodeTree *ntree, bNode *node)
 
 static void node_gather_link_searches(GatherLinkSearchOpParams &params)
 {
-  const bNodeType &node_type = params.node_type();
-  if (params.other_socket().type == SOCK_GEOMETRY) {
-    params.add_item(IFACE_("Geometry"), [node_type](LinkSearchOpParams &params) {
-      bNode &node = params.add_node(node_type);
-      params.connect_available_socket(node, "Geometry");
-    });
-  }
+  const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
+  search_link_ops_for_declarations(params, declaration.inputs().take_front(1));
+  search_link_ops_for_declarations(params, declaration.outputs().take_front(1));
 
+  const bNodeType &node_type = params.node_type();
   const std::optional<CustomDataType> type = node_data_type_to_custom_data_type(
       (eNodeSocketDatatype)params.other_socket().type);
-  if (type) {
+  if (type && *type != CD_PROP_STRING) {
     if (params.in_out() == SOCK_OUT) {
       params.add_item(IFACE_("Attribute"), [node_type, type](LinkSearchOpParams &params) {
         bNode &node = params.add_node(node_type);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc
index 07bd7cec766..ff6294b9b6b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc
@@ -159,15 +159,12 @@ class SocketSearchOp {
 
 static void node_gather_link_searches(GatherLinkSearchOpParams &params)
 {
+  const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
   if (params.in_out() == SOCK_OUT) {
-    if (params.other_socket().type == SOCK_GEOMETRY) {
-      params.add_item(IFACE_("Curve"), [](LinkSearchOpParams &params) {
-        bNode &node = params.add_node("GeometryNodeCurvePrimitiveQuadrilateral");
-        params.connect_available_socket(node, "Curve");
-      });
-    }
+    search_link_ops_for_declarations(params, declaration.outputs());
   }
-  else {
+  else if (params.node_tree().typeinfo->validate_link(
+               static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
     params.add_item(IFACE_("Width"),
                     SocketSearchOp{"Width", GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE});
     params.add_item(IFACE_("Height"),
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});
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
index 389dc278197..41ad4d79f1e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
@@ -109,31 +109,34 @@ static void node_gather_link_searches(GatherLinkSearchOpParams &params)
     search_link_ops_for_declarations(params, declaration.outputs());
     return;
   }
-  params.add_item(IFACE_("Count"), [](LinkSearchOpParams &params) {
-    bNode &node = params.add_node("GeometryNodeMeshLine");
-    node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET;
-    params.connect_available_socket(node, "Count");
-  });
-  params.add_item(IFACE_("Resolution"), [](LinkSearchOpParams &params) {
-    bNode &node = params.add_node("GeometryNodeMeshLine");
-    node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET;
-    node_storage(node).count_mode = GEO_NODE_MESH_LINE_COUNT_RESOLUTION;
-    params.connect_available_socket(node, "Resolution");
-  });
-  params.add_item(IFACE_("Start Location"), [](LinkSearchOpParams &params) {
-    bNode &node = params.add_node("GeometryNodeMeshLine");
-    params.connect_available_socket(node, "Start Location");
-  });
-  params.add_item(IFACE_("Offset"), [](LinkSearchOpParams &params) {
-    bNode &node = params.add_node("GeometryNodeMeshLine");
-    params.connect_available_socket(node, "Offset");
-  });
-  /* The last socket is reused in end points mode. */
-  params.add_item(IFACE_("End Location"), [](LinkSearchOpParams &params) {
-    bNode &node = params.add_node("GeometryNodeMeshLine");
-    node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_END_POINTS;
-    params.connect_available_socket(node, "Offset");
-  });
+  else if (params.node_tree().typeinfo->validate_link(
+          static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
+    params.add_item(IFACE_("Count"), [](LinkSearchOpParams &params) {
+      bNode &node = params.add_node("GeometryNodeMeshLine");
+      node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET;
+      params.connect_available_socket(node, "Count");
+    });
+    params.add_item(IFACE_("Resolution"), [](LinkSearchOpParams &params) {
+      bNode &node = params.add_node("GeometryNodeMeshLine");
+      node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET;
+      node_storage(node).count_mode = GEO_NODE_MESH_LINE_COUNT_RESOLUTION;
+      params.connect_available_socket(node, "Resolution");
+    });
+    params.add_item(IFACE_("Start Location"), [](LinkSearchOpParams &params) {
+      bNode &node = params.add_node("GeometryNodeMeshLine");
+      params.connect_available_socket(node, "Start Location");
+    });
+    params.add_item(IFACE_("Offset"), [](LinkSearchOpParams &params) {
+      bNode &node = params.add_node("GeometryNodeMeshLine");
+      params.connect_available_socket(node, "Offset");
+    });
+    /* The last socket is reused in end points mode. */
+    params.add_item(IFACE_("End Location"), [](LinkSearchOpParams &params) {
+      bNode &node = params.add_node("GeometryNodeMeshLine");
+      node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_END_POINTS;
+      params.connect_available_socket(node, "Offset");
+    });
+  }
 }
 
 static void node_geo_exec(GeoNodeExecParams params)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
index 8968675c1ed..d255fe482f6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
@@ -121,7 +121,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams &params)
 
   const std::optional<CustomDataType> type = node_data_type_to_custom_data_type(
       (eNodeSocketDatatype)params.other_socket().type);
-  if (type) {
+  if (type && *type != CD_PROP_STRING) {
     /* The input and output sockets have the same name. */
     params.add_item(IFACE_("Attribute"), [type](LinkSearchOpParams &params) {
       bNode &node = params.add_node("GeometryNodeRaycast");
diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
index e30b11907e8..33614eb3c46 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
@@ -63,7 +63,7 @@ static void node_declare(NodeDeclarationBuilder &b)
       });
   b.add_output<decl::Geometry>(N_("Curves"));
   b.add_output<decl::String>(N_("Remainder")).make_available([](bNode &node) {
-    node_storage(node).overflow = GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW;
+    node_storage(node).overflow = GEO_NODE_STRING_TO_CURVES_MODE_TRUNCATE;
   });
 }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc
index 007373929f4..1f099dcd04d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc
@@ -136,19 +136,13 @@ static void node_update(bNodeTree *ntree, bNode *node)
 
 static void node_gather_link_searches(Gath

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list