[Bf-blender-cvs] [b4c49e595f2] temp-geometry-nodes-fields-prototype-visualization: initial visualization

Jacques Lucke noreply at git.blender.org
Tue Aug 24 13:41:25 CEST 2021


Commit: b4c49e595f2730920b597b344ccb705a4b93d36b
Author: Jacques Lucke
Date:   Tue Aug 24 12:53:38 2021 +0200
Branches: temp-geometry-nodes-fields-prototype-visualization
https://developer.blender.org/rBb4c49e595f2730920b597b344ccb705a4b93d36b

initial visualization

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

M	source/blender/editors/space_node/node_draw.cc
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_freeze.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc
M	source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc
M	source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
M	source/blender/nodes/geometry/nodes/node_geo_evaluate_curve.cc
M	source/blender/nodes/geometry/nodes/node_geo_extrude.cc
M	source/blender/nodes/geometry/nodes/node_geo_extrude_and_move.cc
M	source/blender/nodes/geometry/nodes/node_geo_index.cc
M	source/blender/nodes/geometry/nodes/node_geo_is_viewport.cc
M	source/blender/nodes/geometry/nodes/node_geo_material_assign.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc
M	source/blender/nodes/geometry/nodes/node_geo_normal.cc
M	source/blender/nodes/geometry/nodes/node_geo_object_info.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
M	source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
M	source/blender/nodes/geometry/nodes/node_geo_position.cc
M	source/blender/nodes/geometry/nodes/node_geo_raycast.cc
M	source/blender/nodes/geometry/nodes/node_geo_sample_mesh_surface.cc
M	source/blender/nodes/geometry/nodes/node_geo_set_position.cc
M	source/blender/nodes/geometry/nodes/node_geo_switch.cc
M	source/blender/nodes/geometry/nodes/node_geo_transform.cc

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

diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 84741f61245..9d6098fbb10 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -789,38 +789,29 @@ static void node_socket_draw_rounded_rectangle(const float color[4],
       &rect, color, nullptr, 1.0f, color_outline, outline_width, width - outline_width * 0.5f);
 }
 
-static bool use_special_non_field_socket_drawing(const bNodeTree *node_tree,
+enum class SocketSingleState {
+  RequiredSingle,
+  CurrentlySingle,
+  MaybeField,
+};
+
+static SocketSingleState get_socket_single_state(const bNodeTree *node_tree,
                                                  const bNode *node,
                                                  const bNodeSocket *socket)
 {
   if (node_tree->type != NTREE_GEOMETRY) {
-    return false;
+    return SocketSingleState::MaybeField;
   }
-  if (ELEM(socket->type,
-           SOCK_MATERIAL,
-           SOCK_GEOMETRY,
-           SOCK_TEXTURE,
-           SOCK_COLLECTION,
-           SOCK_OBJECT,
-           SOCK_IMAGE,
-           SOCK_STRING)) {
-    return false;
+  if (socket->type == -1) {
+    return SocketSingleState::MaybeField;
   }
-  if (socket->flag & SOCK_FIELD) {
-    return false;
+  if (!ELEM(socket->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_INT, SOCK_BOOLEAN, SOCK_RGBA)) {
+    return SocketSingleState::RequiredSingle;
   }
-  if (socket->in_out == SOCK_OUT) {
-    return false;
+  if (socket->flag & SOCK_ALWAYS_SINGLE) {
+    return SocketSingleState::RequiredSingle;
   }
-  if (node->typeinfo->expand_in_mf_network) {
-    /* Wow, that's hacky. Don't use vertical bar for function nodes. */
-    return false;
-  }
-  if (ELEM(node->type, NODE_REROUTE, NODE_GROUP, NODE_GROUP_OUTPUT)) {
-    return false;
-  }
-
-  return true;
+  return SocketSingleState::CurrentlySingle;
 }
 
 static const float virtual_node_socket_outline_color[4] = {0.5, 0.5, 0.5, 1.0};
@@ -1062,7 +1053,8 @@ static void node_socket_draw_nested(const bContext *C,
 
   bNode *node = (bNode *)node_ptr->data;
 
-  if (!use_special_non_field_socket_drawing(ntree, node, sock)) {
+  const SocketSingleState single_state = get_socket_single_state(ntree, node, sock);
+  if (ELEM(single_state, SocketSingleState::MaybeField, SocketSingleState::CurrentlySingle)) {
     node_socket_draw(sock,
                      color,
                      outline_color,
@@ -1445,6 +1437,7 @@ void node_draw_sockets(const View2D *v2d,
     node_socket_color_get((bContext *)C, ntree, &node_ptr, socket, color);
     node_socket_outline_color_get(selected, socket->type, outline_color);
 
+    const SocketSingleState single_state = get_socket_single_state(ntree, node, socket);
     if (socket->flag & SOCK_MULTI_INPUT) {
       const bool is_node_hidden = (node->flag & NODE_HIDDEN);
       const float width = NODE_SOCKSIZE;
@@ -1453,7 +1446,27 @@ void node_draw_sockets(const View2D *v2d,
       node_socket_draw_rounded_rectangle(
           color, outline_color, width, height, socket->locx, socket->locy, 1.0f);
     }
-    else if (use_special_non_field_socket_drawing(ntree, node, socket)) {
+    else if (ELEM(single_state,
+                  SocketSingleState::CurrentlySingle,
+                  SocketSingleState::RequiredSingle)) {
+      node_socket_draw_rounded_rectangle(color,
+                                         outline_color,
+                                         NODE_SOCKSIZE * 0.6f,
+                                         NODE_SOCKSIZE * 1.3,
+                                         socket->locx - 0.8f,
+                                         socket->locy,
+                                         0.75f);
+    }
+  }
+
+  LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
+    const SocketSingleState single_state = get_socket_single_state(ntree, node, socket);
+    if (ELEM(
+            single_state, SocketSingleState::CurrentlySingle, SocketSingleState::RequiredSingle)) {
+      float color[4];
+      float outline_color[4];
+      node_socket_color_get((bContext *)C, ntree, &node_ptr, socket, color);
+      node_socket_outline_color_get(selected, socket->type, outline_color);
       node_socket_draw_rounded_rectangle(color,
                                          outline_color,
                                          NODE_SOCKSIZE * 0.6f,
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index aa3322541a2..dc463eb4a35 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -215,11 +215,8 @@ typedef enum eNodeSocketFlag {
    * type is obvious and the name takes up too much space.
    */
   SOCK_HIDE_LABEL = (1 << 12),
-  /**
-   * For geometry nodes, the result is not a single value, but evaluated as a callback and
-   * potentially many different values.
-   */
-  SOCK_FIELD = (1 << 13),
+  SOCK_ALWAYS_SINGLE = (1 << 13),
+  SOCK_ALWAYS_FIELD = (1 << 14),
 } eNodeSocketFlag;
 
 /* TODO: Limit data in bNode to what we want to see saved. */
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
index 7a47a3524b2..74fdd88a9c8 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@ -22,10 +22,10 @@
 static bNodeSocketTemplate geo_node_attribute_fill_in[] = {
     {SOCK_GEOMETRY, N_("Geometry")},
     {SOCK_STRING, N_("Attribute")},
-    {SOCK_VECTOR, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_RGBA, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_BOOLEAN, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
+    {SOCK_VECTOR, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_RGBA, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_BOOLEAN, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
     {SOCK_INT, N_("Value"), 0, 0, 0, 0, -10000000.0f, 10000000.0f},
     {-1, ""},
 };
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_freeze.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_freeze.cc
index 8404f884373..644edcb5935 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_freeze.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_freeze.cc
@@ -23,21 +23,21 @@
 
 static bNodeSocketTemplate geo_node_attribute_freeze_in[] = {
     {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_VECTOR, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_RGBA, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_BOOLEAN, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE, SOCK_FIELD},
-    {SOCK_INT, N_("Value"), 0, 0, 0, 0, -10000000.0f, 10000000.0f, PROP_NONE, SOCK_FIELD},
+    {SOCK_VECTOR, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_RGBA, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_BOOLEAN, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
+    {SOCK_INT, N_("Value"), 0, 0, 0, 0, -10000000.0f, 10000000.0f, PROP_NONE},
     {-1, ""},
 };
 
 static bNodeSocketTemplate geo_node_attribute_freeze_out[] = {
     {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_VECTOR, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_FLOAT, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_RGBA, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_BOOLEAN, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_INT, N_("Attribute"), 0, 0, 0, 0, -10000000.0f, 10000000.0f},
+    {SOCK_VECTOR, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, SOCK_ALWAYS_FIELD},
+    {SOCK_FLOAT, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, SOCK_ALWAYS_FIELD},
+    {SOCK_RGBA, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, SOCK_ALWAYS_FIELD},
+    {SOCK_BOOLEAN, N_("Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, SOCK_ALWAYS_FIELD},
+    {SOCK_INT, N_("Attribute"), 0, 0, 0, 0, -10000000.0f, 10000000.0f, SOCK_ALWAYS_FIELD},
     {-1, ""},
 };
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc
index d105a9ff886..96b0b5804fd 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc
@@ -17,7 +17,7 @@
 #include "node_geometry_util.hh"
 
 static bNodeSocketTemplate geo_node_curve_parameter_out[] = {
-    {SOCK_FLOAT, N_("Parameter")},
+    {SOCK_FLOAT, N_("Parameter"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_ALWAYS_FIELD},
     {-1, ""},
 };
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc
index 7583b9ec82d..d5171f99695 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc
@@ -23,7 +23,7 @@
 
 static bNodeSocketTemplate geo_node_curve_set_handles_in[] = {
     {SOCK_GEOMETRY, N_("Curve")},
-    {SOCK_BOOLEAN, N_("Selection"), 1, 0, 0, 0, 0, 0, PROP_NONE, SOCK_HIDE_VALUE | SOCK_FIELD},
+    {SOCK_BOOLEAN, N_("Selection"), 1, 0, 0, 0, 0, 0, PROP_NONE, SOCK_HIDE_VALUE},
     {-1, ""},
 };
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
index e4ae5fc21e6..7d432f5bb24 100644
--- a/source/blender/nodes/geome

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list