[Bf-blender-cvs] [31e7eb9] object_nodes: 'Local' value type for outputs to indicate their use as local function arguments.
Lukas Tönne
noreply at git.blender.org
Wed Dec 9 10:47:18 CET 2015
Commit: 31e7eb9a1328f4655181eb2a1092874ba2062c91
Author: Lukas Tönne
Date: Tue Dec 8 21:31:02 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB31e7eb9a1328f4655181eb2a1092874ba2062c91
'Local' value type for outputs to indicate their use as local function arguments.
===================================================================
M source/blender/blenvm/BVM_api.h
M source/blender/blenvm/BVM_types.h
M source/blender/blenvm/bvm/bvm_eval.cc
M source/blender/blenvm/bvm/bvm_eval_mesh.h
M source/blender/blenvm/compile/bvm_nodegraph.cc
M source/blender/blenvm/intern/bvm_api.cc
M source/blender/makesrna/intern/rna_blenvm.c
===================================================================
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index 580d5a5..d1e64b1 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -89,6 +89,7 @@ struct BVMTypeDesc *BVM_node_input_typedesc(struct BVMNodeInput *input);
BVMInputValueType BVM_node_input_value_type(struct BVMNodeInput *input);
const char *BVM_node_output_name(struct BVMNodeOutput *output);
struct BVMTypeDesc *BVM_node_output_typedesc(struct BVMNodeOutput *output);
+BVMOutputValueType BVM_node_output_value_type(struct BVMNodeOutput *output);
BVMType BVM_typedesc_base_type(struct BVMTypeDesc *typedesc);
diff --git a/source/blender/blenvm/BVM_types.h b/source/blender/blenvm/BVM_types.h
index 8c2f3a7..f4f292a 100644
--- a/source/blender/blenvm/BVM_types.h
+++ b/source/blender/blenvm/BVM_types.h
@@ -54,6 +54,7 @@ typedef enum BVMInputValueType {
typedef enum BVMOutputValueType {
OUTPUT_VARIABLE,
+ OUTPUT_LOCAL,
} BVMOutputValueType;
#ifdef __cplusplus
diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index 201e4dd..13b7890 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -737,8 +737,10 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Function *
int fn_transform = fn->read_jump_address(&instr);
StackIndex offset_transform = fn->read_stack_index(&instr);
StackIndex offset_mesh_out = fn->read_stack_index(&instr);
+ StackIndex offset_iteration = fn->read_stack_index(&instr);
eval_op_mesh_array(globals, &kd, stack,
- offset_mesh_in, offset_mesh_out, offset_count, fn_transform, offset_transform);
+ offset_mesh_in, offset_mesh_out, offset_count,
+ fn_transform, offset_transform, offset_iteration);
break;
}
case OP_END:
diff --git a/source/blender/blenvm/bvm/bvm_eval_mesh.h b/source/blender/blenvm/bvm/bvm_eval_mesh.h
index 90fef12..4b0cc07 100644
--- a/source/blender/blenvm/bvm/bvm_eval_mesh.h
+++ b/source/blender/blenvm/bvm/bvm_eval_mesh.h
@@ -159,7 +159,8 @@ static void eval_op_mesh_combine(const EvalKernelData */*kernel_data*/, float *s
}
static DerivedMesh *do_array(const EvalGlobals *globals, const EvalKernelData *kernel_data, float *stack,
- DerivedMesh *dm, int count, int fn_transform, StackIndex offset_transform)
+ DerivedMesh *dm, int count,
+ int fn_transform, StackIndex offset_transform, StackIndex offset_iteration)
{
const bool use_recalc_normals = (dm->dirty & DM_DIRTY_NORMALS);
@@ -209,6 +210,7 @@ static DerivedMesh *do_array(const EvalGlobals *globals, const EvalKernelData *k
DM_copy_poly_data(result, result, 0, c * chunk_npolys, chunk_npolys);
/* calculate transform for the copy */
+ stack_store_int(stack, offset_iteration, c);
kernel_data->context->eval_expression(globals, kernel_data->function, fn_transform, stack);
matrix44 tfm = stack_load_matrix44(stack, offset_transform);
@@ -259,14 +261,14 @@ static DerivedMesh *do_array(const EvalGlobals *globals, const EvalKernelData *k
}
static void eval_op_mesh_array(const EvalGlobals *globals, const EvalKernelData *kernel_data, float *stack,
- StackIndex offset_mesh_in, StackIndex offset_mesh_out,
- StackIndex offset_count, int fn_transform, StackIndex offset_transform)
+ StackIndex offset_mesh_in, StackIndex offset_mesh_out, StackIndex offset_count,
+ int fn_transform, StackIndex offset_transform, StackIndex offset_iteration)
{
DerivedMesh *dm = stack_load_mesh(stack, offset_mesh_in);
int count = stack_load_int(stack, offset_count);
DerivedMesh *result = (count > 0) ?
- do_array(globals, kernel_data, stack, dm, count, fn_transform, offset_transform) :
+ do_array(globals, kernel_data, stack, dm, count, fn_transform, offset_transform, offset_iteration) :
CDDM_new(0, 0, 0, 0, 0);
stack_store_mesh(stack, offset_mesh_out, result);
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index d682a88..298fef2 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -220,6 +220,8 @@ const NodeOutput *NodeType::add_output(const string &name,
BVMOutputValueType value_type)
{
BLI_assert(!find_output(name));
+ /* local outputs only allowed for kernel nodes */
+ BLI_assert(m_is_kernel_node || value_type != OUTPUT_LOCAL);
m_outputs.push_back(NodeOutput(name, type, value_type));
return &m_outputs.back();
}
@@ -1405,6 +1407,7 @@ static void register_opcode_node_types()
nt->add_input("count", BVM_INT, 1);
nt->add_input("transform", BVM_MATRIX44, matrix44::identity(), INPUT_FUNCTION);
nt->add_output("mesh_out", BVM_MESH);
+ nt->add_output("iteration", BVM_INT, OUTPUT_LOCAL);
nt = NodeGraph::add_function_node_type("ADD_MATRIX44");
nt->add_input("value_a", BVM_MATRIX44, matrix44::identity());
diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index e47bd6c..fad0091 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -204,6 +204,9 @@ const char *BVM_node_output_name(struct BVMNodeOutput *output)
struct BVMTypeDesc *BVM_node_output_typedesc(struct BVMNodeOutput *output)
{ return (struct BVMTypeDesc *)(&_OUTPUT(output)->typedesc); }
+BVMOutputValueType BVM_node_output_value_type(struct BVMNodeOutput *output)
+{ return _OUTPUT(output)->value_type; }
+
BVMType BVM_typedesc_base_type(struct BVMTypeDesc *typedesc)
{ return _TYPEDESC(typedesc)->base_type; }
diff --git a/source/blender/makesrna/intern/rna_blenvm.c b/source/blender/makesrna/intern/rna_blenvm.c
index ed10b2a..9ef393c 100644
--- a/source/blender/makesrna/intern/rna_blenvm.c
+++ b/source/blender/makesrna/intern/rna_blenvm.c
@@ -109,6 +109,11 @@ static PointerRNA rna_BVMNodeOutput_typedesc_get(PointerRNA *ptr)
return r_ptr;
}
+static int rna_BVMNodeOutput_value_type_get(PointerRNA *ptr)
+{
+ return BVM_node_output_value_type(ptr->data);
+}
+
static void rna_BVMNodeInstance_inputs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
struct BVMNodeInstance *node = ptr->data;
@@ -350,6 +355,12 @@ static void rna_def_bvm_node_output(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem value_type_items[] = {
+ {OUTPUT_VARIABLE, "VARIABLE", 0, "Variable", "Variable value that can be used by other nodes"},
+ {OUTPUT_LOCAL, "LOCAL", 0, "Local", "Local value that is only used internally"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "BVMNodeOutput", NULL);
RNA_def_struct_ui_text(srna, "Node Output", "Output of a node");
@@ -364,6 +375,12 @@ static void rna_def_bvm_node_output(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "BVMTypeDesc");
RNA_def_property_pointer_funcs(prop, "rna_BVMNodeOutput_typedesc_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Type Descriptor", "Type of data accepted by the input");
+
+ prop = RNA_def_property(srna, "value_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_enum_items(prop, value_type_items);
+ RNA_def_property_enum_funcs(prop, "rna_BVMNodeOutput_value_type_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Value Type", "Limits the data connections the output allows");
}
static void rna_def_bvm_node_instance(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list