[Bf-blender-cvs] [c37de30fdbf] temp-attribute-processor: add initial info for inputs and outputs

Jacques Lucke noreply at git.blender.org
Thu May 27 12:51:41 CEST 2021


Commit: c37de30fdbfd86a8e9450c28342cb09e3658e560
Author: Jacques Lucke
Date:   Mon May 24 17:53:58 2021 +0200
Branches: temp-attribute-processor
https://developer.blender.org/rBc37de30fdbfd86a8e9450c28342cb09e3658e560

add initial info for inputs and outputs

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

M	source/blender/blenkernel/intern/node.cc
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc

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

diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index cb0e957b69c..dbe0874ec2e 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -579,6 +579,18 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
         }
         BLO_write_struct_by_name(writer, node->typeinfo->storagename, storage);
       }
+      else if (node->type == GEO_NODE_ATTRIBUTE_PROCESSOR) {
+        NodeGeometryAttributeProcessor *storage = (NodeGeometryAttributeProcessor *)node->storage;
+        BLO_write_struct(writer, NodeGeometryAttributeProcessor, storage);
+        BLO_write_struct_list(writer, AttributeProcessorInput, &storage->inputs);
+        BLO_write_struct_list(writer, AttributeProcessorOutput, &storage->outputs);
+        LISTBASE_FOREACH (AttributeProcessorInput *, input, &storage->inputs) {
+          BLO_write_string(writer, input->identifier);
+        }
+        LISTBASE_FOREACH (AttributeProcessorOutput *, output, &storage->outputs) {
+          BLO_write_string(writer, output->identifier);
+        }
+      }
       else if (node->typeinfo != &NodeTypeUndefined) {
         BLO_write_struct_by_name(writer, node->typeinfo->storagename, node->storage);
       }
@@ -760,6 +772,19 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
           BLO_read_data_address(reader, &storage->string);
           break;
         }
+        case GEO_NODE_ATTRIBUTE_PROCESSOR: {
+          NodeGeometryAttributeProcessor *storage = (NodeGeometryAttributeProcessor *)
+                                                        node->storage;
+          BLO_read_list(reader, &storage->inputs);
+          BLO_read_list(reader, &storage->outputs);
+          LISTBASE_FOREACH (AttributeProcessorInput *, input, &storage->inputs) {
+            BLO_read_data_address(reader, &input->identifier);
+          }
+          LISTBASE_FOREACH (AttributeProcessorOutput *, output, &storage->outputs) {
+            BLO_read_data_address(reader, &output->identifier);
+          }
+          break;
+        }
         default:
           break;
       }
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 03eb26efeb2..418375830f1 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1358,9 +1358,34 @@ typedef struct NodeGeometryAttributeTransfer {
   uint8_t mapping;
 } NodeGeometryAttributeTransfer;
 
+typedef struct AttributeProcessorInput {
+  struct AttributeProcessorInput *next, *prev;
+
+  char *identifier;
+
+  /* GeometryNodeAttributeProcessorInputMode. */
+  uint8_t input_mode;
+  char _pad[7];
+} AttributeProcessorInput;
+
+typedef struct AttributeProcessorOutput {
+  struct AttributeProcessorOutput *next, *prev;
+
+  char *identifier;
+
+  /* GeometryNodeAttributeProcessorOutputMode. */
+  uint8_t output_mode;
+  char _pad[7];
+} AttributeProcessorOutput;
+
 typedef struct NodeGeometryAttributeProcessor {
   /* AttributeDomain. */
   int8_t domain;
+  char _pad[7];
+  /* List of AttributeProcessorInput. */
+  ListBase inputs;
+  /* List of AttributeProcessorOutput. */
+  ListBase outputs;
 } NodeGeometryAttributeProcessor;
 
 /* script node mode */
@@ -1875,6 +1900,16 @@ typedef enum GeometryNodeAttributeTransferMapMode {
   GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST = 1,
 } GeometryNodeAttributeTransferMapMode;
 
+typedef enum GeometryNodeAttributeProcessorInputMode {
+  GEO_NODE_ATTRIBUTE_PROCESSOR_INPUT_MODE_VALUE = 0,
+  GEO_NODE_ATTRIBUTE_PROCESSOR_INPUT_MODE_ATTRIBUTE = 1,
+} GeometryNodeAttributeProcessorInputMode;
+
+typedef enum GeometryNodeAttributeProcessorOutputMode {
+  GEO_NODE_ATTRIBUTE_PROCESSOR_OUTPUT_MODE_GIVEN_NAME = 0,
+  GEO_NODE_ATTRIBUTE_PROCESSOR_OUTPUT_MODE_CUSTOM_NAME = 1,
+} GeometryNodeAttributeProcessorOutputMode;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
index 51ec5f32da5..8ac747a2de8 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
@@ -85,6 +85,55 @@ static void geo_node_attribute_processor_group_update(bNodeTree *ntree, bNode *n
   }
 }
 
+static void geo_node_attribute_processor_storage_free(bNode *node)
+{
+  NodeGeometryAttributeProcessor *storage = (NodeGeometryAttributeProcessor *)node->storage;
+
+  LISTBASE_FOREACH_MUTABLE (AttributeProcessorInput *, input, &storage->inputs) {
+    MEM_freeN(input->identifier);
+    MEM_freeN(input);
+  }
+  BLI_listbase_clear(&storage->inputs);
+  LISTBASE_FOREACH_MUTABLE (AttributeProcessorOutput *, output, &storage->outputs) {
+    MEM_freeN(output->identifier);
+    MEM_freeN(output);
+  }
+  BLI_listbase_clear(&storage->outputs);
+  MEM_freeN(storage);
+}
+
+static void geo_node_attribute_processor_storage_copy(bNodeTree *UNUSED(dest_ntree),
+                                                      bNode *dst_node,
+                                                      const bNode *src_node)
+{
+  const NodeGeometryAttributeProcessor *src_storage = (const NodeGeometryAttributeProcessor *)
+                                                          src_node->storage;
+  NodeGeometryAttributeProcessor *dst_storage = (NodeGeometryAttributeProcessor *)MEM_callocN(
+      sizeof(NodeGeometryAttributeProcessor), __func__);
+
+  *dst_storage = *src_storage;
+
+  BLI_listbase_clear(&dst_storage->inputs);
+  LISTBASE_FOREACH (const AttributeProcessorInput *, src_input, &src_storage->inputs) {
+    AttributeProcessorInput *dst_input = (AttributeProcessorInput *)MEM_callocN(
+        sizeof(AttributeProcessorInput), __func__);
+    *dst_input = *src_input;
+    dst_input->identifier = BLI_strdup(src_input->identifier);
+    BLI_addtail(&dst_storage->inputs, dst_input);
+  }
+
+  BLI_listbase_clear(&dst_storage->outputs);
+  LISTBASE_FOREACH (const AttributeProcessorOutput *, src_output, &src_storage->outputs) {
+    AttributeProcessorOutput *dst_output = (AttributeProcessorOutput *)MEM_callocN(
+        sizeof(AttributeProcessorOutput), __func__);
+    *dst_output = *src_output;
+    dst_output->identifier = BLI_strdup(src_output->identifier);
+    BLI_addtail(&dst_storage->outputs, dst_output);
+  }
+
+  dst_node->storage = dst_storage;
+}
+
 static void geo_node_attribute_processor_exec(GeoNodeExecParams params)
 {
   GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
@@ -103,8 +152,8 @@ void register_node_type_geo_attribute_processor()
   node_type_init(&ntype, geo_node_attribute_processor_init);
   node_type_storage(&ntype,
                     "NodeGeometryAttributeProcessor",
-                    node_free_standard_storage,
-                    node_copy_standard_storage);
+                    blender::nodes::geo_node_attribute_processor_storage_free,
+                    blender::nodes::geo_node_attribute_processor_storage_copy);
   node_type_group_update(&ntype, blender::nodes::geo_node_attribute_processor_group_update);
   ntype.geometry_node_execute = blender::nodes::geo_node_attribute_processor_exec;
   ntype.draw_buttons = geo_node_attribute_processor_layout;



More information about the Bf-blender-cvs mailing list