[Bf-blender-cvs] [a7bfdb0] object_nodes: Use a full TypeDesc in node sockets.
Lukas Tönne
noreply at git.blender.org
Tue Nov 24 09:44:24 CET 2015
Commit: a7bfdb0cdf4648a0ca3396e0d193861c53bd26ec
Author: Lukas Tönne
Date: Mon Nov 16 08:52:03 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBa7bfdb0cdf4648a0ca3396e0d193861c53bd26ec
Use a full TypeDesc in node sockets.
For the time being this is synonymous with the base type, but in future
it could allow (fixed-size) arrays and vector semantics.
===================================================================
M source/blender/blenvm/compile/bvm_codegen.cc
M source/blender/blenvm/compile/bvm_nodegraph.cc
M source/blender/blenvm/compile/bvm_nodegraph.h
M source/blender/blenvm/util/bvm_util_typedesc.h
===================================================================
diff --git a/source/blender/blenvm/compile/bvm_codegen.cc b/source/blender/blenvm/compile/bvm_codegen.cc
index af9fba6..cbc3b9f 100644
--- a/source/blender/blenvm/compile/bvm_codegen.cc
+++ b/source/blender/blenvm/compile/bvm_codegen.cc
@@ -365,7 +365,7 @@ Function *BVMCompiler::codegen_function(const NodeGraph &graph)
const NodeSocket &output = node.type->outputs[i];
SocketPair key(&node, &output);
- socket_index[key] = assign_stack_index(TypeDesc(output.type));
+ socket_index[key] = assign_stack_index(output.typedesc);
push_stack_index(socket_index[key]);
}
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index bf44a82..df10472 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -40,9 +40,9 @@
namespace bvm {
-NodeSocket::NodeSocket(const string &name, BVMType type, Value *default_value, bool constant) :
+NodeSocket::NodeSocket(const string &name, const TypeDesc &typedesc, Value *default_value, bool constant) :
name(name),
- type(type),
+ typedesc(typedesc),
default_value(default_value),
constant(constant)
{
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.h b/source/blender/blenvm/compile/bvm_nodegraph.h
index 6cbcb79..54ea9f8 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.h
+++ b/source/blender/blenvm/compile/bvm_nodegraph.h
@@ -58,11 +58,11 @@ struct NodeType;
struct NodeInstance;
struct NodeSocket {
- NodeSocket(const string &name, BVMType type, Value *default_value, bool constant);
+ NodeSocket(const string &name, const TypeDesc &typedesc, Value *default_value, bool constant);
~NodeSocket();
string name;
- BVMType type;
+ TypeDesc typedesc;
Value *default_value;
bool constant;
};
@@ -185,14 +185,14 @@ struct NodeInstance {
bool set_input_value(const string &name, const T &value)
{
const NodeSocket *socket = type->find_input(name);
- return socket ? set_input_value(name, Value::create(socket->type, value)) : false;
+ return socket ? set_input_value(name, Value::create(socket->typedesc, value)) : false;
}
template <typename T>
bool set_output_value(const string &name, const T &value)
{
const NodeSocket *socket = type->find_output(name);
- return socket ? set_output_value(name, Value::create(socket->type, value)) : false;
+ return socket ? set_output_value(name, Value::create(socket->typedesc, value)) : false;
}
bool has_input_link(const string &name) const;
@@ -268,7 +268,7 @@ struct NodeGraph {
return false;
SocketPair converted = (autoconvert) ?
- add_type_converter(SocketPair(from_node, from), to_socket->type) :
+ add_type_converter(SocketPair(from_node, from), to_socket->typedesc) :
SocketPair(from_node, from);
if (!converted.node)
return false;
@@ -408,11 +408,13 @@ protected:
return result;
}
- SocketPair add_type_converter(const SocketPair &from, BVMType to_type)
+ SocketPair add_type_converter(const SocketPair &from, const TypeDesc &to_typedesc)
{
SocketPair result(NULL, "");
const NodeSocket *from_socket = from.node->type->find_output(from.socket);
- BVMType from_type = from_socket->type;
+ /* TODO only uses base type so far */
+ BVMType to_type = to_typedesc.base_type;
+ BVMType from_type = from_socket->typedesc.base_type;
if (from_type == to_type) {
result = from;
diff --git a/source/blender/blenvm/util/bvm_util_typedesc.h b/source/blender/blenvm/util/bvm_util_typedesc.h
index 9141937..719e4fa 100644
--- a/source/blender/blenvm/util/bvm_util_typedesc.h
+++ b/source/blender/blenvm/util/bvm_util_typedesc.h
@@ -251,6 +251,7 @@ struct TypeDesc {
{}
inline bool assignable(const TypeDesc &other) const;
+ inline bool is_kernel_type() const;
BVMType base_type;
@@ -262,7 +263,7 @@ struct TypeDesc {
struct Value {
template <typename T>
- static Value *create(BVMType type, T data);
+ static Value *create(const TypeDesc &typedesc, T data);
virtual ~Value()
{}
@@ -318,9 +319,10 @@ private:
/* ========================================================================= */
template <typename T>
-Value *Value::create(BVMType type, T data)
+Value *Value::create(const TypeDesc &typedesc, T data)
{
- switch (type) {
+ /* TODO take extended TypeDesc into account */
+ switch (typedesc.base_type) {
case BVM_FLOAT: return new ValueType<BVM_FLOAT>(data);
case BVM_FLOAT3: return new ValueType<BVM_FLOAT3>(data);
case BVM_FLOAT4: return new ValueType<BVM_FLOAT4>(data);
More information about the Bf-blender-cvs
mailing list