WIP: Closures and deferred evaluation for geometry nodes #107842

Draft
Lukas Tönne wants to merge 35 commits from LukasTonne/blender:geometry-nodes-closures into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
16 changed files with 199 additions and 174 deletions
Showing only changes of commit 1deb83b208 - Show all commits

View File

@ -202,7 +202,7 @@ class NODE_OT_tree_path_parent(Operator):
class NodeFunctionSignatureOperator():
# Dictionary of node types with methods to get the signature
signature_nodes = {
'FunctionNodeEvaluate' : lambda node: node.signature,
'GeometryNodeEvaluateFunction' : lambda node: node.signature,
}
param_type: EnumProperty(

View File

@ -623,8 +623,8 @@ class NODE_MT_category_GEO_FUNCTION(Menu):
def draw(self, context):
layout = self.layout
node_add_menu.add_node_type(layout, "FunctionNodeBind")
node_add_menu.add_node_type(layout, "FunctionNodeEvaluate")
node_add_menu.add_node_type(layout, "GeometryNodeBindFunction")
node_add_menu.add_node_type(layout, "GeometryNodeEvaluateFunction")
class NODE_MT_category_GEO_LAYOUT(Menu):

View File

@ -974,7 +974,7 @@ class FunctionSignaturePanel():
# Dictionary of node types with methods to get the signature
signature_nodes = {
'FunctionNodeEvaluate' : lambda node: node.signature,
'GeometryNodeEvaluateFunction' : lambda node: node.signature,
}
@classmethod

View File

@ -1635,6 +1635,9 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
#define GEO_NODE_MEAN_FILTER_SDF_VOLUME 1197
#define GEO_NODE_OFFSET_SDF_VOLUME 1198
#define GEO_NODE_INDEX_OF_NEAREST 1199
/* 1199 is last valid geometry node type ID, continuing at 11000. */
#define GEO_NODE_BIND_FUNCTION 11000
#define GEO_NODE_EVALUATE_FUNCTION 11001
/** \} */
@ -1661,8 +1664,6 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
#define FN_NODE_INPUT_INT 1220
#define FN_NODE_SEPARATE_COLOR 1221
#define FN_NODE_COMBINE_COLOR 1222
#define FN_NODE_BIND 1223
#define FN_NODE_EVALUATE 1224
/** \} */

View File

@ -223,8 +223,8 @@ bool nodeFunctionParameterFindNode(bNodeTree *ntree,
bNodeFunctionSignature **r_sig)
{
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == FN_NODE_EVALUATE) {
NodeFunctionEvaluate *data = static_cast<NodeFunctionEvaluate *>(node->storage);
if (node->type == GEO_NODE_EVALUATE_FUNCTION) {
NodeGeometryEvaluateFunction *data = static_cast<NodeGeometryEvaluateFunction *>(node->storage);
if (nodeFunctionSignatureContainsParameter(&data->signature, param, nullptr)) {
if (r_node) {
*r_node = node;
@ -271,8 +271,8 @@ bool nodeFunctionSignatureFindNode(bNodeTree *ntree,
bNode **r_node)
{
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == FN_NODE_EVALUATE) {
NodeFunctionEvaluate *data = static_cast<NodeFunctionEvaluate *>(node->storage);
if (node->type == GEO_NODE_EVALUATE_FUNCTION) {
NodeGeometryEvaluateFunction *data = static_cast<NodeGeometryEvaluateFunction *>(node->storage);
if (sig == &data->signature) {
if (r_node) {
*r_node = node;
@ -970,8 +970,8 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
}
BLO_write_struct_by_name(writer, node->typeinfo->storagename, storage);
}
else if (node->type == FN_NODE_EVALUATE) {
NodeFunctionEvaluate *storage = (NodeFunctionEvaluate *)node->storage;
else if (node->type == GEO_NODE_EVALUATE_FUNCTION) {
NodeGeometryEvaluateFunction *storage = (NodeGeometryEvaluateFunction *)node->storage;
BLO_write_struct_by_name(writer, node->typeinfo->storagename, storage);
write_node_function_signature(writer, &storage->signature);
}
@ -1186,8 +1186,8 @@ void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree)
BLO_read_data_address(reader, &storage->string);
break;
}
case FN_NODE_EVALUATE: {
NodeFunctionEvaluate *storage = (NodeFunctionEvaluate *)node->storage;
case GEO_NODE_EVALUATE_FUNCTION: {
NodeGeometryEvaluateFunction *storage = (NodeGeometryEvaluateFunction *)node->storage;
direct_link_node_function_signature(reader, &storage->signature);
break;
}

View File

@ -1665,10 +1665,10 @@ typedef struct bNodeFunctionSignature {
#endif
} bNodeFunctionSignature;
typedef struct NodeFunctionEvaluate {
typedef struct NodeGeometryEvaluateFunction {
/* Expected signature of the function. */
bNodeFunctionSignature signature;
} NodeFunctionEvaluate;
} NodeGeometryEvaluateFunction;
/* script node mode */
#define NODE_SCRIPT_INTERNAL 0

View File

@ -5449,7 +5449,7 @@ static void def_fn_combsep_color(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
static void def_fn_bind(StructRNA *srna)
static void def_geo_bind_function(StructRNA *srna)
{
PropertyRNA *prop;
@ -5464,140 +5464,11 @@ static void def_fn_bind(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNodeBind_update");
}
static void rna_def_node_function_parameter(BlenderRNA *brna)
static void def_geo_evaluate_function(StructRNA *srna)
{
PropertyRNA *prop;
StructRNA *srna = RNA_def_struct(brna, "NodeFunctionParameter", NULL);
RNA_def_struct_ui_text(srna, "Node Function Parameter", "Input or output declaration of a node function");
RNA_def_struct_sdna(srna, "bNodeFunctionParameter");
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NodeFunctionParameter_name_set");
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeFunctionParameter_update");
prop = RNA_def_property(srna, "socket_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, node_socket_data_type_items);
RNA_def_property_ui_text(prop, "Socket Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeFunctionParameter_update");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_float_funcs(prop, "rna_NodeFunctionParameter_color_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Color", "Socket color");
}
static void rna_def_node_function_signature_api(BlenderRNA *brna, PropertyRNA *cprop, eNodeFunctionParameterType param_type)
{
StructRNA *srna;
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
const char *structtype = (param_type == NODE_FUNC_PARAM_IN ? "NodeFunctionSignatureInputs" :
"NodeFunctionSignatureOutputs");
const char *uiname = (param_type == NODE_FUNC_PARAM_IN ? "Node Function Signature Inputs" :
"Node Function Signature Outputs");
const char *active_index_sdna = (param_type == NODE_FUNC_PARAM_IN ? "active_input" :
"active_output");
const char *active_param_get = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_active_input_get" :
"rna_NodeFunctionSignature_active_output_get");
const char *active_param_set = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_active_input_set" :
"rna_NodeFunctionSignature_active_output_set");
const char *newfunc = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_inputs_new" :
"rna_NodeFunctionSignature_outputs_new");
const char *removefunc = "rna_NodeFunctionSignature_params_remove";
const char *clearfunc = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_inputs_clear" :
"rna_NodeFunctionSignature_outputs_clear");
const char *movefunc = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_inputs_move" :
"rna_NodeFunctionSignature_outputs_move");
RNA_def_property_srna(cprop, structtype);
srna = RNA_def_struct(brna, structtype, NULL);
RNA_def_struct_sdna(srna, "bNodeFunctionSignature");
RNA_def_struct_ui_text(srna, uiname, "Collection of node function parameters");
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, active_index_sdna);
RNA_def_property_ui_text(prop, "Active Index", "Index of the active parameter");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE, NULL);
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "NodeFunctionParameter");
RNA_def_property_pointer_funcs(prop, active_param_get, active_param_set, NULL, NULL);
RNA_def_property_ui_text(prop, "Active", "Active parameter");
RNA_def_property_update(prop, NC_NODE, NULL);
func = RNA_def_function(srna, "new", newfunc);
RNA_def_function_ui_description(func, "Add a parameter to this signature");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_enum(
func, "socket_type", node_socket_data_type_items, SOCK_FLOAT, "Type", "Data type");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_string(func, "name", NULL, MAX_NAME, "Name", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* return value */
parm = RNA_def_pointer(func, "param", "NodeFunctionParameter", "", "New parameter");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", removefunc);
RNA_def_function_ui_description(func, "Remove a parameter from this signature");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "param", "NodeFunctionParameter", "", "The parameter to remove");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
func = RNA_def_function(srna, "clear", clearfunc);
RNA_def_function_ui_description(func, "Remove all parameters from this collection");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
func = RNA_def_function(srna, "move", movefunc);
RNA_def_function_ui_description(func, "Move a parameter to another position");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
parm = RNA_def_int(
func, "from_index", -1, 0, INT_MAX, "From Index", "Index of the parameter to move", 0, 10000);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_int(
func, "to_index", -1, 0, INT_MAX, "To Index", "Target index for the parameter", 0, 10000);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
static void rna_def_node_function_signature(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "NodeFunctionSignature", NULL);
RNA_def_struct_ui_text(srna, "Node Function Signature", "Declaration of inputs and outputs of a node function");
RNA_def_struct_sdna(srna, "bNodeFunctionSignature");
prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "inputs", "inputs_num");
RNA_def_property_struct_type(prop, "NodeFunctionParameter");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Inputs", "Function inputs");
rna_def_node_function_signature_api(brna, prop, NODE_FUNC_PARAM_IN);
prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "outputs", "outputs_num");
RNA_def_property_struct_type(prop, "NodeFunctionParameter");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Outputs", "Function outputs");
rna_def_node_function_signature_api(brna, prop, NODE_FUNC_PARAM_OUT);
}
static void def_fn_evaluate(StructRNA *srna)
{
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeFunctionEvaluate", "storage");
RNA_def_struct_sdna_from(srna, "NodeGeometryEvaluateFunction", "storage");
prop = RNA_def_property(srna, "signature", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "signature");
@ -11792,6 +11663,146 @@ static void rna_def_node_socket_interface(BlenderRNA *brna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
}
static void rna_def_node_function_parameter(BlenderRNA *brna)
{
PropertyRNA *prop;
StructRNA *srna = RNA_def_struct(brna, "NodeFunctionParameter", NULL);
RNA_def_struct_ui_text(
srna, "Node Function Parameter", "Input or output declaration of a node function");
RNA_def_struct_sdna(srna, "bNodeFunctionParameter");
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NodeFunctionParameter_name_set");
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeFunctionParameter_update");
prop = RNA_def_property(srna, "socket_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, node_socket_data_type_items);
RNA_def_property_ui_text(prop, "Socket Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeFunctionParameter_update");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_float_funcs(prop, "rna_NodeFunctionParameter_color_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Color", "Socket color");
}
static void rna_def_node_function_signature_api(BlenderRNA *brna,
PropertyRNA *cprop,
eNodeFunctionParameterType param_type)
{
StructRNA *srna;
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
const char *structtype = (param_type == NODE_FUNC_PARAM_IN ? "NodeFunctionSignatureInputs" :
"NodeFunctionSignatureOutputs");
const char *uiname = (param_type == NODE_FUNC_PARAM_IN ? "Node Function Signature Inputs" :
"Node Function Signature Outputs");
const char *active_index_sdna = (param_type == NODE_FUNC_PARAM_IN ? "active_input" :
"active_output");
const char *active_param_get = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_active_input_get" :
"rna_NodeFunctionSignature_active_output_get");
const char *active_param_set = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_active_input_set" :
"rna_NodeFunctionSignature_active_output_set");
const char *newfunc = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_inputs_new" :
"rna_NodeFunctionSignature_outputs_new");
const char *removefunc = "rna_NodeFunctionSignature_params_remove";
const char *clearfunc = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_inputs_clear" :
"rna_NodeFunctionSignature_outputs_clear");
const char *movefunc = (param_type == NODE_FUNC_PARAM_IN ?
"rna_NodeFunctionSignature_inputs_move" :
"rna_NodeFunctionSignature_outputs_move");
RNA_def_property_srna(cprop, structtype);
srna = RNA_def_struct(brna, structtype, NULL);
RNA_def_struct_sdna(srna, "bNodeFunctionSignature");
RNA_def_struct_ui_text(srna, uiname, "Collection of node function parameters");
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, active_index_sdna);
RNA_def_property_ui_text(prop, "Active Index", "Index of the active parameter");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE, NULL);
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "NodeFunctionParameter");
RNA_def_property_pointer_funcs(prop, active_param_get, active_param_set, NULL, NULL);
RNA_def_property_ui_text(prop, "Active", "Active parameter");
RNA_def_property_update(prop, NC_NODE, NULL);
func = RNA_def_function(srna, "new", newfunc);
RNA_def_function_ui_description(func, "Add a parameter to this signature");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_enum(
func, "socket_type", node_socket_data_type_items, SOCK_FLOAT, "Type", "Data type");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_string(func, "name", NULL, MAX_NAME, "Name", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* return value */
parm = RNA_def_pointer(func, "param", "NodeFunctionParameter", "", "New parameter");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", removefunc);
RNA_def_function_ui_description(func, "Remove a parameter from this signature");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "param", "NodeFunctionParameter", "", "The parameter to remove");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
func = RNA_def_function(srna, "clear", clearfunc);
RNA_def_function_ui_description(func, "Remove all parameters from this collection");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
func = RNA_def_function(srna, "move", movefunc);
RNA_def_function_ui_description(func, "Move a parameter to another position");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
parm = RNA_def_int(func,
"from_index",
-1,
0,
INT_MAX,
"From Index",
"Index of the parameter to move",
0,
10000);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_int(
func, "to_index", -1, 0, INT_MAX, "To Index", "Target index for the parameter", 0, 10000);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
static void rna_def_node_function_signature(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "NodeFunctionSignature", NULL);
RNA_def_struct_ui_text(
srna, "Node Function Signature", "Declaration of inputs and outputs of a node function");
RNA_def_struct_sdna(srna, "bNodeFunctionSignature");
prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "inputs", "inputs_num");
RNA_def_property_struct_type(prop, "NodeFunctionParameter");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Inputs", "Function inputs");
rna_def_node_function_signature_api(brna, prop, NODE_FUNC_PARAM_IN);
prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "outputs", "outputs_num");
RNA_def_property_struct_type(prop, "NodeFunctionParameter");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Outputs", "Function outputs");
rna_def_node_function_signature_api(brna, prop, NODE_FUNC_PARAM_OUT);
}
static void rna_def_node_socket_float(BlenderRNA *brna,
const char *idname,
const char *interface_idname,

View File

@ -279,12 +279,11 @@ DefNode(FunctionNode, FN_NODE_SEPARATE_COLOR, def_fn_combsep_color, "SEPARATE_CO
DefNode(FunctionNode, FN_NODE_SLICE_STRING, 0, "SLICE_STRING", SliceString, "Slice String", "")
DefNode(FunctionNode, FN_NODE_STRING_LENGTH, 0, "STRING_LENGTH", StringLength, "String Length", "")
DefNode(FunctionNode, FN_NODE_VALUE_TO_STRING, 0, "VALUE_TO_STRING", ValueToString, "Value to String", "")
DefNode(FunctionNode, FN_NODE_BIND, def_fn_bind, "BIND", Bind, "Bind", "")
DefNode(FunctionNode, FN_NODE_EVALUATE, def_fn_evaluate, "EVALUATE", Evaluate, "Evaluate", "")
DefNode(GeometryNode, GEO_NODE_ACCUMULATE_FIELD, def_geo_accumulate_field, "ACCUMULATE_FIELD", AccumulateField, "Accumulate Field", "Add the values of an evaluated field together and output the running total for each element")
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_DOMAIN_SIZE, def_geo_attribute_domain_size, "ATTRIBUTE_DOMAIN_SIZE", AttributeDomainSize, "Domain Size", "Retrieve the number of elements in a geometry for each attribute domain")
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_STATISTIC, def_geo_attribute_statistic, "ATTRIBUTE_STATISTIC",AttributeStatistic, "Attribute Statistic","Calculate statistics about a data set from a field evaluated on a geometry")
DefNode(GeometryNode, GEO_NODE_BIND_FUNCTION, def_geo_bind_function, "BIND_FUNCTION", BindFunction, "Bind Function", "")
DefNode(GeometryNode, GEO_NODE_BLUR_ATTRIBUTE, def_geo_blur_attribute, "BLUR_ATTRIBUTE", BlurAttribute, "Blur Attribute", "Mix attribute values of neighboring elements")
DefNode(GeometryNode, GEO_NODE_BOUNDING_BOX, 0, "BOUNDING_BOX", BoundBox, "Bounding Box", "Calculate the limits of a geometry's positions and generate a box mesh with those dimensions")
DefNode(GeometryNode, GEO_NODE_CAPTURE_ATTRIBUTE, def_geo_attribute_capture,"CAPTURE_ATTRIBUTE", CaptureAttribute, "Capture Attribute", "Store the result of a field on a geometry and output the data as a node socket. Allows remembering or interpolating data as the geometry changes, such as positions before deformation")
@ -318,6 +317,7 @@ DefNode(GeometryNode, GEO_NODE_EDGE_PATHS_TO_CURVES, 0, "EDGE_PATHS_TO_CURVES",
DefNode(GeometryNode, GEO_NODE_EDGE_PATHS_TO_SELECTION, 0, "EDGE_PATHS_TO_SELECTION", EdgePathsToSelection, "Edge Paths to Selection", "")
DefNode(GeometryNode, GEO_NODE_EDGES_TO_FACE_GROUPS, 0, "EDGES_TO_FACE_GROUPS", EdgesToFaceGroups, "Edges to Face Groups", "Group faces into regions surrounded by the selected boundary edges")
DefNode(GeometryNode, GEO_NODE_EVALUATE_AT_INDEX, def_geo_evaluate_at_index, "FIELD_AT_INDEX", FieldAtIndex, "Evaluate at Index", "Retrieve data of other elements in the context's geometry")
DefNode(GeometryNode, GEO_NODE_EVALUATE_FUNCTION, def_geo_evaluate_function, "EVALUATE_FUNCTION", EvaluateFunction, "Evaluate Function", "")
DefNode(GeometryNode, GEO_NODE_EVALUATE_ON_DOMAIN, def_geo_evaluate_on_domain, "FIELD_ON_DOMAIN", FieldOnDomain, "Evaluate on Domain", "Retrieve values from a field on a different domain besides the domain from the context")
DefNode(GeometryNode, GEO_NODE_EXTRUDE_MESH, def_geo_extrude_mesh, "EXTRUDE_MESH", ExtrudeMesh, "Extrude Mesh", "Generate new vertices, edges, or faces from selected elements and move them based on an offset while keeping them connected by their boundary")
DefNode(GeometryNode, GEO_NODE_FILL_CURVE, def_geo_curve_fill, "FILL_CURVE", FillCurve, "Fill Curve", "Generate a mesh on the XY plane with faces on the inside of input curves")

View File

@ -21,11 +21,9 @@ set(INC_SYS
set(SRC
nodes/node_fn_align_euler_to_vector.cc
nodes/node_fn_bind.cc
nodes/node_fn_boolean_math.cc
nodes/node_fn_combine_color.cc
nodes/node_fn_compare.cc
nodes/node_fn_evaluate.cc
nodes/node_fn_float_to_int.cc
nodes/node_fn_input_bool.cc
nodes/node_fn_input_color.cc

View File

@ -7,11 +7,9 @@
void register_function_nodes()
{
register_node_type_fn_align_euler_to_vector();
register_node_type_fn_bind();
register_node_type_fn_boolean_math();
register_node_type_fn_combine_color();
register_node_type_fn_compare();
register_node_type_fn_evaluate();
register_node_type_fn_float_to_int();
register_node_type_fn_input_bool();
register_node_type_fn_input_color();

View File

@ -3,11 +3,9 @@
#pragma once
void register_node_type_fn_align_euler_to_vector();
void register_node_type_fn_bind();
void register_node_type_fn_boolean_math();
void register_node_type_fn_combine_color();
void register_node_type_fn_compare();
void register_node_type_fn_evaluate();
void register_node_type_fn_float_to_int();
void register_node_type_fn_input_bool();
void register_node_type_fn_input_color();

View File

@ -29,6 +29,7 @@ set(SRC
nodes/node_geo_attribute_capture.cc
nodes/node_geo_attribute_domain_size.cc
nodes/node_geo_attribute_statistic.cc
nodes/node_geo_bind_function.cc
nodes/node_geo_blur_attribute.cc
nodes/node_geo_boolean.cc
nodes/node_geo_bounding_box.cc
@ -71,6 +72,7 @@ set(SRC
nodes/node_geo_edge_split.cc
nodes/node_geo_edges_to_face_groups.cc
nodes/node_geo_evaluate_at_index.cc
nodes/node_geo_evaluate_function.cc
nodes/node_geo_evaluate_on_domain.cc
nodes/node_geo_extrude_mesh.cc
nodes/node_geo_flip_faces.cc

View File

@ -14,6 +14,7 @@ void register_geometry_nodes()
register_node_type_geo_attribute_capture();
register_node_type_geo_attribute_domain_size();
register_node_type_geo_attribute_statistic();
register_node_type_geo_bind_function();
register_node_type_geo_blur_attribute();
register_node_type_geo_boolean();
register_node_type_geo_bounding_box();
@ -55,6 +56,7 @@ void register_geometry_nodes()
register_node_type_geo_edge_split();
register_node_type_geo_edges_to_face_groups();
register_node_type_geo_evaluate_at_index();
register_node_type_geo_evaluate_function();
register_node_type_geo_evaluate_on_domain();
register_node_type_geo_extrude_mesh();
register_node_type_geo_flip_faces();

View File

@ -11,6 +11,7 @@ void register_node_type_geo_attribute_capture();
void register_node_type_geo_attribute_domain_size();
void register_node_type_geo_attribute_separate_xyz();
void register_node_type_geo_attribute_statistic();
void register_node_type_geo_bind_function();
void register_node_type_geo_blur_attribute();
void register_node_type_geo_boolean();
void register_node_type_geo_bounding_box();
@ -52,6 +53,7 @@ void register_node_type_geo_edge_paths_to_selection();
void register_node_type_geo_edge_split();
void register_node_type_geo_edges_to_face_groups();
void register_node_type_geo_evaluate_at_index();
void register_node_type_geo_evaluate_function();
void register_node_type_geo_evaluate_on_domain();
void register_node_type_geo_extrude_mesh();
void register_node_type_geo_flip_faces();

View File

@ -11,10 +11,9 @@
#include "NOD_node_declaration.hh"
#include "node_common.h"
#include "node_function_util.hh"
#include "node_function_util.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_fn_bind_cc {
namespace blender::nodes::node_geo_bind_function_cc {
static void node_declare(const bNodeTree &node_tree,
const bNode &node,
@ -50,17 +49,31 @@ static void node_layout(uiLayout *layout, bContext *C, PointerRNA *ptr)
layout, C, ptr, "node_tree", nullptr, nullptr, nullptr, UI_TEMPLATE_ID_FILTER_ALL, nullptr);
}
} // namespace blender::nodes::node_fn_bind_cc
void register_node_type_fn_bind()
static void node_geo_exec(GeoNodeExecParams params)
{
namespace file_ns = blender::nodes::node_fn_bind_cc;
//GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
//const NodeGeometryCurveFill &storage = node_storage(params.node());
//const GeometryNodeCurveFillMode mode = (GeometryNodeCurveFillMode)storage.mode;
//geometry_set.modify_geometry_sets(
// [&](GeometrySet &geometry_set) { curve_fill_calculate(geometry_set, mode); });
//params.set_output("Mesh", std::move(geometry_set));
}
} // namespace blender::nodes::node_geo_bind_function_cc
void register_node_type_geo_bind_function()
{
namespace file_ns = blender::nodes::node_geo_bind_function_cc;
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_BIND, "Bind", NODE_CLASS_GROUP);
geo_node_type_base(&ntype, GEO_NODE_BIND_FUNCTION, "Bind Function", NODE_CLASS_GROUP);
ntype.declare_dynamic = file_ns::node_declare;
ntype.poll_instance = node_group_poll_instance;
ntype.draw_buttons = file_ns::node_layout;
ntype.geometry_node_execute = file_ns::node_geo_exec;
nodeRegisterType(&ntype);
}

View File

@ -10,11 +10,11 @@
#include "UI_resources.h"
#include "NOD_common.h"
#include "node_function_util.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_fn_evaluate_cc {
namespace blender::nodes::node_geo_evaluate_function_cc {
NODE_STORAGE_FUNCS(NodeFunctionEvaluate)
NODE_STORAGE_FUNCS(NodeGeometryEvaluateFunction)
static void node_declare(const bNodeTree &node_tree,
const bNode &node,
@ -24,7 +24,7 @@ static void node_declare(const bNodeTree &node_tree,
if (node.storage == nullptr) {
return;
}
const NodeFunctionEvaluate &storage = node_storage(node);
const NodeGeometryEvaluateFunction &storage = node_storage(node);
NodeDeclarationBuilder builder(r_declaration);
builder.add_input<decl::Function>(N_("Function"));
@ -35,7 +35,7 @@ static void node_declare(const bNodeTree &node_tree,
static void node_init(bNodeTree * /*tree*/, bNode *node)
{
NodeFunctionEvaluate *data = MEM_cnew<NodeFunctionEvaluate>(__func__);
NodeGeometryEvaluateFunction *data = MEM_cnew<NodeGeometryEvaluateFunction>(__func__);
node->storage = data;
}
@ -47,20 +47,20 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
}
} // namespace blender::nodes::node_fn_evaluate_cc
} // namespace blender::nodes::node_geo_evaluate_function_cc
void register_node_type_fn_evaluate()
void register_node_type_geo_evaluate_function()
{
namespace file_ns = blender::nodes::node_fn_evaluate_cc;
namespace file_ns = blender::nodes::node_geo_evaluate_function_cc;
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_EVALUATE, "Evaluate", NODE_CLASS_GROUP);
geo_node_type_base(&ntype, GEO_NODE_EVALUATE_FUNCTION, "Evaluate Function", NODE_CLASS_GROUP);
ntype.declare_dynamic = file_ns::node_declare;
ntype.draw_buttons = file_ns::node_layout;
ntype.initfunc = file_ns::node_init;
ntype.updatefunc = file_ns::node_update;
node_type_storage(
&ntype, "NodeFunctionEvaluate", node_free_standard_storage, node_copy_standard_storage);
&ntype, "NodeGeometryEvaluateFunction", node_free_standard_storage, node_copy_standard_storage);
nodeRegisterType(&ntype);
}