[Bf-blender-cvs] [d5dc3501b55] temp-geometry-nodes-expandable-geometry-socket-prototype: show warning when expander output is not available

Jacques Lucke noreply at git.blender.org
Thu Aug 5 17:27:07 CEST 2021


Commit: d5dc3501b550dd1ebf90e290ac80b30c82797b54
Author: Jacques Lucke
Date:   Thu Aug 5 16:14:51 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rBd5dc3501b550dd1ebf90e290ac80b30c82797b54

show warning when expander output is not available

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

M	source/blender/editors/space_node/node_edit.cc
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc

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

diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index 8a22199986a..dd053367eff 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -3108,6 +3108,7 @@ static int node_geometry_expander_output_add_exec(bContext *C, wmOperator *op)
       sizeof(GeometryExpanderOutput), __func__);
   *expander_output = attribute;
   STRNCPY(expander_output->socket_identifier, identifier.c_str());
+  expander_output->is_outdated = false;
 
   BLI_addtail(&storage->outputs, expander_output);
 
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 671e6da4e56..62a09719904 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1436,7 +1436,8 @@ typedef struct GeometryExpanderOutput {
 
   /* eGeometryExpanderOutputType. */
   int type;
-  char _pad[4];
+  uint8_t is_outdated;
+  char _pad[3];
 
   /* Identifier of the corresponding socket in the geometry expander. */
   char socket_identifier[64];
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 81e11e93fcd..310f04e54cc 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2443,9 +2443,6 @@ static void rna_Node_select_set(PointerRNA *ptr, bool value)
   nodeSetSelected(node, value);
 }
 
-void nodeGeometryExpanderUpdateOutputNameCache(GeometryExpanderOutput *expander_output,
-                                               const bNodeTree *ntree);
-
 static void rna_Node_name_set(PointerRNA *ptr, const char *value)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
@@ -2479,6 +2476,36 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
   BKE_animdata_fix_paths_rename_all(NULL, "nodes", oldname, node->name);
 }
 
+void rna_NodeSocket_add_to_geometry_set(PointerRNA *ptr, const bool value)
+{
+  bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
+  bNodeSocket *socket = (bNodeSocket *)ptr->data;
+  bNode *node;
+  nodeFindNode(ntree, socket, &node, NULL);
+  if (value) {
+    socket->flag |= SOCK_ADD_ATTRIBUTE_TO_GEOMETRY;
+  }
+  else {
+    socket->flag &= ~SOCK_ADD_ATTRIBUTE_TO_GEOMETRY;
+  }
+
+  LISTBASE_FOREACH (bNode *, other_node, &ntree->nodes) {
+    if (other_node->type != GEO_NODE_GEOMETRY_EXPANDER) {
+      continue;
+    }
+    NodeGeometryGeometryExpander *storage = (NodeGeometryGeometryExpander *)other_node->storage;
+    LISTBASE_FOREACH (GeometryExpanderOutput *, expander_output, &storage->outputs) {
+      if (expander_output->type != GEOMETRY_EXPANDER_OUTPUT_TYPE_LOCAL) {
+        continue;
+      }
+      if (STREQ(expander_output->local_node_name, node->name) &&
+          STREQ(expander_output->local_socket_identifier, socket->identifier)) {
+        expander_output->is_outdated = !value;
+      }
+    }
+  }
+}
+
 static bNodeSocket *rna_Node_inputs_new(ID *id,
                                         bNode *node,
                                         Main *bmain,
@@ -10404,6 +10431,7 @@ static void rna_def_node_socket(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "add_to_geometry", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_ADD_ATTRIBUTE_TO_GEOMETRY);
+  RNA_def_property_boolean_funcs(prop, NULL, "rna_NodeSocket_add_to_geometry_set");
   RNA_def_property_ui_text(
       prop,
       "Add to Geometry",
diff --git a/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc b/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
index 54fc1b46652..647dcf6520a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
@@ -63,7 +63,12 @@ static bool geo_node_geometry_expander_socket_layout(const bContext *UNUSED(C),
   uiLayout *row = uiLayoutRow(layout, true);
   uiLayout *split = uiLayoutSplit(row, 0.7, false);
   uiItemL(split, expander_output->display_name_cache, ICON_NONE);
-  uiItemR(split, &expander_output_ptr, "domain", 0, "", ICON_NONE);
+  if (expander_output->is_outdated) {
+    uiItemL(split, "", ICON_ERROR);
+  }
+  else {
+    uiItemR(split, &expander_output_ptr, "domain", 0, "", ICON_NONE);
+  }
 
   return true;
 }



More information about the Bf-blender-cvs mailing list