[Bf-blender-cvs] [f2112199a4d] temp-geometry-nodes-fields-prototype: Add utilities to enable and disable output sockets with a type

Hans Goudey noreply at git.blender.org
Sat Aug 7 00:13:59 CEST 2021


Commit: f2112199a4dce81d7a3644b4499309f10847c458
Author: Hans Goudey
Date:   Fri Aug 6 17:08:22 2021 -0500
Branches: temp-geometry-nodes-fields-prototype
https://developer.blender.org/rBf2112199a4dce81d7a3644b4499309f10847c458

Add utilities to enable and disable output sockets with a type

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

M	source/blender/nodes/geometry/node_geometry_util.cc
M	source/blender/nodes/geometry/node_geometry_util.hh

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

diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc
index 455bc8c55dc..4ea12190ae8 100644
--- a/source/blender/nodes/geometry/node_geometry_util.cc
+++ b/source/blender/nodes/geometry/node_geometry_util.cc
@@ -30,6 +30,40 @@ namespace blender::nodes {
 
 using bke::GeometryInstanceGroup;
 
+static void update_multi_type_socket_availabilities(ListBase &socket_list,
+                                                    const StringRef name,
+                                                    const CustomDataType type,
+                                                    const bool name_is_available)
+{
+  LISTBASE_FOREACH (bNodeSocket *, socket, &socket_list) {
+    if (name == socket->name) {
+      const bool socket_is_available = name_is_available &&
+                                       ((socket->type == SOCK_STRING && type == CD_PROP_STRING) ||
+                                        (socket->type == SOCK_FLOAT && type == CD_PROP_FLOAT) ||
+                                        (socket->type == SOCK_INT && type == CD_PROP_INT32) ||
+                                        (socket->type == SOCK_VECTOR && type == CD_PROP_FLOAT3) ||
+                                        (socket->type == SOCK_RGBA && type == CD_PROP_COLOR));
+      nodeSetSocketAvailability(socket, socket_is_available);
+    }
+  }
+}
+
+void update_multi_type_input_socket_availabilities(bNode &node,
+                                                   const StringRef name,
+                                                   const CustomDataType type,
+                                                   const bool name_is_available)
+{
+  update_multi_type_socket_availabilities(node.inputs, name, type, name_is_available);
+}
+
+void update_multi_type_output_socket_availabilities(bNode &node,
+                                                    const StringRef name,
+                                                    const CustomDataType type,
+                                                    const bool name_is_available)
+{
+  update_multi_type_socket_availabilities(node.outputs, name, type, name_is_available);
+}
+
 /**
  * Update the availability of a group of input sockets with the same name,
  * used for switching between attribute inputs or single values.
diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh
index b2d5a542e3b..2aa7276578a 100644
--- a/source/blender/nodes/geometry/node_geometry_util.hh
+++ b/source/blender/nodes/geometry/node_geometry_util.hh
@@ -46,6 +46,16 @@ void update_attribute_input_socket_availabilities(bNode &node,
                                                   const GeometryNodeAttributeInputMode mode,
                                                   const bool name_is_available = true);
 
+void update_multi_type_input_socket_availabilities(bNode &node,
+                                                   const StringRef name,
+                                                   const CustomDataType type,
+                                                   const bool name_is_available = true);
+
+void update_multi_type_output_socket_availabilities(bNode &node,
+                                                    const StringRef name,
+                                                    const CustomDataType type,
+                                                    const bool name_is_available = true);
+
 Array<uint32_t> get_geometry_element_ids_as_uints(const GeometryComponent &component,
                                                   const AttributeDomain domain);



More information about the Bf-blender-cvs mailing list