Commit: 3f1027567d3442b831ec165a07b5c3d15936b893 Author: Hans Goudey Date: Wed Dec 14 14:34:20 2022 -0600 Branches: geometry-nodes-simulation https://developer.blender.org/rB3f1027567d3442b831ec165a07b5c3d15936b893
Add initial simulation state items array to output node =================================================================== M source/blender/makesdna/DNA_node_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/NOD_static_types.h M source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc =================================================================== diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 866f8f23279..ba2d63644ef 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -1577,12 +1577,24 @@ 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; + int _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 ee232ecd45d..be36cdcd6ad 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -9695,8 +9695,18 @@ static void def_geo_set_curve_normal(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } -static void def_geo_simulation_input(StructRNA *srna) +static void rna_def_simulation_state_item(BlenderRNA *brna) { + 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) @@ -9708,6 +9718,11 @@ 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) @@ -12983,6 +12998,7 @@ 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_static_types.h b/source/blender/nodes/NOD_static_types.h index f10f366f3a3..015642de392 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, def_geo_simulation_input, "SIMULATION_INPUT", SimulationInput, "Simulation Input", "") +DefNode(GeometryNode, GEO_NODE_SIMULATION_INPUT, 0, "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_output.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc index d1bdd9a0264..7bc9af24085 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc @@ -26,10 +26,29 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometrySimulationOutput *data = MEM_cnew<NodeGeometrySimulationOutput>(__func__); + data->state_items = MEM_cnew_array<SimulationStateItem>(1, __func__); + data->state_items[0].name = BLI_strdup(DATA_("Geometry")); + data->state_items[0].data_type = SOCK_GEOMETRY; + data->state_items_num = 1; data->use_persistent_cache = false; node->storage = data; } +static void node_free_storage(bNode *node) +{ + NodeGeometrySimulationOutput &storage = node_storage(*node); + MEM_SAFE_FREE(storage.state_items); +} + +void node_copy_storage(bNodeTree * /*dest_ntree*/, bNode *dst_node, const bNode *src_node) +{ + const NodeGeometrySimulationOutput &src = node_storage(*src_node); + NodeGeometrySimulationOutput &dst = node_storage(*dst_node); + MEM_SAFE_FREE(dst.state_items); + dst.state_items = MEM_cnew_array<SimulationStateItem>(src.state_items_num, __func__); + dst.state_items_num = src.state_items_num; +} + static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); @@ -90,9 +109,9 @@ void register_node_type_geo_simulation_output() ntype.declare = file_ns::node_declare; node_type_storage(&ntype, "NodeGeometrySimulationOutput", - node_free_standard_storage, - node_copy_standard_storage); + file_ns::node_free_storage, + file_ns::node_copy_storage); ntype.geometry_node_execute_supports_laziness = true; - // ntype.declaration_is_dynamic = true; + ntype.declaration_is_dynamic = true; nodeRegisterType(&ntype); } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs