[Bf-blender-cvs] [d53946a] object_nodes: Improved RNA API for bvm node graphs.
Lukas Tönne
noreply at git.blender.org
Wed Dec 2 12:05:54 CET 2015
Commit: d53946ad7ea102a94075c0f804936cdc06a4fdb3
Author: Lukas Tönne
Date: Tue Dec 1 17:33:23 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBd53946ad7ea102a94075c0f804936cdc06a4fdb3
Improved RNA API for bvm node graphs.
Now there are actual collections of inputs/outputs to perform proper checks
on valid names/indices and types.
===================================================================
M release/scripts/startup/bl_operators/object_nodes.py
M source/blender/blenvm/BVM_api.h
M source/blender/blenvm/BVM_types.h
M source/blender/blenvm/compile/bvm_nodegraph.cc
M source/blender/blenvm/compile/bvm_nodegraph.h
M source/blender/blenvm/intern/bvm_api.cc
M source/blender/makesrna/intern/rna_blenvm.c
===================================================================
diff --git a/release/scripts/startup/bl_operators/object_nodes.py b/release/scripts/startup/bl_operators/object_nodes.py
index 3f39164..bb90568 100644
--- a/release/scripts/startup/bl_operators/object_nodes.py
+++ b/release/scripts/startup/bl_operators/object_nodes.py
@@ -135,13 +135,13 @@ class NodeCompiler:
pairs.add((node, name))
if isinstance(socket, bpy.types.NodeSocketFloat):
- node.set_value_float(name, socket.default_value)
+ node.set_value_float(node.inputs[name], socket.default_value)
elif isinstance(socket, bpy.types.NodeSocketVector):
- node.set_value_float3(name, socket.default_value)
+ node.set_value_float3(node.inputs[name], socket.default_value)
elif isinstance(socket, bpy.types.NodeSocketColor):
- node.set_value_float4(name, socket.default_value)
+ node.set_value_float4(node.inputs[name], socket.default_value)
elif isinstance(socket, bpy.types.NodeSocketInt):
- node.set_value_int(name, socket.default_value)
+ node.set_value_int(node.inputs[name], socket.default_value)
def map_output(self, index, node, name):
socket = self.current_node.outputs[index]
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index 15f50b2..3ee280b 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -55,6 +55,9 @@ void BVM_function_free(struct BVMFunction *fn);
struct BVMCompileContext;
struct BVMNodeGraph;
struct BVMNodeInstance;
+struct BVMNodeInput;
+struct BVMNodeOutput;
+struct BVMTypeDesc;
int BVM_compile_get_object_index(struct BVMCompileContext *context, struct Object *ob);
@@ -67,16 +70,25 @@ void BVM_nodegraph_add_link(struct BVMNodeGraph *graph,
void BVM_nodegraph_get_output(struct BVMNodeGraph *graph, const char *name,
struct BVMNodeInstance **node, const char **socket);
-void BVM_node_set_input_value_float(struct BVMNodeInstance *node,
- const char *socket, float value);
-void BVM_node_set_input_value_float3(struct BVMNodeInstance *node,
- const char *socket, const float value[3]);
-void BVM_node_set_input_value_float4(struct BVMNodeInstance *node,
- const char *socket, const float value[4]);
-void BVM_node_set_input_value_matrix44(struct BVMNodeInstance *node,
- const char *socket, float value[4][4]);
-void BVM_node_set_input_value_int(struct BVMNodeInstance *node,
- const char *socket, int value);
+int BVM_node_num_inputs(struct BVMNodeInstance *node);
+int BVM_node_num_outputs(struct BVMNodeInstance *node);
+struct BVMNodeInput *BVM_node_get_input(struct BVMNodeInstance *node, const char *name);
+struct BVMNodeInput *BVM_node_get_input_n(struct BVMNodeInstance *node, int index);
+struct BVMNodeOutput *BVM_node_get_output(struct BVMNodeInstance *node, const char *name);
+struct BVMNodeOutput *BVM_node_get_output_n(struct BVMNodeInstance *node, int index);
+void BVM_node_set_input_value_float(struct BVMNodeInstance *node, struct BVMNodeInput *input, float value);
+void BVM_node_set_input_value_float3(struct BVMNodeInstance *node, struct BVMNodeInput *input, const float value[3]);
+void BVM_node_set_input_value_float4(struct BVMNodeInstance *node, struct BVMNodeInput *input, const float value[4]);
+void BVM_node_set_input_value_matrix44(struct BVMNodeInstance *node, struct BVMNodeInput *input, float value[4][4]);
+void BVM_node_set_input_value_int(struct BVMNodeInstance *node, struct BVMNodeInput *input, int value);
+
+const char *BVM_node_input_name(struct BVMNodeInput *input);
+struct BVMTypeDesc *BVM_node_input_typedesc(struct BVMNodeInput *input);
+BVMValueType 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);
+
+BVMType BVM_typedesc_base_type(struct BVMTypeDesc *typedesc);
/* ------------------------------------------------------------------------- */
@@ -115,9 +127,9 @@ void BVM_eval_texture(struct BVMEvalContext *context, struct BVMFunction *fn,
float coord[3], float dxt[3], float dyt[3], int osatex,
short which_output, int cfra, int preview);
-struct BVMFunction *BVM_texture_cache_acquire(Tex *tex);
-void BVM_texture_cache_release(Tex *tex);
-void BVM_texture_cache_invalidate(Tex *tex);
+struct BVMFunction *BVM_texture_cache_acquire(struct Tex *tex);
+void BVM_texture_cache_release(struct Tex *tex);
+void BVM_texture_cache_invalidate(struct Tex *tex);
void BVM_texture_cache_clear(void);
/* ------------------------------------------------------------------------- */
diff --git a/source/blender/blenvm/BVM_types.h b/source/blender/blenvm/BVM_types.h
index a08e9f0..ff9280a 100644
--- a/source/blender/blenvm/BVM_types.h
+++ b/source/blender/blenvm/BVM_types.h
@@ -46,6 +46,12 @@ typedef enum BVMType {
BVM_MESH,
} BVMType;
+typedef enum BVMValueType {
+ VALUE_CONSTANT,
+ VALUE_VARIABLE,
+ VALUE_FUNCTION
+} BVMValueType;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index 61a2574..212f286 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -44,7 +44,7 @@ namespace bvm {
NodeSocket::NodeSocket(const string &name,
const TypeDesc &typedesc,
Value *default_value,
- eNodeSocketValueType value_type) :
+ BVMValueType value_type) :
name(name),
typedesc(typedesc),
default_value(default_value),
@@ -191,7 +191,7 @@ bool NodeType::verify_arguments(Module *module, LLVMContext &context, raw_ostrea
const NodeSocket *NodeType::add_input(const string &name,
BVMType type,
Value *default_value,
- eNodeSocketValueType value_type)
+ BVMValueType value_type)
{
BLI_assert(!find_input(name));
/* function inputs only allowed for kernel nodes */
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.h b/source/blender/blenvm/compile/bvm_nodegraph.h
index 5092d8a..830f2db 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.h
+++ b/source/blender/blenvm/compile/bvm_nodegraph.h
@@ -58,23 +58,17 @@ struct NodeGraph;
struct NodeType;
struct NodeInstance;
-enum eNodeSocketValueType {
- VALUE_CONSTANT,
- VALUE_VARIABLE,
- VALUE_FUNCTION
-};
-
struct NodeSocket {
NodeSocket(const string &name,
const TypeDesc &typedesc,
Value *default_value,
- eNodeSocketValueType value_type);
+ BVMValueType value_type);
~NodeSocket();
string name;
TypeDesc typedesc;
Value *default_value;
- eNodeSocketValueType value_type;
+ BVMValueType value_type;
};
struct NodeType {
@@ -105,7 +99,7 @@ struct NodeType {
const NodeSocket *add_input(const string &name,
BVMType type,
Value *default_value,
- eNodeSocketValueType value_type = VALUE_VARIABLE);
+ BVMValueType value_type = VALUE_VARIABLE);
const NodeSocket *add_output(const string &name,
BVMType type,
Value *default_value);
@@ -114,7 +108,7 @@ struct NodeType {
const NodeSocket *add_input(const string &name,
BVMType type,
T default_value,
- eNodeSocketValueType value_type = VALUE_VARIABLE)
+ BVMValueType value_type = VALUE_VARIABLE)
{
Value *c = Value::create(type, default_value);
BLI_assert(c != NULL);
diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 1e617ab..b44fcd5 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -98,6 +98,12 @@ BLI_INLINE bvm::NodeGraph *_GRAPH(struct BVMNodeGraph *graph)
{ return (bvm::NodeGraph *)graph; }
BLI_INLINE bvm::NodeInstance *_NODE(struct BVMNodeInstance *node)
{ return (bvm::NodeInstance *)node; }
+BLI_INLINE bvm::NodeSocket *_INPUT(struct BVMNodeInput *input)
+{ return (bvm::NodeSocket *)input; }
+BLI_INLINE bvm::NodeSocket *_OUTPUT(struct BVMNodeOutput *output)
+{ return (bvm::NodeSocket *)output; }
+BLI_INLINE bvm::TypeDesc *_TYPEDESC(struct BVMTypeDesc *typedesc)
+{ return (bvm::TypeDesc *)typedesc; }
struct BVMNodeInstance *BVM_nodegraph_add_node(BVMNodeGraph *graph, const char *type, const char *name)
{ return (struct BVMNodeInstance *)_GRAPH(graph)->add_node(type, name); }
@@ -121,25 +127,71 @@ void BVM_nodegraph_get_output(struct BVMNodeGraph *graph, const char *name,
}
-void BVM_node_set_input_value_float(struct BVMNodeInstance *node, const char *socket,
+int BVM_node_num_inputs(struct BVMNodeInstance *node)
+{ return _NODE(node)->num_inputs(); }
+
+int BVM_node_num_outputs(struct BVMNodeInstance *node)
+{ return _NODE(node)->num_outputs(); }
+
+struct BVMNodeInput *BVM_node_get_input(struct BVMNodeInstance *node, const char *name)
+{ return (struct BVMNodeInput *)_NODE(node)->type->find_input(name); }
+
+struct BVMNodeInput *BVM_node_get_input_n(struct BVMNodeInstance *node, int index)
+{
+ if (index >= 0 && index < _NODE(node)->num_inputs())
+ return (struct BVMNodeInput *)_NODE(node)->type->find_input(index);
+ else
+ return NULL;
+}
+
+struct BVMNodeOutput *BVM_node_get_output(struct BVMNodeInstance *node, const char *name)
+{ return (struct BVMNodeOutput *)_NODE(node)->type->find_output(name); }
+
+struct BVMNodeOutput *BVM_node_get_output_n(struct BVMNodeInstance *node, int index)
+{
+ if (index >= 0 && index < _NODE(node)->num_outputs())
+ return (struct BVMNodeOutput *)_NODE(node)->type->find_output(index);
+ else
+ return NULL;
+}
+
+void BVM_node_set_in
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list