[Bf-blender-cvs] [508fd044b44] geometry-nodes-simulation: Revert "Fix simulation"

Hans Goudey noreply at git.blender.org
Mon Dec 19 19:05:26 CET 2022


Commit: 508fd044b44ab234fbdb715a757f8230ca51aa1f
Author: Hans Goudey
Date:   Mon Dec 19 12:03:42 2022 -0600
Branches: geometry-nodes-simulation
https://developer.blender.org/rB508fd044b44ab234fbdb715a757f8230ca51aa1f

Revert "Fix simulation"

This reverts commit 468f43c7a6e96ba55d72564a8f11d60fc8984d33.

Revert "Add initial dynamic declarations"

This reverts commit 50a2c77c4ebe0edd048715c94bde5bbe6f106617.

Revert "Add initial simulation state items array to output node"

This reverts commit 3f1027567d3442b831ec165a07b5c3d15936b893.

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

M	source/blender/blenkernel/intern/node.cc
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/NOD_node_declaration.hh
M	source/blender/nodes/NOD_static_types.h
M	source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
M	source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc
M	source/blender/nodes/intern/node_declaration.cc

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

diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 3e350fbb80a..d55e57bb000 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -1124,12 +1124,12 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node)
   BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
   nodeUniqueName(ntree, node);
 
+  node_add_sockets_from_type(ntree, node, ntype);
+
   if (ntype->initfunc != nullptr) {
     ntype->initfunc(ntree, node);
   }
 
-  node_add_sockets_from_type(ntree, node, ntype);
-
   if (ntree->typeinfo && ntree->typeinfo->node_add_init) {
     ntree->typeinfo->node_add_init(ntree, node);
   }
@@ -3620,7 +3620,7 @@ bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree * /*ntree*/, bNode *node)
   }
   if (node->typeinfo->declaration_is_dynamic) {
     node->runtime->declaration = new blender::nodes::NodeDeclaration();
-    blender::nodes::build_node_declaration_dynamic(*node, *node->runtime->declaration);
+    blender::nodes::build_node_declaration(*node->typeinfo, *node->runtime->declaration);
   }
   else {
     /* Declaration should have been created in #nodeRegisterType. */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index a5e771f5319..2294d4c3960 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1579,24 +1579,12 @@ typedef struct NodeGeometryUVUnwrap {
   uint8_t method;
 } NodeGeometryUVUnwrap;
 
-typedef struct SimulationStateItem {
-  char *name;
-  /* TODO: Use a different enum instead to support Byte colors, geometry, etc. */
-  /* eNodeSocketDatatype */
-  int8_t data_type;
-  char _pad[7];
-} SimulationStateItem;
-
 typedef struct NodeGeometrySimulationInput {
   int32_t output_node_id;
 } NodeGeometrySimulationInput;
 
 typedef struct NodeGeometrySimulationOutput {
-  SimulationStateItem *state_items;
-  int state_items_num;
-
   int8_t use_persistent_cache;
-  char _pad[3];
 } NodeGeometrySimulationOutput;
 
 typedef struct NodeGeometryDistributePointsInVolume {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index be36cdcd6ad..ee232ecd45d 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9695,18 +9695,8 @@ static void def_geo_set_curve_normal(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
-static void rna_def_simulation_state_item(BlenderRNA *brna)
+static void def_geo_simulation_input(StructRNA *srna)
 {
-  StructRNA *srna = RNA_def_struct(brna, "SimulationStateItem", NULL);
-  RNA_def_struct_ui_text(srna, "Simulation Sate Item", "");
-  RNA_def_struct_sdna(srna, "SimulationStateItem");
-
-  PropertyRNA *prop;
-
-  // prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
-  // RNA_def_property_ui_text(prop, "Name", "");
-  // RNA_def_struct_name_property(srna, prop);
-  // RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
 }
 
 static void def_geo_simulation_output(StructRNA *srna)
@@ -9718,11 +9708,6 @@ static void def_geo_simulation_output(StructRNA *srna)
   prop = RNA_def_property(srna, "use_persistent_cache", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_ui_text(prop, "Persistent Cache", "");
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
-  prop = RNA_def_property(srna, "state_items", PROP_COLLECTION, PROP_NONE);
-  RNA_def_property_collection_sdna(prop, NULL, "state_items", "state_items_num");
-  RNA_def_property_struct_type(prop, "SimulationStateItem");
-  RNA_def_property_ui_text(prop, "Inputs", "");
 }
 
 static void def_geo_curve_handle_type_selection(StructRNA *srna)
@@ -12998,7 +12983,6 @@ void RNA_def_nodetree(BlenderRNA *brna)
   rna_def_shader_node(brna);
   rna_def_compositor_node(brna);
   rna_def_texture_node(brna);
-  rna_def_simulation_state_item(brna);
   rna_def_geometry_node(brna);
   rna_def_function_node(brna);
 
diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh
index c28f7525245..975cc96131c 100644
--- a/source/blender/nodes/NOD_node_declaration.hh
+++ b/source/blender/nodes/NOD_node_declaration.hh
@@ -325,19 +325,11 @@ class NodeDeclaration {
 class NodeDeclarationBuilder {
  private:
   NodeDeclaration &declaration_;
-  const bNode *node_;
   Vector<std::unique_ptr<BaseSocketDeclarationBuilder>> builders_;
   bool is_function_node_ = false;
 
  public:
   NodeDeclarationBuilder(NodeDeclaration &declaration);
-  NodeDeclarationBuilder(const bNode &node, NodeDeclaration &declaration);
-
-  /** Only valid for nodes with dynamic declarations. */
-  const bNode &node()
-  {
-    return *node_;
-  }
 
   /**
    * All inputs support fields, and all outputs are fields if any of the inputs is a field.
@@ -369,7 +361,6 @@ void index(const bNode &node, void *r_value);
 void id_or_index(const bNode &node, void *r_value);
 }  // namespace implicit_field_inputs
 
-void build_node_declaration_dynamic(const bNode &node, NodeDeclaration &r_declaration);
 void build_node_declaration(const bNodeType &typeinfo, NodeDeclaration &r_declaration);
 
 /* -------------------------------------------------------------------- */
@@ -525,12 +516,6 @@ inline NodeDeclarationBuilder::NodeDeclarationBuilder(NodeDeclaration &declarati
 {
 }
 
-inline NodeDeclarationBuilder::NodeDeclarationBuilder(const bNode &node,
-                                                      NodeDeclaration &declaration)
-    : declaration_(declaration), node_(&node)
-{
-}
-
 template<typename DeclType>
 inline typename DeclType::Builder &NodeDeclarationBuilder::add_input(StringRef name,
                                                                      StringRef identifier)
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 015642de392..f10f366f3a3 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -412,7 +412,7 @@ DefNode(GeometryNode, GEO_NODE_SET_POSITION, 0, "SET_POSITION", SetPosition, "Se
 DefNode(GeometryNode, GEO_NODE_SET_SHADE_SMOOTH, 0, "SET_SHADE_SMOOTH", SetShadeSmooth, "Set Shade Smooth", "Control the smoothness of mesh normals around each face by changing the \"shade smooth\" attribute")
 DefNode(GeometryNode, GEO_NODE_SET_SPLINE_CYCLIC, 0, "SET_SPLINE_CYCLIC", SetSplineCyclic, "Set Spline Cyclic", "Control whether each spline loops back on itself by changing the \"cyclic\" attribute")
 DefNode(GeometryNode, GEO_NODE_SET_SPLINE_RESOLUTION, 0, "SET_SPLINE_RESOLUTION", SetSplineResolution, "Set Spline Resolution", "Control how many evaluated points should be generated on every curve segment")
-DefNode(GeometryNode, GEO_NODE_SIMULATION_INPUT, 0, "SIMULATION_INPUT", SimulationInput, "Simulation Input", "")
+DefNode(GeometryNode, GEO_NODE_SIMULATION_INPUT, def_geo_simulation_input, "SIMULATION_INPUT", SimulationInput, "Simulation Input", "")
 DefNode(GeometryNode, GEO_NODE_SIMULATION_OUTPUT, def_geo_simulation_output, "SIMULATION_OUTPUT", SimulationOutput, "Simulation Output", "")
 DefNode(GeometryNode, GEO_NODE_SPLIT_EDGES, 0, "SPLIT_EDGES", SplitEdges, "Split Edges", "Duplicate mesh edges and break connections with the surrounding faces")
 DefNode(GeometryNode, GEO_NODE_STORE_NAMED_ATTRIBUTE, def_geo_store_named_attribute, "STORE_NAMED_ATTRIBUTE", StoreNamedAttribute, "Store Named Attribute", "Store the result of a field on a geometry as an attribute with the specified name")
diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
index 4a785d9fae8..5c2ef821c8a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
@@ -17,60 +17,25 @@ NODE_STORAGE_FUNCS(NodeGeometrySimulationInput);
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
-  b.add_output<decl::Float>(N_("Delta Time"));
-
-  const bNode &node = b.node();
-  const NodeGeometrySimulationInput &storage = node_storage(node);
-  const int32_t sim_output_node_id = storage.output_node_id;
-  /* TODO: Add node tree and ndoe as arguments to new dynamic declaration function. */
-  node.owner_tree().ensure_topology_cache();
-  const bNode *sim_output_node = node.owner_tree().node_by_id(sim_output_node_id);
-  if (!sim_output_node) {
-    return;
-  }
-  const NodeGeometrySimulationOutput &output_storage =
-      *static_cast<const NodeGeometrySimulationOutput *>(sim_output_node->storage);
-  const Span<SimulationStateItem> items(output_storage.state_items,
-                                        output_storage.state_items_num);
-
-  for (const int i : items.index_range()) {
-    const SimulationStateItem &item = items[i];
-    switch (item.data_type) {
-      case SOCK_FLOAT:
-        b.add_input<decl::Float>(item.name).supports_field();
-        b.add_output<decl::Float>(item.name).dependent_field({i});
-        break;
-      case SOCK_VECTOR:
-        b.add_input<decl::Vector>(item.name).supports_field();
-        b.add_output<decl::Vector>(item.name).dependent_field({i});
-        break;
-      case SOCK_RGBA:
-        b.add_input<decl::Color>(item.name).supports_field();
-        b.add_output<decl::Color>(item.name).dependent_field({i});
-        break;
-      case SOCK_BOOLEAN:
-        b.add_input<decl::Bool>(item.name).supports_field();
-        b.add_output<decl::Bool>(item.name).dependent_field({i});
-        break;
-      case SOCK_INT:
-        b.add_input<decl::Int>(item.name).supports_field();
-        b.add_output<decl::Int>(item.name).dependent_field({i});
-        break;
-      case SOCK_STRING:
-        b.add_input<decl::String>(item.name);
-        b.add_output<decl::String>(item.name);
-        break;
-      case SOCK_GEOMETRY:
-        b.add_input<decl::Geometry>(item.name);
-        b.add_output<decl::Geometry>(item.name);
-        break;
-    }
-  }
-
+  b.add_input<decl::Geometry>(N_("Geometry"));
   b.add_input<decl::Extend>("", N_("__extend__"));
+
+  b.add_output<decl::F

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list