[Bf-blender-cvs] [7de3caa05d8] master: Fix: Drag link search doesn't always connect to socket

Leon Schittek noreply at git.blender.org
Tue Mar 22 15:58:12 CET 2022


Commit: 7de3caa05d8de4aa9cf83bbeaaa298785f2366f8
Author: Leon Schittek
Date:   Tue Mar 22 09:57:50 2022 -0500
Branches: master
https://developer.blender.org/rB7de3caa05d8de4aa9cf83bbeaaa298785f2366f8

Fix: Drag link search doesn't always connect to socket

Connecting to some sockets of a few nodes via the drag link search
would fail and trigger an assert, because the picked socket wasn't
available. This was due to some sockets only being available with
certain settings.

This patch fixes these cases by adding the availability conditions of
the socket to the node declaration with the `make_available` method
or manually adding a `node_link_gather_search` function.

Differential Revision: https://developer.blender.org/D14283

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

M	source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc
M	source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
M	source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc
M	source/blender/nodes/shader/nodes/node_shader_tex_sky.cc
M	source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc

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

diff --git a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
index 3718ce6f359..a4fc1a6bfd1 100644
--- a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
+++ b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
@@ -15,11 +15,20 @@ namespace blender::nodes::node_fn_rotate_euler_cc {
 
 static void fn_node_rotate_euler_declare(NodeDeclarationBuilder &b)
 {
+  auto enable_axis_angle = [](bNode &node) {
+    node.custom1 = FN_NODE_ROTATE_EULER_TYPE_AXIS_ANGLE;
+  };
+
   b.is_function_node();
   b.add_input<decl::Vector>(N_("Rotation")).subtype(PROP_EULER).hide_value();
-  b.add_input<decl::Vector>(N_("Rotate By")).subtype(PROP_EULER);
-  b.add_input<decl::Vector>(N_("Axis")).default_value({0.0, 0.0, 1.0}).subtype(PROP_XYZ);
-  b.add_input<decl::Float>(N_("Angle")).subtype(PROP_ANGLE);
+  b.add_input<decl::Vector>(N_("Rotate By")).subtype(PROP_EULER).make_available([](bNode &node) {
+    node.custom1 = FN_NODE_ROTATE_EULER_TYPE_EULER;
+  });
+  b.add_input<decl::Vector>(N_("Axis"))
+      .default_value({0.0, 0.0, 1.0})
+      .subtype(PROP_XYZ)
+      .make_available(enable_axis_angle);
+  b.add_input<decl::Float>(N_("Angle")).subtype(PROP_ANGLE).make_available(enable_axis_angle);
   b.add_output<decl::Vector>(N_("Rotation"));
 }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
index 6c7d7ed375b..38d81c54933 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
@@ -17,6 +17,13 @@ NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveArc)
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
+  auto enable_points = [](bNode &node) {
+    node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS;
+  };
+  auto enable_radius = [](bNode &node) {
+    node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_RADIUS;
+  };
+
   b.add_input<decl::Int>(N_("Resolution"))
       .default_value(16)
       .min(2)
@@ -26,34 +33,41 @@ static void node_declare(NodeDeclarationBuilder &b)
   b.add_input<decl::Vector>(N_("Start"))
       .default_value({-1.0f, 0.0f, 0.0f})
       .subtype(PROP_TRANSLATION)
-      .description(N_("Position of the first control point"));
+      .description(N_("Position of the first control point"))
+      .make_available(enable_points);
   b.add_input<decl::Vector>(N_("Middle"))
       .default_value({0.0f, 2.0f, 0.0f})
       .subtype(PROP_TRANSLATION)
-      .description(N_("Position of the middle control point"));
+      .description(N_("Position of the middle control point"))
+      .make_available(enable_points);
   b.add_input<decl::Vector>(N_("End"))
       .default_value({1.0f, 0.0f, 0.0f})
       .subtype(PROP_TRANSLATION)
-      .description(N_("Position of the last control point"));
+      .description(N_("Position of the last control point"))
+      .make_available(enable_points);
   b.add_input<decl::Float>(N_("Radius"))
       .default_value(1.0f)
       .min(0.0f)
       .subtype(PROP_DISTANCE)
-      .description(N_("Distance of the points from the origin"));
+      .description(N_("Distance of the points from the origin"))
+      .make_available(enable_radius);
   b.add_input<decl::Float>(N_("Start Angle"))
       .default_value(0.0f)
       .subtype(PROP_ANGLE)
-      .description(N_("Starting angle of the arc"));
+      .description(N_("Starting angle of the arc"))
+      .make_available(enable_radius);
   b.add_input<decl::Float>(N_("Sweep Angle"))
       .default_value(1.75f * M_PI)
       .min(-2 * M_PI)
       .max(2 * M_PI)
       .subtype(PROP_ANGLE)
-      .description(N_("Length of the arc"));
+      .description(N_("Length of the arc"))
+      .make_available(enable_radius);
   b.add_input<decl::Float>(N_("Offset Angle"))
       .default_value(0.0f)
       .subtype(PROP_ANGLE)
-      .description(N_("Offset angle of the arc"));
+      .description(N_("Offset angle of the arc"))
+      .make_available(enable_points);
   b.add_input<decl::Bool>(N_("Connect Center"))
       .default_value(false)
       .description(N_("Connect the arc at the center"));
@@ -64,17 +78,14 @@ static void node_declare(NodeDeclarationBuilder &b)
   b.add_output<decl::Geometry>(N_("Curve"));
   b.add_output<decl::Vector>(N_("Center"))
       .description(N_("The center of the circle described by the three points"))
-      .make_available(
-          [](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; });
+      .make_available(enable_points);
   b.add_output<decl::Vector>(N_("Normal"))
       .description(N_("The normal direction of the plane described by the three points, pointing "
                       "towards the positive Z axis"))
-      .make_available(
-          [](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; });
+      .make_available(enable_points);
   b.add_output<decl::Float>(N_("Radius"))
       .description(N_("The radius of the circle described by the three points"))
-      .make_available(
-          [](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS; });
+      .make_available(enable_points);
 }
 
 static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
index 2fb9f724130..aa4b3a785f1 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
@@ -13,6 +13,13 @@ NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveCircle)
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
+  auto endable_points = [](bNode &node) {
+    node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS;
+  };
+  auto enable_radius = [](bNode &node) {
+    node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS;
+  };
+
   b.add_input<decl::Int>(N_("Resolution"))
       .default_value(32)
       .min(3)
@@ -23,28 +30,30 @@ static void node_declare(NodeDeclarationBuilder &b)
       .subtype(PROP_TRANSLATION)
       .description(
           N_("One of the three points on the circle. The point order determines the circle's "
-             "direction"));
+             "direction"))
+      .make_available(endable_points);
   b.add_input<decl::Vector>(N_("Point 2"))
       .default_value({0.0f, 1.0f, 0.0f})
       .subtype(PROP_TRANSLATION)
       .description(
           N_("One of the three points on the circle. The point order determines the circle's "
-             "direction"));
+             "direction"))
+      .make_available(endable_points);
   b.add_input<decl::Vector>(N_("Point 3"))
       .default_value({1.0f, 0.0f, 0.0f})
       .subtype(PROP_TRANSLATION)
       .description(
           N_("One of the three points on the circle. The point order determines the circle's "
-             "direction"));
+             "direction"))
+      .make_available(endable_points);
   b.add_input<decl::Float>(N_("Radius"))
       .default_value(1.0f)
       .min(0.0f)
       .subtype(PROP_DISTANCE)
-      .description(N_("Distance of the points from the origin"));
+      .description(N_("Distance of the points from the origin"))
+      .make_available(enable_radius);
   b.add_output<decl::Geometry>(N_("Curve"));
-  b.add_output<decl::Vector>(N_("Center")).make_available([](bNode &node) {
-    node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS;
-  });
+  b.add_output<decl::Vector>(N_("Center")).make_available(endable_points);
 }
 
 static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc
index 2e2f4254752..62dbcc91cc6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc
@@ -13,21 +13,29 @@ NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveLine)
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
+  auto enable_direction = [](bNode &node) {
+    node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_DIRECTION;
+  };
+
   b.add_input<decl::Vector>(N_("Start"))
       .subtype(PROP_TRANSLATION)
       .description(N_("Position of the first control point"));
   b.add_input<decl::Vector>(N_("End"))
       .default_value({0.0f, 0.0f, 1.0f})
       .subtype(PROP_TRANSLATION)
-      .description(N_("Position of the second control point"));
+      .description(N_("Position of the second control point"))
+      .make_available([](bNode &node) {
+        node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_POINTS;
+      });
   b.add_input<decl::Vector>(N_("Direction"))
       .default_value({0.0f, 0.0f, 1.0f})
-      .description(
-          N_("Direction the line is going in. The length of this vector does not matter"));
+      .description(N_("Direction the line is going in. The length of this vector does not matter"))
+      .make_available(enable_direction);
   b.add_input<decl::Float>(N_("Length"))
       .default_value(1.0f)
       .subtype(PROP_DISTANCE)
-      .description(N_("Distance between the two points"));
+      .description(N_("Distance between the two points"))
+      .make_available(enable_direction);
   b.add_output<decl::Geometry>(N_("Curve"));
 }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
index 8e28a4ba9b9..d9f29d1ef1c 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
@@ -26,17 +26,35 @@ namespace blender::nodes::node_geo_distribute_points_on_faces_cc {
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
+  auto enable_random = [](bNode &node) {
+    node.custom1 = GEO_NODE_POINT_DIST

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list