Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /intern/cycles/graph
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'intern/cycles/graph')
-rw-r--r--intern/cycles/graph/CMakeLists.txt16
-rw-r--r--intern/cycles/graph/node.cpp817
-rw-r--r--intern/cycles/graph/node.h131
-rw-r--r--intern/cycles/graph/node_enum.h55
-rw-r--r--intern/cycles/graph/node_type.cpp265
-rw-r--r--intern/cycles/graph/node_type.h425
-rw-r--r--intern/cycles/graph/node_xml.cpp768
-rw-r--r--intern/cycles/graph/node_xml.h4
8 files changed, 1351 insertions, 1130 deletions
diff --git a/intern/cycles/graph/CMakeLists.txt b/intern/cycles/graph/CMakeLists.txt
index bd2b2728a29..c6c46941598 100644
--- a/intern/cycles/graph/CMakeLists.txt
+++ b/intern/cycles/graph/CMakeLists.txt
@@ -1,19 +1,19 @@
set(INC
- ..
+ ..
)
set(SRC
- node.cpp
- node_type.cpp
- node_xml.cpp
+ node.cpp
+ node_type.cpp
+ node_xml.cpp
)
set(SRC_HEADERS
- node.h
- node_enum.h
- node_type.h
- node_xml.h
+ node.h
+ node_enum.h
+ node_type.h
+ node_xml.h
)
set(LIB
diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp
index 19fe0a168ea..fc7daaeeaa6 100644
--- a/intern/cycles/graph/node.cpp
+++ b/intern/cycles/graph/node.cpp
@@ -26,550 +26,645 @@ CCL_NAMESPACE_BEGIN
/* Node Type */
-Node::Node(const NodeType *type_, ustring name_)
-: name(name_), type(type_)
+Node::Node(const NodeType *type_, ustring name_) : name(name_), type(type_)
{
- assert(type);
+ assert(type);
- /* assign non-empty name, convenient for debugging */
- if(name.empty()) {
- name = type->name;
- }
+ /* assign non-empty name, convenient for debugging */
+ if (name.empty()) {
+ name = type->name;
+ }
- /* initialize default values */
- foreach(const SocketType& socket, type->inputs) {
- set_default_value(socket);
- }
+ /* initialize default values */
+ foreach (const SocketType &socket, type->inputs) {
+ set_default_value(socket);
+ }
}
Node::~Node()
{
}
-template<typename T>
-static T& get_socket_value(const Node *node, const SocketType& socket)
+template<typename T> static T &get_socket_value(const Node *node, const SocketType &socket)
{
- return (T&)*(((char*)node) + socket.struct_offset);
+ return (T &)*(((char *)node) + socket.struct_offset);
}
#ifndef NDEBUG
-static bool is_socket_float3(const SocketType& socket)
+static bool is_socket_float3(const SocketType &socket)
{
- return socket.type == SocketType::COLOR ||
- socket.type == SocketType::POINT ||
- socket.type == SocketType::VECTOR ||
- socket.type == SocketType::NORMAL;
+ return socket.type == SocketType::COLOR || socket.type == SocketType::POINT ||
+ socket.type == SocketType::VECTOR || socket.type == SocketType::NORMAL;
}
-static bool is_socket_array_float3(const SocketType& socket)
+static bool is_socket_array_float3(const SocketType &socket)
{
- return socket.type == SocketType::COLOR_ARRAY ||
- socket.type == SocketType::POINT_ARRAY ||
- socket.type == SocketType::VECTOR_ARRAY ||
- socket.type == SocketType::NORMAL_ARRAY;
+ return socket.type == SocketType::COLOR_ARRAY || socket.type == SocketType::POINT_ARRAY ||
+ socket.type == SocketType::VECTOR_ARRAY || socket.type == SocketType::NORMAL_ARRAY;
}
#endif
/* set values */
-void Node::set(const SocketType& input, bool value)
+void Node::set(const SocketType &input, bool value)
{
- assert(input.type == SocketType::BOOLEAN);
- get_socket_value<bool>(this, input) = value;
+ assert(input.type == SocketType::BOOLEAN);
+ get_socket_value<bool>(this, input) = value;
}
-void Node::set(const SocketType& input, int value)
+void Node::set(const SocketType &input, int value)
{
- assert((input.type == SocketType::INT || input.type == SocketType::ENUM));
- get_socket_value<int>(this, input) = value;
+ assert((input.type == SocketType::INT || input.type == SocketType::ENUM));
+ get_socket_value<int>(this, input) = value;
}
-void Node::set(const SocketType& input, uint value)
+void Node::set(const SocketType &input, uint value)
{
- assert(input.type == SocketType::UINT);
- get_socket_value<uint>(this, input) = value;
+ assert(input.type == SocketType::UINT);
+ get_socket_value<uint>(this, input) = value;
}
-void Node::set(const SocketType& input, float value)
+void Node::set(const SocketType &input, float value)
{
- assert(input.type == SocketType::FLOAT);
- get_socket_value<float>(this, input) = value;
+ assert(input.type == SocketType::FLOAT);
+ get_socket_value<float>(this, input) = value;
}
-void Node::set(const SocketType& input, float2 value)
+void Node::set(const SocketType &input, float2 value)
{
- assert(input.type == SocketType::FLOAT);
- get_socket_value<float2>(this, input) = value;
+ assert(input.type == SocketType::FLOAT);
+ get_socket_value<float2>(this, input) = value;
}
-void Node::set(const SocketType& input, float3 value)
+void Node::set(const SocketType &input, float3 value)
{
- assert(is_socket_float3(input));
- get_socket_value<float3>(this, input) = value;
+ assert(is_socket_float3(input));
+ get_socket_value<float3>(this, input) = value;
}
-void Node::set(const SocketType& input, const char *value)
+void Node::set(const SocketType &input, const char *value)
{
- set(input, ustring(value));
+ set(input, ustring(value));
}
-void Node::set(const SocketType& input, ustring value)
+void Node::set(const SocketType &input, ustring value)
{
- if(input.type == SocketType::STRING) {
- get_socket_value<ustring>(this, input) = value;
- }
- else if(input.type == SocketType::ENUM) {
- const NodeEnum& enm = *input.enum_values;
- if(enm.exists(value)) {
- get_socket_value<int>(this, input) = enm[value];
- }
- else {
- assert(0);
- }
- }
- else {
- assert(0);
- }
+ if (input.type == SocketType::STRING) {
+ get_socket_value<ustring>(this, input) = value;
+ }
+ else if (input.type == SocketType::ENUM) {
+ const NodeEnum &enm = *input.enum_values;
+ if (enm.exists(value)) {
+ get_socket_value<int>(this, input) = enm[value];
+ }
+ else {
+ assert(0);
+ }
+ }
+ else {
+ assert(0);
+ }
}
-void Node::set(const SocketType& input, const Transform& value)
+void Node::set(const SocketType &input, const Transform &value)
{
- assert(input.type == SocketType::TRANSFORM);
- get_socket_value<Transform>(this, input) = value;
+ assert(input.type == SocketType::TRANSFORM);
+ get_socket_value<Transform>(this, input) = value;
}
-void Node::set(const SocketType& input, Node *value)
+void Node::set(const SocketType &input, Node *value)
{
- assert(input.type == SocketType::TRANSFORM);
- get_socket_value<Node*>(this, input) = value;
+ assert(input.type == SocketType::TRANSFORM);
+ get_socket_value<Node *>(this, input) = value;
}
/* set array values */
-void Node::set(const SocketType& input, array<bool>& value)
+void Node::set(const SocketType &input, array<bool> &value)
{
- assert(input.type == SocketType::BOOLEAN_ARRAY);
- get_socket_value<array<bool> >(this, input).steal_data(value);
+ assert(input.type == SocketType::BOOLEAN_ARRAY);
+ get_socket_value<array<bool>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<int>& value)
+void Node::set(const SocketType &input, array<int> &value)
{
- assert(input.type == SocketType::INT_ARRAY);
- get_socket_value<array<int> >(this, input).steal_data(value);
+ assert(input.type == SocketType::INT_ARRAY);
+ get_socket_value<array<int>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<float>& value)
+void Node::set(const SocketType &input, array<float> &value)
{
- assert(input.type == SocketType::FLOAT_ARRAY);
- get_socket_value<array<float> >(this, input).steal_data(value);
+ assert(input.type == SocketType::FLOAT_ARRAY);
+ get_socket_value<array<float>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<float2>& value)
+void Node::set(const SocketType &input, array<float2> &value)
{
- assert(input.type == SocketType::FLOAT_ARRAY);
- get_socket_value<array<float2> >(this, input).steal_data(value);
+ assert(input.type == SocketType::FLOAT_ARRAY);
+ get_socket_value<array<float2>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<float3>& value)
+void Node::set(const SocketType &input, array<float3> &value)
{
- assert(is_socket_array_float3(input));
- get_socket_value<array<float3> >(this, input).steal_data(value);
+ assert(is_socket_array_float3(input));
+ get_socket_value<array<float3>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<ustring>& value)
+void Node::set(const SocketType &input, array<ustring> &value)
{
- assert(input.type == SocketType::STRING_ARRAY);
- get_socket_value<array<ustring> >(this, input).steal_data(value);
+ assert(input.type == SocketType::STRING_ARRAY);
+ get_socket_value<array<ustring>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<Transform>& value)
+void Node::set(const SocketType &input, array<Transform> &value)
{
- assert(input.type == SocketType::TRANSFORM_ARRAY);
- get_socket_value<array<Transform> >(this, input).steal_data(value);
+ assert(input.type == SocketType::TRANSFORM_ARRAY);
+ get_socket_value<array<Transform>>(this, input).steal_data(value);
}
-void Node::set(const SocketType& input, array<Node*>& value)
+void Node::set(const SocketType &input, array<Node *> &value)
{
- assert(input.type == SocketType::TRANSFORM_ARRAY);
- get_socket_value<array<Node*> >(this, input).steal_data(value);
+ assert(input.type == SocketType::TRANSFORM_ARRAY);
+ get_socket_value<array<Node *>>(this, input).steal_data(value);
}
/* get values */
-bool Node::get_bool(const SocketType& input) const
+bool Node::get_bool(const SocketType &input) const
{
- assert(input.type == SocketType::BOOLEAN);
- return get_socket_value<bool>(this, input);
+ assert(input.type == SocketType::BOOLEAN);
+ return get_socket_value<bool>(this, input);
}
-int Node::get_int(const SocketType& input) const
+int Node::get_int(const SocketType &input) const
{
- assert(input.type == SocketType::INT || input.type == SocketType::ENUM);
- return get_socket_value<int>(this, input);
+ assert(input.type == SocketType::INT || input.type == SocketType::ENUM);
+ return get_socket_value<int>(this, input);
}
-uint Node::get_uint(const SocketType& input) const
+uint Node::get_uint(const SocketType &input) const
{
- assert(input.type == SocketType::UINT);
- return get_socket_value<uint>(this, input);
+ assert(input.type == SocketType::UINT);
+ return get_socket_value<uint>(this, input);
}
-float Node::get_float(const SocketType& input) const
+float Node::get_float(const SocketType &input) const
{
- assert(input.type == SocketType::FLOAT);
- return get_socket_value<float>(this, input);
+ assert(input.type == SocketType::FLOAT);
+ return get_socket_value<float>(this, input);
}
-float2 Node::get_float2(const SocketType& input) const
+float2 Node::get_float2(const SocketType &input) const
{
- assert(input.type == SocketType::FLOAT);
- return get_socket_value<float2>(this, input);
+ assert(input.type == SocketType::FLOAT);
+ return get_socket_value<float2>(this, input);
}
-float3 Node::get_float3(const SocketType& input) const
+float3 Node::get_float3(const SocketType &input) const
{
- assert(is_socket_float3(input));
- return get_socket_value<float3>(this, input);
+ assert(is_socket_float3(input));
+ return get_socket_value<float3>(this, input);
}
-ustring Node::get_string(const SocketType& input) const
+ustring Node::get_string(const SocketType &input) const
{
- if(input.type == SocketType::STRING) {
- return get_socket_value<ustring>(this, input);
- }
- else if(input.type == SocketType::ENUM) {
- const NodeEnum& enm = *input.enum_values;
- int intvalue = get_socket_value<int>(this, input);
- return (enm.exists(intvalue)) ? enm[intvalue] : ustring();
- }
- else {
- assert(0);
- return ustring();
- }
+ if (input.type == SocketType::STRING) {
+ return get_socket_value<ustring>(this, input);
+ }
+ else if (input.type == SocketType::ENUM) {
+ const NodeEnum &enm = *input.enum_values;
+ int intvalue = get_socket_value<int>(this, input);
+ return (enm.exists(intvalue)) ? enm[intvalue] : ustring();
+ }
+ else {
+ assert(0);
+ return ustring();
+ }
}
-Transform Node::get_transform(const SocketType& input) const
+Transform Node::get_transform(const SocketType &input) const
{
- assert(input.type == SocketType::TRANSFORM);
- return get_socket_value<Transform>(this, input);
+ assert(input.type == SocketType::TRANSFORM);
+ return get_socket_value<Transform>(this, input);
}
-Node *Node::get_node(const SocketType& input) const
+Node *Node::get_node(const SocketType &input) const
{
- assert(input.type == SocketType::NODE);
- return get_socket_value<Node*>(this, input);
+ assert(input.type == SocketType::NODE);
+ return get_socket_value<Node *>(this, input);
}
/* get array values */
-const array<bool>& Node::get_bool_array(const SocketType& input) const
+const array<bool> &Node::get_bool_array(const SocketType &input) const
{
- assert(input.type == SocketType::BOOLEAN_ARRAY);
- return get_socket_value<array<bool> >(this, input);
+ assert(input.type == SocketType::BOOLEAN_ARRAY);
+ return get_socket_value<array<bool>>(this, input);
}
-const array<int>& Node::get_int_array(const SocketType& input) const
+const array<int> &Node::get_int_array(const SocketType &input) const
{
- assert(input.type == SocketType::INT_ARRAY);
- return get_socket_value<array<int> >(this, input);
+ assert(input.type == SocketType::INT_ARRAY);
+ return get_socket_value<array<int>>(this, input);
}
-const array<float>& Node::get_float_array(const SocketType& input) const
+const array<float> &Node::get_float_array(const SocketType &input) const
{
- assert(input.type == SocketType::FLOAT_ARRAY);
- return get_socket_value<array<float> >(this, input);
+ assert(input.type == SocketType::FLOAT_ARRAY);
+ return get_socket_value<array<float>>(this, input);
}
-const array<float2>& Node::get_float2_array(const SocketType& input) const
+const array<float2> &Node::get_float2_array(const SocketType &input) const
{
- assert(input.type == SocketType::FLOAT_ARRAY);
- return get_socket_value<array<float2> >(this, input);
+ assert(input.type == SocketType::FLOAT_ARRAY);
+ return get_socket_value<array<float2>>(this, input);
}
-const array<float3>& Node::get_float3_array(const SocketType& input) const
+const array<float3> &Node::get_float3_array(const SocketType &input) const
{
- assert(is_socket_array_float3(input));
- return get_socket_value<array<float3> >(this, input);
+ assert(is_socket_array_float3(input));
+ return get_socket_value<array<float3>>(this, input);
}
-const array<ustring>& Node::get_string_array(const SocketType& input) const
+const array<ustring> &Node::get_string_array(const SocketType &input) const
{
- assert(input.type == SocketType::STRING_ARRAY);
- return get_socket_value<array<ustring> >(this, input);
+ assert(input.type == SocketType::STRING_ARRAY);
+ return get_socket_value<array<ustring>>(this, input);
}
-const array<Transform>& Node::get_transform_array(const SocketType& input) const
+const array<Transform> &Node::get_transform_array(const SocketType &input) const
{
- assert(input.type == SocketType::TRANSFORM_ARRAY);
- return get_socket_value<array<Transform> >(this, input);
+ assert(input.type == SocketType::TRANSFORM_ARRAY);
+ return get_socket_value<array<Transform>>(this, input);
}
-const array<Node*>& Node::get_node_array(const SocketType& input) const
+const array<Node *> &Node::get_node_array(const SocketType &input) const
{
- assert(input.type == SocketType::NODE_ARRAY);
- return get_socket_value<array<Node*> >(this, input);
+ assert(input.type == SocketType::NODE_ARRAY);
+ return get_socket_value<array<Node *>>(this, input);
}
/* generic value operations */
-bool Node::has_default_value(const SocketType& input) const
+bool Node::has_default_value(const SocketType &input) const
{
- const void *src = input.default_value;
- void *dst = &get_socket_value<char>(this, input);
- return memcmp(dst, src, input.size()) == 0;
+ const void *src = input.default_value;
+ void *dst = &get_socket_value<char>(this, input);
+ return memcmp(dst, src, input.size()) == 0;
}
-void Node::set_default_value(const SocketType& socket)
+void Node::set_default_value(const SocketType &socket)
{
- const void *src = socket.default_value;
- void *dst = ((char*)this) + socket.struct_offset;
- memcpy(dst, src, socket.size());
+ const void *src = socket.default_value;
+ void *dst = ((char *)this) + socket.struct_offset;
+ memcpy(dst, src, socket.size());
}
template<typename T>
-static void copy_array(const Node *node, const SocketType& socket, const Node *other, const SocketType& other_socket)
-{
- const array<T>* src = (const array<T>*)(((char*)other) + other_socket.struct_offset);
- array<T>* dst = (array<T>*)(((char*)node) + socket.struct_offset);
- *dst = *src;
-}
-
-void Node::copy_value(const SocketType& socket, const Node& other, const SocketType& other_socket)
-{
- assert(socket.type == other_socket.type);
-
- if(socket.is_array()) {
- switch(socket.type) {
- case SocketType::BOOLEAN_ARRAY: copy_array<bool>(this, socket, &other, other_socket); break;
- case SocketType::FLOAT_ARRAY: copy_array<float>(this, socket, &other, other_socket); break;
- case SocketType::INT_ARRAY: copy_array<int>(this, socket, &other, other_socket); break;
- case SocketType::COLOR_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
- case SocketType::VECTOR_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
- case SocketType::POINT_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
- case SocketType::NORMAL_ARRAY: copy_array<float3>(this, socket, &other, other_socket); break;
- case SocketType::POINT2_ARRAY: copy_array<float2>(this, socket, &other, other_socket); break;
- case SocketType::STRING_ARRAY: copy_array<ustring>(this, socket, &other, other_socket); break;
- case SocketType::TRANSFORM_ARRAY: copy_array<Transform>(this, socket, &other, other_socket); break;
- case SocketType::NODE_ARRAY: copy_array<void*>(this, socket, &other, other_socket); break;
- default: assert(0); break;
- }
- }
- else {
- const void *src = ((char*)&other) + other_socket.struct_offset;
- void *dst = ((char*)this) + socket.struct_offset;
- memcpy(dst, src, socket.size());
- }
+static void copy_array(const Node *node,
+ const SocketType &socket,
+ const Node *other,
+ const SocketType &other_socket)
+{
+ const array<T> *src = (const array<T> *)(((char *)other) + other_socket.struct_offset);
+ array<T> *dst = (array<T> *)(((char *)node) + socket.struct_offset);
+ *dst = *src;
+}
+
+void Node::copy_value(const SocketType &socket, const Node &other, const SocketType &other_socket)
+{
+ assert(socket.type == other_socket.type);
+
+ if (socket.is_array()) {
+ switch (socket.type) {
+ case SocketType::BOOLEAN_ARRAY:
+ copy_array<bool>(this, socket, &other, other_socket);
+ break;
+ case SocketType::FLOAT_ARRAY:
+ copy_array<float>(this, socket, &other, other_socket);
+ break;
+ case SocketType::INT_ARRAY:
+ copy_array<int>(this, socket, &other, other_socket);
+ break;
+ case SocketType::COLOR_ARRAY:
+ copy_array<float3>(this, socket, &other, other_socket);
+ break;
+ case SocketType::VECTOR_ARRAY:
+ copy_array<float3>(this, socket, &other, other_socket);
+ break;
+ case SocketType::POINT_ARRAY:
+ copy_array<float3>(this, socket, &other, other_socket);
+ break;
+ case SocketType::NORMAL_ARRAY:
+ copy_array<float3>(this, socket, &other, other_socket);
+ break;
+ case SocketType::POINT2_ARRAY:
+ copy_array<float2>(this, socket, &other, other_socket);
+ break;
+ case SocketType::STRING_ARRAY:
+ copy_array<ustring>(this, socket, &other, other_socket);
+ break;
+ case SocketType::TRANSFORM_ARRAY:
+ copy_array<Transform>(this, socket, &other, other_socket);
+ break;
+ case SocketType::NODE_ARRAY:
+ copy_array<void *>(this, socket, &other, other_socket);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ }
+ else {
+ const void *src = ((char *)&other) + other_socket.struct_offset;
+ void *dst = ((char *)this) + socket.struct_offset;
+ memcpy(dst, src, socket.size());
+ }
}
template<typename T>
-static bool is_array_equal(const Node *node, const Node *other, const SocketType& socket)
+static bool is_array_equal(const Node *node, const Node *other, const SocketType &socket)
{
- const array<T>* a = (const array<T>*)(((char*)node) + socket.struct_offset);
- const array<T>* b = (const array<T>*)(((char*)other) + socket.struct_offset);
- return *a == *b;
+ const array<T> *a = (const array<T> *)(((char *)node) + socket.struct_offset);
+ const array<T> *b = (const array<T> *)(((char *)other) + socket.struct_offset);
+ return *a == *b;
}
template<typename T>
-static bool is_value_equal(const Node *node, const Node *other, const SocketType& socket)
-{
- const T *a = (const T*)(((char*)node) + socket.struct_offset);
- const T *b = (const T*)(((char*)other) + socket.struct_offset);
- return *a == *b;
-}
-
-bool Node::equals_value(const Node& other, const SocketType& socket) const
-{
- switch(socket.type) {
- case SocketType::BOOLEAN: return is_value_equal<bool>(this, &other, socket);
- case SocketType::FLOAT: return is_value_equal<float>(this, &other, socket);
- case SocketType::INT: return is_value_equal<int>(this, &other, socket);
- case SocketType::UINT: return is_value_equal<uint>(this, &other, socket);
- case SocketType::COLOR: return is_value_equal<float3>(this, &other, socket);
- case SocketType::VECTOR: return is_value_equal<float3>(this, &other, socket);
- case SocketType::POINT: return is_value_equal<float3>(this, &other, socket);
- case SocketType::NORMAL: return is_value_equal<float3>(this, &other, socket);
- case SocketType::POINT2: return is_value_equal<float2>(this, &other, socket);
- case SocketType::CLOSURE: return true;
- case SocketType::STRING: return is_value_equal<ustring>(this, &other, socket);
- case SocketType::ENUM: return is_value_equal<int>(this, &other, socket);
- case SocketType::TRANSFORM: return is_value_equal<Transform>(this, &other, socket);
- case SocketType::NODE: return is_value_equal<void*>(this, &other, socket);
-
- case SocketType::BOOLEAN_ARRAY: return is_array_equal<bool>(this, &other, socket);
- case SocketType::FLOAT_ARRAY: return is_array_equal<float>(this, &other, socket);
- case SocketType::INT_ARRAY: return is_array_equal<int>(this, &other, socket);
- case SocketType::COLOR_ARRAY: return is_array_equal<float3>(this, &other, socket);
- case SocketType::VECTOR_ARRAY: return is_array_equal<float3>(this, &other, socket);
- case SocketType::POINT_ARRAY: return is_array_equal<float3>(this, &other, socket);
- case SocketType::NORMAL_ARRAY: return is_array_equal<float3>(this, &other, socket);
- case SocketType::POINT2_ARRAY: return is_array_equal<float2>(this, &other, socket);
- case SocketType::STRING_ARRAY: return is_array_equal<ustring>(this, &other, socket);
- case SocketType::TRANSFORM_ARRAY: return is_array_equal<Transform>(this, &other, socket);
- case SocketType::NODE_ARRAY: return is_array_equal<void*>(this, &other, socket);
-
- case SocketType::UNDEFINED: return true;
- }
-
- return true;
+static bool is_value_equal(const Node *node, const Node *other, const SocketType &socket)
+{
+ const T *a = (const T *)(((char *)node) + socket.struct_offset);
+ const T *b = (const T *)(((char *)other) + socket.struct_offset);
+ return *a == *b;
+}
+
+bool Node::equals_value(const Node &other, const SocketType &socket) const
+{
+ switch (socket.type) {
+ case SocketType::BOOLEAN:
+ return is_value_equal<bool>(this, &other, socket);
+ case SocketType::FLOAT:
+ return is_value_equal<float>(this, &other, socket);
+ case SocketType::INT:
+ return is_value_equal<int>(this, &other, socket);
+ case SocketType::UINT:
+ return is_value_equal<uint>(this, &other, socket);
+ case SocketType::COLOR:
+ return is_value_equal<float3>(this, &other, socket);
+ case SocketType::VECTOR:
+ return is_value_equal<float3>(this, &other, socket);
+ case SocketType::POINT:
+ return is_value_equal<float3>(this, &other, socket);
+ case SocketType::NORMAL:
+ return is_value_equal<float3>(this, &other, socket);
+ case SocketType::POINT2:
+ return is_value_equal<float2>(this, &other, socket);
+ case SocketType::CLOSURE:
+ return true;
+ case SocketType::STRING:
+ return is_value_equal<ustring>(this, &other, socket);
+ case SocketType::ENUM:
+ return is_value_equal<int>(this, &other, socket);
+ case SocketType::TRANSFORM:
+ return is_value_equal<Transform>(this, &other, socket);
+ case SocketType::NODE:
+ return is_value_equal<void *>(this, &other, socket);
+
+ case SocketType::BOOLEAN_ARRAY:
+ return is_array_equal<bool>(this, &other, socket);
+ case SocketType::FLOAT_ARRAY:
+ return is_array_equal<float>(this, &other, socket);
+ case SocketType::INT_ARRAY:
+ return is_array_equal<int>(this, &other, socket);
+ case SocketType::COLOR_ARRAY:
+ return is_array_equal<float3>(this, &other, socket);
+ case SocketType::VECTOR_ARRAY:
+ return is_array_equal<float3>(this, &other, socket);
+ case SocketType::POINT_ARRAY:
+ return is_array_equal<float3>(this, &other, socket);
+ case SocketType::NORMAL_ARRAY:
+ return is_array_equal<float3>(this, &other, socket);
+ case SocketType::POINT2_ARRAY:
+ return is_array_equal<float2>(this, &other, socket);
+ case SocketType::STRING_ARRAY:
+ return is_array_equal<ustring>(this, &other, socket);
+ case SocketType::TRANSFORM_ARRAY:
+ return is_array_equal<Transform>(this, &other, socket);
+ case SocketType::NODE_ARRAY:
+ return is_array_equal<void *>(this, &other, socket);
+
+ case SocketType::UNDEFINED:
+ return true;
+ }
+
+ return true;
}
/* equals */
-bool Node::equals(const Node& other) const
+bool Node::equals(const Node &other) const
{
- assert(type == other.type);
+ assert(type == other.type);
- foreach(const SocketType& socket, type->inputs) {
- if(!equals_value(other, socket))
- return false;
- }
+ foreach (const SocketType &socket, type->inputs) {
+ if (!equals_value(other, socket))
+ return false;
+ }
- return true;
+ return true;
}
/* Hash */
namespace {
-template<typename T>
-void value_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
+template<typename T> void value_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
{
- md5.append(((uint8_t*)node) + socket.struct_offset, socket.size());
+ md5.append(((uint8_t *)node) + socket.struct_offset, socket.size());
}
-void float3_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
+void float3_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
{
- /* Don't compare 4th element used for padding. */
- md5.append(((uint8_t*)node) + socket.struct_offset, sizeof(float) * 3);
+ /* Don't compare 4th element used for padding. */
+ md5.append(((uint8_t *)node) + socket.struct_offset, sizeof(float) * 3);
}
-template<typename T>
-void array_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
+template<typename T> void array_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
{
- const array<T>& a = *(const array<T>*)(((char*)node) + socket.struct_offset);
- for(size_t i = 0; i < a.size(); i++) {
- md5.append((uint8_t*)&a[i], sizeof(T));
- }
+ const array<T> &a = *(const array<T> *)(((char *)node) + socket.struct_offset);
+ for (size_t i = 0; i < a.size(); i++) {
+ md5.append((uint8_t *)&a[i], sizeof(T));
+ }
}
-void float3_array_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
+void float3_array_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
{
- /* Don't compare 4th element used for padding. */
- const array<float3>& a = *(const array<float3>*)(((char*)node) + socket.struct_offset);
- for(size_t i = 0; i < a.size(); i++) {
- md5.append((uint8_t*)&a[i], sizeof(float) * 3);
- }
+ /* Don't compare 4th element used for padding. */
+ const array<float3> &a = *(const array<float3> *)(((char *)node) + socket.struct_offset);
+ for (size_t i = 0; i < a.size(); i++) {
+ md5.append((uint8_t *)&a[i], sizeof(float) * 3);
+ }
}
} // namespace
-void Node::hash(MD5Hash& md5)
-{
- md5.append(type->name.string());
-
- foreach(const SocketType& socket, type->inputs) {
- md5.append(socket.name.string());
-
- switch(socket.type) {
- case SocketType::BOOLEAN: value_hash<bool>(this, socket, md5); break;
- case SocketType::FLOAT: value_hash<float>(this, socket, md5); break;
- case SocketType::INT: value_hash<int>(this, socket, md5); break;
- case SocketType::UINT: value_hash<uint>(this, socket, md5); break;
- case SocketType::COLOR: float3_hash(this, socket, md5); break;
- case SocketType::VECTOR: float3_hash(this, socket, md5); break;
- case SocketType::POINT: float3_hash(this, socket, md5); break;
- case SocketType::NORMAL: float3_hash(this, socket, md5); break;
- case SocketType::POINT2: value_hash<float2>(this, socket, md5); break;
- case SocketType::CLOSURE: break;
- case SocketType::STRING: value_hash<ustring>(this, socket, md5); break;
- case SocketType::ENUM: value_hash<int>(this, socket, md5); break;
- case SocketType::TRANSFORM: value_hash<Transform>(this, socket, md5); break;
- case SocketType::NODE: value_hash<void*>(this, socket, md5); break;
-
- case SocketType::BOOLEAN_ARRAY: array_hash<bool>(this, socket, md5); break;
- case SocketType::FLOAT_ARRAY: array_hash<float>(this, socket, md5); break;
- case SocketType::INT_ARRAY: array_hash<int>(this, socket, md5); break;
- case SocketType::COLOR_ARRAY: float3_array_hash(this, socket, md5); break;
- case SocketType::VECTOR_ARRAY: float3_array_hash(this, socket, md5); break;
- case SocketType::POINT_ARRAY: float3_array_hash(this, socket, md5); break;
- case SocketType::NORMAL_ARRAY: float3_array_hash(this, socket, md5); break;
- case SocketType::POINT2_ARRAY: array_hash<float2>(this, socket, md5); break;
- case SocketType::STRING_ARRAY: array_hash<ustring>(this, socket, md5); break;
- case SocketType::TRANSFORM_ARRAY: array_hash<Transform>(this, socket, md5); break;
- case SocketType::NODE_ARRAY: array_hash<void*>(this, socket, md5); break;
-
- case SocketType::UNDEFINED: break;
- }
- }
+void Node::hash(MD5Hash &md5)
+{
+ md5.append(type->name.string());
+
+ foreach (const SocketType &socket, type->inputs) {
+ md5.append(socket.name.string());
+
+ switch (socket.type) {
+ case SocketType::BOOLEAN:
+ value_hash<bool>(this, socket, md5);
+ break;
+ case SocketType::FLOAT:
+ value_hash<float>(this, socket, md5);
+ break;
+ case SocketType::INT:
+ value_hash<int>(this, socket, md5);
+ break;
+ case SocketType::UINT:
+ value_hash<uint>(this, socket, md5);
+ break;
+ case SocketType::COLOR:
+ float3_hash(this, socket, md5);
+ break;
+ case SocketType::VECTOR:
+ float3_hash(this, socket, md5);
+ break;
+ case SocketType::POINT:
+ float3_hash(this, socket, md5);
+ break;
+ case SocketType::NORMAL:
+ float3_hash(this, socket, md5);
+ break;
+ case SocketType::POINT2:
+ value_hash<float2>(this, socket, md5);
+ break;
+ case SocketType::CLOSURE:
+ break;
+ case SocketType::STRING:
+ value_hash<ustring>(this, socket, md5);
+ break;
+ case SocketType::ENUM:
+ value_hash<int>(this, socket, md5);
+ break;
+ case SocketType::TRANSFORM:
+ value_hash<Transform>(this, socket, md5);
+ break;
+ case SocketType::NODE:
+ value_hash<void *>(this, socket, md5);
+ break;
+
+ case SocketType::BOOLEAN_ARRAY:
+ array_hash<bool>(this, socket, md5);
+ break;
+ case SocketType::FLOAT_ARRAY:
+ array_hash<float>(this, socket, md5);
+ break;
+ case SocketType::INT_ARRAY:
+ array_hash<int>(this, socket, md5);
+ break;
+ case SocketType::COLOR_ARRAY:
+ float3_array_hash(this, socket, md5);
+ break;
+ case SocketType::VECTOR_ARRAY:
+ float3_array_hash(this, socket, md5);
+ break;
+ case SocketType::POINT_ARRAY:
+ float3_array_hash(this, socket, md5);
+ break;
+ case SocketType::NORMAL_ARRAY:
+ float3_array_hash(this, socket, md5);
+ break;
+ case SocketType::POINT2_ARRAY:
+ array_hash<float2>(this, socket, md5);
+ break;
+ case SocketType::STRING_ARRAY:
+ array_hash<ustring>(this, socket, md5);
+ break;
+ case SocketType::TRANSFORM_ARRAY:
+ array_hash<Transform>(this, socket, md5);
+ break;
+ case SocketType::NODE_ARRAY:
+ array_hash<void *>(this, socket, md5);
+ break;
+
+ case SocketType::UNDEFINED:
+ break;
+ }
+ }
}
namespace {
-template<typename T>
-size_t array_size_in_bytes(const Node *node, const SocketType& socket)
+template<typename T> size_t array_size_in_bytes(const Node *node, const SocketType &socket)
{
- const array<T>& a = *(const array<T>*)(((char*)node) + socket.struct_offset);
- return a.size() * sizeof(T);
+ const array<T> &a = *(const array<T> *)(((char *)node) + socket.struct_offset);
+ return a.size() * sizeof(T);
}
} // namespace
size_t Node::get_total_size_in_bytes() const
{
- size_t total_size = 0;
- foreach(const SocketType& socket, type->inputs) {
- switch(socket.type) {
- case SocketType::BOOLEAN:
- case SocketType::FLOAT:
- case SocketType::INT:
- case SocketType::UINT:
- case SocketType::COLOR:
- case SocketType::VECTOR:
- case SocketType::POINT:
- case SocketType::NORMAL:
- case SocketType::POINT2:
- case SocketType::CLOSURE:
- case SocketType::STRING:
- case SocketType::ENUM:
- case SocketType::TRANSFORM:
- case SocketType::NODE:
- total_size += socket.size();
- break;
-
- case SocketType::BOOLEAN_ARRAY:
- total_size += array_size_in_bytes<bool>(this, socket);
- break;
- case SocketType::FLOAT_ARRAY:
- total_size += array_size_in_bytes<float>(this, socket);
- break;
- case SocketType::INT_ARRAY:
- total_size += array_size_in_bytes<int>(this, socket);
- break;
- case SocketType::COLOR_ARRAY:
- total_size += array_size_in_bytes<float3>(this, socket);
- break;
- case SocketType::VECTOR_ARRAY:
- total_size += array_size_in_bytes<float3>(this, socket);
- break;
- case SocketType::POINT_ARRAY:
- total_size += array_size_in_bytes<float3>(this, socket);
- break;
- case SocketType::NORMAL_ARRAY:
- total_size += array_size_in_bytes<float3>(this, socket);
- break;
- case SocketType::POINT2_ARRAY:
- total_size += array_size_in_bytes<float2>(this, socket);
- break;
- case SocketType::STRING_ARRAY:
- total_size += array_size_in_bytes<ustring>(this, socket);
- break;
- case SocketType::TRANSFORM_ARRAY:
- total_size += array_size_in_bytes<Transform>(this, socket);
- break;
- case SocketType::NODE_ARRAY:
- total_size += array_size_in_bytes<void*>(this, socket);
- break;
-
- case SocketType::UNDEFINED: break;
- }
- }
- return total_size;
+ size_t total_size = 0;
+ foreach (const SocketType &socket, type->inputs) {
+ switch (socket.type) {
+ case SocketType::BOOLEAN:
+ case SocketType::FLOAT:
+ case SocketType::INT:
+ case SocketType::UINT:
+ case SocketType::COLOR:
+ case SocketType::VECTOR:
+ case SocketType::POINT:
+ case SocketType::NORMAL:
+ case SocketType::POINT2:
+ case SocketType::CLOSURE:
+ case SocketType::STRING:
+ case SocketType::ENUM:
+ case SocketType::TRANSFORM:
+ case SocketType::NODE:
+ total_size += socket.size();
+ break;
+
+ case SocketType::BOOLEAN_ARRAY:
+ total_size += array_size_in_bytes<bool>(this, socket);
+ break;
+ case SocketType::FLOAT_ARRAY:
+ total_size += array_size_in_bytes<float>(this, socket);
+ break;
+ case SocketType::INT_ARRAY:
+ total_size += array_size_in_bytes<int>(this, socket);
+ break;
+ case SocketType::COLOR_ARRAY:
+ total_size += array_size_in_bytes<float3>(this, socket);
+ break;
+ case SocketType::VECTOR_ARRAY:
+ total_size += array_size_in_bytes<float3>(this, socket);
+ break;
+ case SocketType::POINT_ARRAY:
+ total_size += array_size_in_bytes<float3>(this, socket);
+ break;
+ case SocketType::NORMAL_ARRAY:
+ total_size += array_size_in_bytes<float3>(this, socket);
+ break;
+ case SocketType::POINT2_ARRAY:
+ total_size += array_size_in_bytes<float2>(this, socket);
+ break;
+ case SocketType::STRING_ARRAY:
+ total_size += array_size_in_bytes<ustring>(this, socket);
+ break;
+ case SocketType::TRANSFORM_ARRAY:
+ total_size += array_size_in_bytes<Transform>(this, socket);
+ break;
+ case SocketType::NODE_ARRAY:
+ total_size += array_size_in_bytes<void *>(this, socket);
+ break;
+
+ case SocketType::UNDEFINED:
+ break;
+ }
+ }
+ return total_size;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h
index d50a3786139..226c49b387a 100644
--- a/intern/cycles/graph/node.h
+++ b/intern/cycles/graph/node.h
@@ -31,72 +31,71 @@ struct Transform;
/* Node */
-struct Node
-{
- explicit Node(const NodeType *type, ustring name = ustring());
- virtual ~Node();
-
- /* set values */
- void set(const SocketType& input, bool value);
- void set(const SocketType& input, int value);
- void set(const SocketType& input, uint value);
- void set(const SocketType& input, float value);
- void set(const SocketType& input, float2 value);
- void set(const SocketType& input, float3 value);
- void set(const SocketType& input, const char *value);
- void set(const SocketType& input, ustring value);
- void set(const SocketType& input, const Transform& value);
- void set(const SocketType& input, Node *value);
-
- /* set array values. the memory from the input array will taken over
- * by the node and the input array will be empty after return */
- void set(const SocketType& input, array<bool>& value);
- void set(const SocketType& input, array<int>& value);
- void set(const SocketType& input, array<float>& value);
- void set(const SocketType& input, array<float2>& value);
- void set(const SocketType& input, array<float3>& value);
- void set(const SocketType& input, array<ustring>& value);
- void set(const SocketType& input, array<Transform>& value);
- void set(const SocketType& input, array<Node*>& value);
-
- /* get values */
- bool get_bool(const SocketType& input) const;
- int get_int(const SocketType& input) const;
- uint get_uint(const SocketType& input) const;
- float get_float(const SocketType& input) const;
- float2 get_float2(const SocketType& input) const;
- float3 get_float3(const SocketType& input) const;
- ustring get_string(const SocketType& input) const;
- Transform get_transform(const SocketType& input) const;
- Node *get_node(const SocketType& input) const;
-
- /* get array values */
- const array<bool>& get_bool_array(const SocketType& input) const;
- const array<int>& get_int_array(const SocketType& input) const;
- const array<float>& get_float_array(const SocketType& input) const;
- const array<float2>& get_float2_array(const SocketType& input) const;
- const array<float3>& get_float3_array(const SocketType& input) const;
- const array<ustring>& get_string_array(const SocketType& input) const;
- const array<Transform>& get_transform_array(const SocketType& input) const;
- const array<Node*>& get_node_array(const SocketType& input) const;
-
- /* generic values operations */
- bool has_default_value(const SocketType& input) const;
- void set_default_value(const SocketType& input);
- bool equals_value(const Node& other, const SocketType& input) const;
- void copy_value(const SocketType& input, const Node& other, const SocketType& other_input);
-
- /* equals */
- bool equals(const Node& other) const;
-
- /* compute hash of node and its socket values */
- void hash(MD5Hash& md5);
-
- /* Get total size of this node. */
- size_t get_total_size_in_bytes() const;
-
- ustring name;
- const NodeType *type;
+struct Node {
+ explicit Node(const NodeType *type, ustring name = ustring());
+ virtual ~Node();
+
+ /* set values */
+ void set(const SocketType &input, bool value);
+ void set(const SocketType &input, int value);
+ void set(const SocketType &input, uint value);
+ void set(const SocketType &input, float value);
+ void set(const SocketType &input, float2 value);
+ void set(const SocketType &input, float3 value);
+ void set(const SocketType &input, const char *value);
+ void set(const SocketType &input, ustring value);
+ void set(const SocketType &input, const Transform &value);
+ void set(const SocketType &input, Node *value);
+
+ /* set array values. the memory from the input array will taken over
+ * by the node and the input array will be empty after return */
+ void set(const SocketType &input, array<bool> &value);
+ void set(const SocketType &input, array<int> &value);
+ void set(const SocketType &input, array<float> &value);
+ void set(const SocketType &input, array<float2> &value);
+ void set(const SocketType &input, array<float3> &value);
+ void set(const SocketType &input, array<ustring> &value);
+ void set(const SocketType &input, array<Transform> &value);
+ void set(const SocketType &input, array<Node *> &value);
+
+ /* get values */
+ bool get_bool(const SocketType &input) const;
+ int get_int(const SocketType &input) const;
+ uint get_uint(const SocketType &input) const;
+ float get_float(const SocketType &input) const;
+ float2 get_float2(const SocketType &input) const;
+ float3 get_float3(const SocketType &input) const;
+ ustring get_string(const SocketType &input) const;
+ Transform get_transform(const SocketType &input) const;
+ Node *get_node(const SocketType &input) const;
+
+ /* get array values */
+ const array<bool> &get_bool_array(const SocketType &input) const;
+ const array<int> &get_int_array(const SocketType &input) const;
+ const array<float> &get_float_array(const SocketType &input) const;
+ const array<float2> &get_float2_array(const SocketType &input) const;
+ const array<float3> &get_float3_array(const SocketType &input) const;
+ const array<ustring> &get_string_array(const SocketType &input) const;
+ const array<Transform> &get_transform_array(const SocketType &input) const;
+ const array<Node *> &get_node_array(const SocketType &input) const;
+
+ /* generic values operations */
+ bool has_default_value(const SocketType &input) const;
+ void set_default_value(const SocketType &input);
+ bool equals_value(const Node &other, const SocketType &input) const;
+ void copy_value(const SocketType &input, const Node &other, const SocketType &other_input);
+
+ /* equals */
+ bool equals(const Node &other) const;
+
+ /* compute hash of node and its socket values */
+ void hash(MD5Hash &md5);
+
+ /* Get total size of this node. */
+ size_t get_total_size_in_bytes() const;
+
+ ustring name;
+ const NodeType *type;
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/graph/node_enum.h b/intern/cycles/graph/node_enum.h
index 705aec9a918..d3ed0928a4f 100644
--- a/intern/cycles/graph/node_enum.h
+++ b/intern/cycles/graph/node_enum.h
@@ -26,25 +26,50 @@ CCL_NAMESPACE_BEGIN
* Utility class for enum values. */
struct NodeEnum {
- bool empty() const { return left.empty(); }
- void insert(const char *x, int y) {
- left[ustring(x)] = y;
- right[y] = ustring(x);
- }
+ bool empty() const
+ {
+ return left.empty();
+ }
+ void insert(const char *x, int y)
+ {
+ left[ustring(x)] = y;
+ right[y] = ustring(x);
+ }
- bool exists(ustring x) const { return left.find(x) != left.end(); }
- bool exists(int y) const { return right.find(y) != right.end(); }
+ bool exists(ustring x) const
+ {
+ return left.find(x) != left.end();
+ }
+ bool exists(int y) const
+ {
+ return right.find(y) != right.end();
+ }
- int operator[](const char *x) const { return left.find(ustring(x))->second; }
- int operator[](ustring x) const { return left.find(x)->second; }
- ustring operator[](int y) const { return right.find(y)->second; }
+ int operator[](const char *x) const
+ {
+ return left.find(ustring(x))->second;
+ }
+ int operator[](ustring x) const
+ {
+ return left.find(x)->second;
+ }
+ ustring operator[](int y) const
+ {
+ return right.find(y)->second;
+ }
- unordered_map<ustring, int, ustringHash>::const_iterator begin() const { return left.begin(); }
- unordered_map<ustring, int, ustringHash>::const_iterator end() const { return left.end(); }
+ unordered_map<ustring, int, ustringHash>::const_iterator begin() const
+ {
+ return left.begin();
+ }
+ unordered_map<ustring, int, ustringHash>::const_iterator end() const
+ {
+ return left.end();
+ }
-private:
- unordered_map<ustring, int, ustringHash> left;
- unordered_map<int, ustring> right;
+ private:
+ unordered_map<ustring, int, ustringHash> left;
+ unordered_map<int, ustring> right;
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp
index e045777e969..f46d4e48026 100644
--- a/intern/cycles/graph/node_type.cpp
+++ b/intern/cycles/graph/node_type.cpp
@@ -24,107 +24,118 @@ CCL_NAMESPACE_BEGIN
size_t SocketType::size() const
{
- return size(type);
+ return size(type);
}
bool SocketType::is_array() const
{
- return (type >= BOOLEAN_ARRAY);
+ return (type >= BOOLEAN_ARRAY);
}
size_t SocketType::size(Type type)
{
- switch(type)
- {
- case UNDEFINED: return 0;
-
- case BOOLEAN: return sizeof(bool);
- case FLOAT: return sizeof(float);
- case INT: return sizeof(int);
- case UINT: return sizeof(uint);
- case COLOR: return sizeof(float3);
- case VECTOR: return sizeof(float3);
- case POINT: return sizeof(float3);
- case NORMAL: return sizeof(float3);
- case POINT2: return sizeof(float2);
- case CLOSURE: return 0;
- case STRING: return sizeof(ustring);
- case ENUM: return sizeof(int);
- case TRANSFORM: return sizeof(Transform);
- case NODE: return sizeof(void*);
-
- case BOOLEAN_ARRAY: return sizeof(array<bool>);
- case FLOAT_ARRAY: return sizeof(array<float>);
- case INT_ARRAY: return sizeof(array<int>);
- case COLOR_ARRAY: return sizeof(array<float3>);
- case VECTOR_ARRAY: return sizeof(array<float3>);
- case POINT_ARRAY: return sizeof(array<float3>);
- case NORMAL_ARRAY: return sizeof(array<float3>);
- case POINT2_ARRAY: return sizeof(array<float2>);
- case STRING_ARRAY: return sizeof(array<ustring>);
- case TRANSFORM_ARRAY: return sizeof(array<Transform>);
- case NODE_ARRAY: return sizeof(array<void*>);
- }
-
- assert(0);
- return 0;
+ switch (type) {
+ case UNDEFINED:
+ return 0;
+
+ case BOOLEAN:
+ return sizeof(bool);
+ case FLOAT:
+ return sizeof(float);
+ case INT:
+ return sizeof(int);
+ case UINT:
+ return sizeof(uint);
+ case COLOR:
+ return sizeof(float3);
+ case VECTOR:
+ return sizeof(float3);
+ case POINT:
+ return sizeof(float3);
+ case NORMAL:
+ return sizeof(float3);
+ case POINT2:
+ return sizeof(float2);
+ case CLOSURE:
+ return 0;
+ case STRING:
+ return sizeof(ustring);
+ case ENUM:
+ return sizeof(int);
+ case TRANSFORM:
+ return sizeof(Transform);
+ case NODE:
+ return sizeof(void *);
+
+ case BOOLEAN_ARRAY:
+ return sizeof(array<bool>);
+ case FLOAT_ARRAY:
+ return sizeof(array<float>);
+ case INT_ARRAY:
+ return sizeof(array<int>);
+ case COLOR_ARRAY:
+ return sizeof(array<float3>);
+ case VECTOR_ARRAY:
+ return sizeof(array<float3>);
+ case POINT_ARRAY:
+ return sizeof(array<float3>);
+ case NORMAL_ARRAY:
+ return sizeof(array<float3>);
+ case POINT2_ARRAY:
+ return sizeof(array<float2>);
+ case STRING_ARRAY:
+ return sizeof(array<ustring>);
+ case TRANSFORM_ARRAY:
+ return sizeof(array<Transform>);
+ case NODE_ARRAY:
+ return sizeof(array<void *>);
+ }
+
+ assert(0);
+ return 0;
}
size_t SocketType::max_size()
{
- return sizeof(Transform);
+ return sizeof(Transform);
}
void *SocketType::zero_default_value()
{
- static Transform zero_transform = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
- return &zero_transform;
+ static Transform zero_transform = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
+ return &zero_transform;
}
ustring SocketType::type_name(Type type)
{
- static ustring names[] = {
- ustring("undefined"),
-
- ustring("boolean"),
- ustring("float"),
- ustring("int"),
- ustring("uint"),
- ustring("color"),
- ustring("vector"),
- ustring("point"),
- ustring("normal"),
- ustring("point2"),
- ustring("closure"),
- ustring("string"),
- ustring("enum"),
- ustring("transform"),
- ustring("node"),
-
- ustring("array_boolean"),
- ustring("array_float"),
- ustring("array_int"),
- ustring("array_color"),
- ustring("array_vector"),
- ustring("array_point"),
- ustring("array_normal"),
- ustring("array_point2"),
- ustring("array_string"),
- ustring("array_transform"),
- ustring("array_node")};
-
- return names[(int)type];
+ static ustring names[] = {ustring("undefined"),
+
+ ustring("boolean"), ustring("float"),
+ ustring("int"), ustring("uint"),
+ ustring("color"), ustring("vector"),
+ ustring("point"), ustring("normal"),
+ ustring("point2"), ustring("closure"),
+ ustring("string"), ustring("enum"),
+ ustring("transform"), ustring("node"),
+
+ ustring("array_boolean"), ustring("array_float"),
+ ustring("array_int"), ustring("array_color"),
+ ustring("array_vector"), ustring("array_point"),
+ ustring("array_normal"), ustring("array_point2"),
+ ustring("array_string"), ustring("array_transform"),
+ ustring("array_node")};
+
+ return names[(int)type];
}
bool SocketType::is_float3(Type type)
{
- return (type == COLOR || type == VECTOR || type == POINT || type == NORMAL);
+ return (type == COLOR || type == VECTOR || type == POINT || type == NORMAL);
}
/* Node Type */
-NodeType::NodeType(Type type_)
-: type(type_)
+NodeType::NodeType(Type type_) : type(type_)
{
}
@@ -132,88 +143,94 @@ NodeType::~NodeType()
{
}
-void NodeType::register_input(ustring name, ustring ui_name, SocketType::Type type, int struct_offset,
- const void *default_value, const NodeEnum *enum_values,
- const NodeType **node_type, int flags, int extra_flags)
+void NodeType::register_input(ustring name,
+ ustring ui_name,
+ SocketType::Type type,
+ int struct_offset,
+ const void *default_value,
+ const NodeEnum *enum_values,
+ const NodeType **node_type,
+ int flags,
+ int extra_flags)
{
- SocketType socket;
- socket.name = name;
- socket.ui_name = ui_name;
- socket.type = type;
- socket.struct_offset = struct_offset;
- socket.default_value = default_value;
- socket.enum_values = enum_values;
- socket.node_type = node_type;
- socket.flags = flags | extra_flags;
- inputs.push_back(socket);
+ SocketType socket;
+ socket.name = name;
+ socket.ui_name = ui_name;
+ socket.type = type;
+ socket.struct_offset = struct_offset;
+ socket.default_value = default_value;
+ socket.enum_values = enum_values;
+ socket.node_type = node_type;
+ socket.flags = flags | extra_flags;
+ inputs.push_back(socket);
}
void NodeType::register_output(ustring name, ustring ui_name, SocketType::Type type)
{
- SocketType socket;
- socket.name = name;
- socket.ui_name = ui_name;
- socket.type = type;
- socket.struct_offset = 0;
- socket.default_value = NULL;
- socket.enum_values = NULL;
- socket.node_type = NULL;
- socket.flags = SocketType::LINKABLE;
- outputs.push_back(socket);
+ SocketType socket;
+ socket.name = name;
+ socket.ui_name = ui_name;
+ socket.type = type;
+ socket.struct_offset = 0;
+ socket.default_value = NULL;
+ socket.enum_values = NULL;
+ socket.node_type = NULL;
+ socket.flags = SocketType::LINKABLE;
+ outputs.push_back(socket);
}
const SocketType *NodeType::find_input(ustring name) const
{
- foreach(const SocketType& socket, inputs) {
- if(socket.name == name) {
- return &socket;
- }
- }
+ foreach (const SocketType &socket, inputs) {
+ if (socket.name == name) {
+ return &socket;
+ }
+ }
- return NULL;
+ return NULL;
}
const SocketType *NodeType::find_output(ustring name) const
{
- foreach(const SocketType& socket, outputs) {
- if(socket.name == name) {
- return &socket;
- }
- }
+ foreach (const SocketType &socket, outputs) {
+ if (socket.name == name) {
+ return &socket;
+ }
+ }
- return NULL;
+ return NULL;
}
/* Node Type Registry */
-unordered_map<ustring, NodeType, ustringHash>& NodeType::types()
+unordered_map<ustring, NodeType, ustringHash> &NodeType::types()
{
- static unordered_map<ustring, NodeType, ustringHash> _types;
- return _types;
+ static unordered_map<ustring, NodeType, ustringHash> _types;
+ return _types;
}
NodeType *NodeType::add(const char *name_, CreateFunc create_, Type type_)
{
- ustring name(name_);
+ ustring name(name_);
- if(types().find(name) != types().end()) {
- fprintf(stderr, "Node type %s registered twice!\n", name_);
- assert(0);
- return NULL;
- }
+ if (types().find(name) != types().end()) {
+ fprintf(stderr, "Node type %s registered twice!\n", name_);
+ assert(0);
+ return NULL;
+ }
- types()[name] = NodeType(type_);
+ types()[name] = NodeType(type_);
- NodeType *type = &types()[name];
- type->name = name;
- type->create = create_;
- return type;
+ NodeType *type = &types()[name];
+ type->name = name;
+ type->create = create_;
+ return type;
}
const NodeType *NodeType::find(ustring name)
{
- unordered_map<ustring, NodeType, ustringHash>::iterator it = types().find(name);
- return (it == types().end()) ? NULL : &it->second;
+ unordered_map<ustring, NodeType, ustringHash>::iterator it = types().find(name);
+ return (it == types().end()) ? NULL : &it->second;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h
index 7d6abae2314..e9496a42658 100644
--- a/intern/cycles/graph/node_type.h
+++ b/intern/cycles/graph/node_type.h
@@ -30,236 +30,349 @@ struct NodeType;
/* Socket Type */
-struct SocketType
-{
- enum Type
- {
- UNDEFINED,
+struct SocketType {
+ enum Type {
+ UNDEFINED,
- BOOLEAN,
- FLOAT,
- INT,
- UINT,
- COLOR,
- VECTOR,
- POINT,
- NORMAL,
- POINT2,
- CLOSURE,
- STRING,
- ENUM,
- TRANSFORM,
- NODE,
+ BOOLEAN,
+ FLOAT,
+ INT,
+ UINT,
+ COLOR,
+ VECTOR,
+ POINT,
+ NORMAL,
+ POINT2,
+ CLOSURE,
+ STRING,
+ ENUM,
+ TRANSFORM,
+ NODE,
- BOOLEAN_ARRAY,
- FLOAT_ARRAY,
- INT_ARRAY,
- COLOR_ARRAY,
- VECTOR_ARRAY,
- POINT_ARRAY,
- NORMAL_ARRAY,
- POINT2_ARRAY,
- STRING_ARRAY,
- TRANSFORM_ARRAY,
- NODE_ARRAY,
- };
+ BOOLEAN_ARRAY,
+ FLOAT_ARRAY,
+ INT_ARRAY,
+ COLOR_ARRAY,
+ VECTOR_ARRAY,
+ POINT_ARRAY,
+ NORMAL_ARRAY,
+ POINT2_ARRAY,
+ STRING_ARRAY,
+ TRANSFORM_ARRAY,
+ NODE_ARRAY,
+ };
- enum Flags {
- LINKABLE = (1 << 0),
- ANIMATABLE = (1 << 1),
+ enum Flags {
+ LINKABLE = (1 << 0),
+ ANIMATABLE = (1 << 1),
- SVM_INTERNAL = (1 << 2),
- OSL_INTERNAL = (1 << 3),
- INTERNAL = (1 << 2) | (1 << 3),
+ SVM_INTERNAL = (1 << 2),
+ OSL_INTERNAL = (1 << 3),
+ INTERNAL = (1 << 2) | (1 << 3),
- LINK_TEXTURE_GENERATED = (1 << 4),
- LINK_TEXTURE_NORMAL = (1 << 5),
- LINK_TEXTURE_UV = (1 << 6),
- LINK_INCOMING = (1 << 7),
- LINK_NORMAL = (1 << 8),
- LINK_POSITION = (1 << 9),
- LINK_TANGENT = (1 << 10),
- DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)
- };
+ LINK_TEXTURE_GENERATED = (1 << 4),
+ LINK_TEXTURE_NORMAL = (1 << 5),
+ LINK_TEXTURE_UV = (1 << 6),
+ LINK_INCOMING = (1 << 7),
+ LINK_NORMAL = (1 << 8),
+ LINK_POSITION = (1 << 9),
+ LINK_TANGENT = (1 << 10),
+ DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)
+ };
- ustring name;
- Type type;
- int struct_offset;
- const void *default_value;
- const NodeEnum *enum_values;
- const NodeType **node_type;
- int flags;
- ustring ui_name;
+ ustring name;
+ Type type;
+ int struct_offset;
+ const void *default_value;
+ const NodeEnum *enum_values;
+ const NodeType **node_type;
+ int flags;
+ ustring ui_name;
- size_t size() const;
- bool is_array() const;
- static size_t size(Type type);
- static size_t max_size();
- static ustring type_name(Type type);
- static void *zero_default_value();
- static bool is_float3(Type type);
+ size_t size() const;
+ bool is_array() const;
+ static size_t size(Type type);
+ static size_t max_size();
+ static ustring type_name(Type type);
+ static void *zero_default_value();
+ static bool is_float3(Type type);
};
/* Node Type */
-struct NodeType
-{
- enum Type {
- NONE,
- SHADER
- };
+struct NodeType {
+ enum Type { NONE, SHADER };
- explicit NodeType(Type type = NONE);
- ~NodeType();
+ explicit NodeType(Type type = NONE);
+ ~NodeType();
- void register_input(ustring name, ustring ui_name, SocketType::Type type,
- int struct_offset, const void *default_value,
- const NodeEnum *enum_values = NULL,
- const NodeType **node_type = NULL,
- int flags = 0, int extra_flags = 0);
- void register_output(ustring name, ustring ui_name, SocketType::Type type);
+ void register_input(ustring name,
+ ustring ui_name,
+ SocketType::Type type,
+ int struct_offset,
+ const void *default_value,
+ const NodeEnum *enum_values = NULL,
+ const NodeType **node_type = NULL,
+ int flags = 0,
+ int extra_flags = 0);
+ void register_output(ustring name, ustring ui_name, SocketType::Type type);
- const SocketType *find_input(ustring name) const;
- const SocketType *find_output(ustring name) const;
+ const SocketType *find_input(ustring name) const;
+ const SocketType *find_output(ustring name) const;
- typedef Node *(*CreateFunc)(const NodeType *type);
+ typedef Node *(*CreateFunc)(const NodeType *type);
- ustring name;
- Type type;
- vector<SocketType, std::allocator<SocketType> > inputs;
- vector<SocketType, std::allocator<SocketType> > outputs;
- CreateFunc create;
+ ustring name;
+ Type type;
+ vector<SocketType, std::allocator<SocketType>> inputs;
+ vector<SocketType, std::allocator<SocketType>> outputs;
+ CreateFunc create;
- static NodeType *add(const char *name, CreateFunc create, Type type = NONE);
- static const NodeType *find(ustring name);
- static unordered_map<ustring, NodeType, ustringHash>& types();
+ static NodeType *add(const char *name, CreateFunc create, Type type = NONE);
+ static const NodeType *find(ustring name);
+ static unordered_map<ustring, NodeType, ustringHash> &types();
};
/* Node Definition Macros */
-#define NODE_DECLARE \
-template<typename T> \
-static const NodeType *register_type(); \
-static Node *create(const NodeType *type); \
-static const NodeType *node_type;
+#define NODE_DECLARE \
+ template<typename T> static const NodeType *register_type(); \
+ static Node *create(const NodeType *type); \
+ static const NodeType *node_type;
-#define NODE_DEFINE(structname) \
-const NodeType *structname::node_type = structname::register_type<structname>(); \
-Node *structname::create(const NodeType*) { return new structname(); } \
-template<typename T> \
-const NodeType *structname::register_type()
+#define NODE_DEFINE(structname) \
+ const NodeType *structname::node_type = structname::register_type<structname>(); \
+ Node *structname::create(const NodeType *) \
+ { \
+ return new structname(); \
+ } \
+ template<typename T> const NodeType *structname::register_type()
/* Sock Definition Macros */
#define SOCKET_OFFSETOF(T, name) (((char *)&(((T *)1)->name)) - (char *)1)
#define SOCKET_SIZEOF(T, name) (sizeof(((T *)1)->name))
#define SOCKET_DEFINE(name, ui_name, default_value, datatype, TYPE, flags, ...) \
- { \
- static datatype defval = default_value; \
- CHECK_TYPE(((T *)1)->name, datatype); \
- type->register_input(ustring(#name), ustring(ui_name), TYPE, SOCKET_OFFSETOF(T, name), &defval, NULL, NULL, flags, ##__VA_ARGS__); \
- }
+ { \
+ static datatype defval = default_value; \
+ CHECK_TYPE(((T *)1)->name, datatype); \
+ type->register_input(ustring(#name), \
+ ustring(ui_name), \
+ TYPE, \
+ SOCKET_OFFSETOF(T, name), \
+ &defval, \
+ NULL, \
+ NULL, \
+ flags, \
+ ##__VA_ARGS__); \
+ }
#define SOCKET_BOOLEAN(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, bool, SocketType::BOOLEAN, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, bool, SocketType::BOOLEAN, 0, ##__VA_ARGS__)
#define SOCKET_INT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, int, SocketType::INT, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, int, SocketType::INT, 0, ##__VA_ARGS__)
#define SOCKET_UINT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, uint, SocketType::UINT, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, uint, SocketType::UINT, 0, ##__VA_ARGS__)
#define SOCKET_FLOAT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float, SocketType::FLOAT, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, float, SocketType::FLOAT, 0, ##__VA_ARGS__)
#define SOCKET_COLOR(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::COLOR, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::COLOR, 0, ##__VA_ARGS__)
#define SOCKET_VECTOR(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::VECTOR, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::VECTOR, 0, ##__VA_ARGS__)
#define SOCKET_POINT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::POINT, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::POINT, 0, ##__VA_ARGS__)
#define SOCKET_NORMAL(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::NORMAL, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::NORMAL, 0, ##__VA_ARGS__)
#define SOCKET_POINT2(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float2, SocketType::POINT2, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, float2, SocketType::POINT2, 0, ##__VA_ARGS__)
#define SOCKET_STRING(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, ustring, SocketType::STRING, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, ustring, SocketType::STRING, 0, ##__VA_ARGS__)
#define SOCKET_TRANSFORM(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, Transform, SocketType::TRANSFORM, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, Transform, SocketType::TRANSFORM, 0, ##__VA_ARGS__)
#define SOCKET_ENUM(name, ui_name, values, default_value, ...) \
- { \
- static int defval = default_value; \
- assert(SOCKET_SIZEOF(T, name) == sizeof(int)); \
- type->register_input(ustring(#name), ustring(ui_name), SocketType::ENUM, SOCKET_OFFSETOF(T, name), &defval, &values, NULL, ##__VA_ARGS__); \
- }
+ { \
+ static int defval = default_value; \
+ assert(SOCKET_SIZEOF(T, name) == sizeof(int)); \
+ type->register_input(ustring(#name), \
+ ustring(ui_name), \
+ SocketType::ENUM, \
+ SOCKET_OFFSETOF(T, name), \
+ &defval, \
+ &values, \
+ NULL, \
+ ##__VA_ARGS__); \
+ }
#define SOCKET_NODE(name, ui_name, node_type, ...) \
- { \
- static Node *defval = NULL; \
- assert(SOCKET_SIZEOF(T, name) == sizeof(Node*)); \
- type->register_input(ustring(#name), ustring(ui_name), SocketType::NODE, SOCKET_OFFSETOF(T, name), &defval, NULL, node_type, ##__VA_ARGS__); \
- }
+ { \
+ static Node *defval = NULL; \
+ assert(SOCKET_SIZEOF(T, name) == sizeof(Node *)); \
+ type->register_input(ustring(#name), \
+ ustring(ui_name), \
+ SocketType::NODE, \
+ SOCKET_OFFSETOF(T, name), \
+ &defval, \
+ NULL, \
+ node_type, \
+ ##__VA_ARGS__); \
+ }
#define SOCKET_BOOLEAN_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<bool>, SocketType::BOOLEAN_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<bool>, SocketType::BOOLEAN_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_INT_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<int>, SocketType::INT_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, ui_name, default_value, array<int>, SocketType::INT_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_FLOAT_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<float>, SocketType::FLOAT_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<float>, SocketType::FLOAT_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_COLOR_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<float3>, SocketType::COLOR_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<float3>, SocketType::COLOR_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_VECTOR_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<float3>, SocketType::VECTOR_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<float3>, SocketType::VECTOR_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_POINT_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<float3>, SocketType::POINT_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<float3>, SocketType::POINT_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_NORMAL_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<float3>, SocketType::NORMAL_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<float3>, SocketType::NORMAL_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_POINT2_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<float2>, SocketType::POINT2_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<float2>, SocketType::POINT2_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_STRING_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<ustring>, SocketType::STRING_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, array<ustring>, SocketType::STRING_ARRAY, 0, ##__VA_ARGS__)
#define SOCKET_TRANSFORM_ARRAY(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, array<Transform>, SocketType::TRANSFORM_ARRAY, 0, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ array<Transform>, \
+ SocketType::TRANSFORM_ARRAY, \
+ 0, \
+ ##__VA_ARGS__)
#define SOCKET_NODE_ARRAY(name, ui_name, node_type, ...) \
- { \
- static Node *defval = NULL; \
- assert(SOCKET_SIZEOF(T, name) == sizeof(Node*)); \
- type->register_input(ustring(#name), ustring(ui_name), SocketType::NODE_ARRAY, SOCKET_OFFSETOF(T, name), &defval, NULL, node_type, ##__VA_ARGS__); \
- }
+ { \
+ static Node *defval = NULL; \
+ assert(SOCKET_SIZEOF(T, name) == sizeof(Node *)); \
+ type->register_input(ustring(#name), \
+ ustring(ui_name), \
+ SocketType::NODE_ARRAY, \
+ SOCKET_OFFSETOF(T, name), \
+ &defval, \
+ NULL, \
+ node_type, \
+ ##__VA_ARGS__); \
+ }
#define SOCKET_IN_BOOLEAN(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, bool, SocketType::BOOLEAN, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ bool, \
+ SocketType::BOOLEAN, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_INT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, int, SocketType::INT, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE( \
+ name, ui_name, default_value, int, SocketType::INT, SocketType::LINKABLE, ##__VA_ARGS__)
#define SOCKET_IN_FLOAT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float, SocketType::FLOAT, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ float, \
+ SocketType::FLOAT, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_COLOR(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::COLOR, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ float3, \
+ SocketType::COLOR, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_VECTOR(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::VECTOR, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ float3, \
+ SocketType::VECTOR, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_POINT(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::POINT, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ float3, \
+ SocketType::POINT, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_NORMAL(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, float3, SocketType::NORMAL, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ float3, \
+ SocketType::NORMAL, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_STRING(name, ui_name, default_value, ...) \
- SOCKET_DEFINE(name, ui_name, default_value, ustring, SocketType::STRING, SocketType::LINKABLE, ##__VA_ARGS__)
+ SOCKET_DEFINE(name, \
+ ui_name, \
+ default_value, \
+ ustring, \
+ SocketType::STRING, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_IN_CLOSURE(name, ui_name, ...) \
- type->register_input(ustring(#name), ustring(ui_name), SocketType::CLOSURE, 0, NULL, NULL, NULL, SocketType::LINKABLE, ##__VA_ARGS__)
+ type->register_input(ustring(#name), \
+ ustring(ui_name), \
+ SocketType::CLOSURE, \
+ 0, \
+ NULL, \
+ NULL, \
+ NULL, \
+ SocketType::LINKABLE, \
+ ##__VA_ARGS__)
#define SOCKET_OUT_BOOLEAN(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::BOOLEAN); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::BOOLEAN); \
+ }
#define SOCKET_OUT_INT(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::INT); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::INT); \
+ }
#define SOCKET_OUT_FLOAT(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::FLOAT); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::FLOAT); \
+ }
#define SOCKET_OUT_COLOR(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::COLOR); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::COLOR); \
+ }
#define SOCKET_OUT_VECTOR(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::VECTOR); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::VECTOR); \
+ }
#define SOCKET_OUT_POINT(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::POINT); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::POINT); \
+ }
#define SOCKET_OUT_NORMAL(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::NORMAL); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::NORMAL); \
+ }
#define SOCKET_OUT_CLOSURE(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::CLOSURE); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::CLOSURE); \
+ }
#define SOCKET_OUT_STRING(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::STRING); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::STRING); \
+ }
#define SOCKET_OUT_ENUM(name, ui_name) \
- { type->register_output(ustring(#name), ustring(ui_name), SocketType::ENUM); }
+ { \
+ type->register_output(ustring(#name), ustring(ui_name), SocketType::ENUM); \
+ }
CCL_NAMESPACE_END
diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp
index f228da282e9..a96970cc904 100644
--- a/intern/cycles/graph/node_xml.cpp
+++ b/intern/cycles/graph/node_xml.cpp
@@ -24,437 +24,409 @@ CCL_NAMESPACE_BEGIN
static bool xml_read_boolean(const char *value)
{
- return string_iequals(value, "true") || (atoi(value) != 0);
+ return string_iequals(value, "true") || (atoi(value) != 0);
}
static const char *xml_write_boolean(bool value)
{
- return (value) ? "true" : "false";
+ return (value) ? "true" : "false";
}
template<int VECTOR_SIZE, typename T>
-static void xml_read_float_array(T& value, xml_attribute attr)
+static void xml_read_float_array(T &value, xml_attribute attr)
{
- vector<string> tokens;
- string_split(tokens, attr.value());
+ vector<string> tokens;
+ string_split(tokens, attr.value());
- if(tokens.size() % VECTOR_SIZE != 0) {
- return;
- }
+ if (tokens.size() % VECTOR_SIZE != 0) {
+ return;
+ }
- value.resize(tokens.size() / VECTOR_SIZE);
- for(size_t i = 0; i < value.size(); i++) {
- float *value_float = (float*)&value[i];
+ value.resize(tokens.size() / VECTOR_SIZE);
+ for (size_t i = 0; i < value.size(); i++) {
+ float *value_float = (float *)&value[i];
- for(size_t j = 0; j < VECTOR_SIZE; j++)
- value_float[j] = (float)atof(tokens[i * VECTOR_SIZE + j].c_str());
- }
+ for (size_t j = 0; j < VECTOR_SIZE; j++)
+ value_float[j] = (float)atof(tokens[i * VECTOR_SIZE + j].c_str());
+ }
}
-void xml_read_node(XMLReader& reader, Node *node, xml_node xml_node)
+void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node)
{
- xml_attribute name_attr = xml_node.attribute("name");
- if(name_attr) {
- node->name = ustring(name_attr.value());
- }
+ xml_attribute name_attr = xml_node.attribute("name");
+ if (name_attr) {
+ node->name = ustring(name_attr.value());
+ }
- foreach(const SocketType& socket, node->type->inputs) {
- if(socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
- continue;
- }
- if(socket.flags & SocketType::INTERNAL) {
- continue;
- }
+ foreach (const SocketType &socket, node->type->inputs) {
+ if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
+ continue;
+ }
+ if (socket.flags & SocketType::INTERNAL) {
+ continue;
+ }
- xml_attribute attr = xml_node.attribute(socket.name.c_str());
+ xml_attribute attr = xml_node.attribute(socket.name.c_str());
- if(!attr) {
- continue;
- }
+ if (!attr) {
+ continue;
+ }
- switch(socket.type)
- {
- case SocketType::BOOLEAN:
- {
- node->set(socket, xml_read_boolean(attr.value()));
- break;
- }
- case SocketType::BOOLEAN_ARRAY:
- {
- vector<string> tokens;
- string_split(tokens, attr.value());
+ switch (socket.type) {
+ case SocketType::BOOLEAN: {
+ node->set(socket, xml_read_boolean(attr.value()));
+ break;
+ }
+ case SocketType::BOOLEAN_ARRAY: {
+ vector<string> tokens;
+ string_split(tokens, attr.value());
- array<bool> value;
- value.resize(tokens.size());
- for(size_t i = 0; i < value.size(); i++)
- value[i] = xml_read_boolean(tokens[i].c_str());
- node->set(socket, value);
- break;
- }
- case SocketType::FLOAT:
- {
- node->set(socket, (float)atof(attr.value()));
- break;
- }
- case SocketType::FLOAT_ARRAY:
- {
- array<float> value;
- xml_read_float_array<1>(value, attr);
- node->set(socket, value);
- break;
- }
- case SocketType::INT:
- {
- node->set(socket, (int)atoi(attr.value()));
- break;
- }
- case SocketType::UINT:
- {
- node->set(socket, (uint)atoi(attr.value()));
- break;
- }
- case SocketType::INT_ARRAY:
- {
- vector<string> tokens;
- string_split(tokens, attr.value());
+ array<bool> value;
+ value.resize(tokens.size());
+ for (size_t i = 0; i < value.size(); i++)
+ value[i] = xml_read_boolean(tokens[i].c_str());
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::FLOAT: {
+ node->set(socket, (float)atof(attr.value()));
+ break;
+ }
+ case SocketType::FLOAT_ARRAY: {
+ array<float> value;
+ xml_read_float_array<1>(value, attr);
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::INT: {
+ node->set(socket, (int)atoi(attr.value()));
+ break;
+ }
+ case SocketType::UINT: {
+ node->set(socket, (uint)atoi(attr.value()));
+ break;
+ }
+ case SocketType::INT_ARRAY: {
+ vector<string> tokens;
+ string_split(tokens, attr.value());
- array<int> value;
- value.resize(tokens.size());
- for(size_t i = 0; i < value.size(); i++) {
- value[i] = (int)atoi(attr.value());
- }
- node->set(socket, value);
- break;
- }
- case SocketType::COLOR:
- case SocketType::VECTOR:
- case SocketType::POINT:
- case SocketType::NORMAL:
- {
- array<float3> value;
- xml_read_float_array<3>(value, attr);
- if(value.size() == 1) {
- node->set(socket, value[0]);
- }
- break;
- }
- case SocketType::COLOR_ARRAY:
- case SocketType::VECTOR_ARRAY:
- case SocketType::POINT_ARRAY:
- case SocketType::NORMAL_ARRAY:
- {
- array<float3> value;
- xml_read_float_array<3>(value, attr);
- node->set(socket, value);
- break;
- }
- case SocketType::POINT2:
- {
- array<float2> value;
- xml_read_float_array<2>(value, attr);
- if(value.size() == 1) {
- node->set(socket, value[0]);
- }
- break;
- }
- case SocketType::POINT2_ARRAY:
- {
- array<float2> value;
- xml_read_float_array<2>(value, attr);
- node->set(socket, value);
- break;
- }
- case SocketType::STRING:
- {
- node->set(socket, attr.value());
- break;
- }
- case SocketType::ENUM:
- {
- ustring value(attr.value());
- if(socket.enum_values->exists(value)) {
- node->set(socket, value);
- }
- else {
- fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", value.c_str(), socket.name.c_str());
- }
- break;
- }
- case SocketType::STRING_ARRAY:
- {
- vector<string> tokens;
- string_split(tokens, attr.value());
+ array<int> value;
+ value.resize(tokens.size());
+ for (size_t i = 0; i < value.size(); i++) {
+ value[i] = (int)atoi(attr.value());
+ }
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::COLOR:
+ case SocketType::VECTOR:
+ case SocketType::POINT:
+ case SocketType::NORMAL: {
+ array<float3> value;
+ xml_read_float_array<3>(value, attr);
+ if (value.size() == 1) {
+ node->set(socket, value[0]);
+ }
+ break;
+ }
+ case SocketType::COLOR_ARRAY:
+ case SocketType::VECTOR_ARRAY:
+ case SocketType::POINT_ARRAY:
+ case SocketType::NORMAL_ARRAY: {
+ array<float3> value;
+ xml_read_float_array<3>(value, attr);
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::POINT2: {
+ array<float2> value;
+ xml_read_float_array<2>(value, attr);
+ if (value.size() == 1) {
+ node->set(socket, value[0]);
+ }
+ break;
+ }
+ case SocketType::POINT2_ARRAY: {
+ array<float2> value;
+ xml_read_float_array<2>(value, attr);
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::STRING: {
+ node->set(socket, attr.value());
+ break;
+ }
+ case SocketType::ENUM: {
+ ustring value(attr.value());
+ if (socket.enum_values->exists(value)) {
+ node->set(socket, value);
+ }
+ else {
+ fprintf(stderr,
+ "Unknown value \"%s\" for attribute \"%s\".\n",
+ value.c_str(),
+ socket.name.c_str());
+ }
+ break;
+ }
+ case SocketType::STRING_ARRAY: {
+ vector<string> tokens;
+ string_split(tokens, attr.value());
- array<ustring> value;
- value.resize(tokens.size());
- for(size_t i = 0; i < value.size(); i++) {
- value[i] = ustring(tokens[i]);
- }
- node->set(socket, value);
- break;
- }
- case SocketType::TRANSFORM:
- {
- array<Transform> value;
- xml_read_float_array<12>(value, attr);
- if(value.size() == 1) {
- node->set(socket, value[0]);
- }
- break;
- }
- case SocketType::TRANSFORM_ARRAY:
- {
- array<Transform> value;
- xml_read_float_array<12>(value, attr);
- node->set(socket, value);
- break;
- }
- case SocketType::NODE:
- {
- ustring value(attr.value());
- map<ustring, Node*>::iterator it = reader.node_map.find(value);
- if(it != reader.node_map.end())
- {
- Node *value_node = it->second;
- if(value_node->type == *(socket.node_type))
- node->set(socket, it->second);
- }
- break;
- }
- case SocketType::NODE_ARRAY:
- {
- vector<string> tokens;
- string_split(tokens, attr.value());
+ array<ustring> value;
+ value.resize(tokens.size());
+ for (size_t i = 0; i < value.size(); i++) {
+ value[i] = ustring(tokens[i]);
+ }
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::TRANSFORM: {
+ array<Transform> value;
+ xml_read_float_array<12>(value, attr);
+ if (value.size() == 1) {
+ node->set(socket, value[0]);
+ }
+ break;
+ }
+ case SocketType::TRANSFORM_ARRAY: {
+ array<Transform> value;
+ xml_read_float_array<12>(value, attr);
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::NODE: {
+ ustring value(attr.value());
+ map<ustring, Node *>::iterator it = reader.node_map.find(value);
+ if (it != reader.node_map.end()) {
+ Node *value_node = it->second;
+ if (value_node->type == *(socket.node_type))
+ node->set(socket, it->second);
+ }
+ break;
+ }
+ case SocketType::NODE_ARRAY: {
+ vector<string> tokens;
+ string_split(tokens, attr.value());
- array<Node*> value;
- value.resize(tokens.size());
- for(size_t i = 0; i < value.size(); i++)
- {
- map<ustring, Node*>::iterator it = reader.node_map.find(ustring(tokens[i]));
- if(it != reader.node_map.end())
- {
- Node *value_node = it->second;
- value[i] = (value_node->type == *(socket.node_type)) ? value_node : NULL;
- }
- else
- {
- value[i] = NULL;
- }
- }
- node->set(socket, value);
- break;
- }
- case SocketType::CLOSURE:
- case SocketType::UNDEFINED:
- break;
- }
- }
+ array<Node *> value;
+ value.resize(tokens.size());
+ for (size_t i = 0; i < value.size(); i++) {
+ map<ustring, Node *>::iterator it = reader.node_map.find(ustring(tokens[i]));
+ if (it != reader.node_map.end()) {
+ Node *value_node = it->second;
+ value[i] = (value_node->type == *(socket.node_type)) ? value_node : NULL;
+ }
+ else {
+ value[i] = NULL;
+ }
+ }
+ node->set(socket, value);
+ break;
+ }
+ case SocketType::CLOSURE:
+ case SocketType::UNDEFINED:
+ break;
+ }
+ }
- if(!node->name.empty())
- reader.node_map[node->name] = node;
+ if (!node->name.empty())
+ reader.node_map[node->name] = node;
}
xml_node xml_write_node(Node *node, xml_node xml_root)
{
- xml_node xml_node = xml_root.append_child(node->type->name.c_str());
+ xml_node xml_node = xml_root.append_child(node->type->name.c_str());
- xml_node.append_attribute("name") = node->name.c_str();
+ xml_node.append_attribute("name") = node->name.c_str();
- foreach(const SocketType& socket, node->type->inputs) {
- if(socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
- continue;
- }
- if(socket.flags & SocketType::INTERNAL) {
- continue;
- }
- if(node->has_default_value(socket)) {
- continue;
- }
+ foreach (const SocketType &socket, node->type->inputs) {
+ if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
+ continue;
+ }
+ if (socket.flags & SocketType::INTERNAL) {
+ continue;
+ }
+ if (node->has_default_value(socket)) {
+ continue;
+ }
- xml_attribute attr = xml_node.append_attribute(socket.name.c_str());
+ xml_attribute attr = xml_node.append_attribute(socket.name.c_str());
- switch(socket.type)
- {
- case SocketType::BOOLEAN:
- {
- attr = xml_write_boolean(node->get_bool(socket));
- break;
- }
- case SocketType::BOOLEAN_ARRAY:
- {
- std::stringstream ss;
- const array<bool>& value = node->get_bool_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- ss << xml_write_boolean(value[i]);
- if(i != value.size() - 1)
- ss << " ";
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::FLOAT:
- {
- attr = (double)node->get_float(socket);
- break;
- }
- case SocketType::FLOAT_ARRAY:
- {
- std::stringstream ss;
- const array<float>& value = node->get_float_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- ss << value[i];
- if(i != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::INT:
- {
- attr = node->get_int(socket);
- break;
- }
- case SocketType::UINT:
- {
- attr = node->get_uint(socket);
- break;
- }
- case SocketType::INT_ARRAY:
- {
- std::stringstream ss;
- const array<int>& value = node->get_int_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- ss << value[i];
- if(i != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::COLOR:
- case SocketType::VECTOR:
- case SocketType::POINT:
- case SocketType::NORMAL:
- {
- float3 value = node->get_float3(socket);
- attr = string_printf("%g %g %g", (double)value.x, (double)value.y, (double)value.z).c_str();
- break;
- }
- case SocketType::COLOR_ARRAY:
- case SocketType::VECTOR_ARRAY:
- case SocketType::POINT_ARRAY:
- case SocketType::NORMAL_ARRAY:
- {
- std::stringstream ss;
- const array<float3>& value = node->get_float3_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- ss << string_printf("%g %g %g", (double)value[i].x, (double)value[i].y, (double)value[i].z);
- if(i != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::POINT2:
- {
- float2 value = node->get_float2(socket);
- attr = string_printf("%g %g", (double)value.x, (double)value.y).c_str();
- break;
- }
- case SocketType::POINT2_ARRAY:
- {
- std::stringstream ss;
- const array<float2>& value = node->get_float2_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- ss << string_printf("%g %g", (double)value[i].x, (double)value[i].y);
- if(i != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::STRING:
- case SocketType::ENUM:
- {
- attr = node->get_string(socket).c_str();
- break;
- }
- case SocketType::STRING_ARRAY:
- {
- std::stringstream ss;
- const array<ustring>& value = node->get_string_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- ss << value[i];
- if(i != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::TRANSFORM:
- {
- Transform tfm = node->get_transform(socket);
- std::stringstream ss;
- for(int i = 0; i < 3; i++) {
- ss << string_printf("%g %g %g %g ", (double)tfm[i][0], (double)tfm[i][1], (double)tfm[i][2], (double)tfm[i][3]);
- }
- ss << string_printf("%g %g %g %g", 0.0, 0.0, 0.0, 1.0);
- attr = ss.str().c_str();
- break;
- }
- case SocketType::TRANSFORM_ARRAY:
- {
- std::stringstream ss;
- const array<Transform>& value = node->get_transform_array(socket);
- for(size_t j = 0; j < value.size(); j++) {
- const Transform& tfm = value[j];
+ switch (socket.type) {
+ case SocketType::BOOLEAN: {
+ attr = xml_write_boolean(node->get_bool(socket));
+ break;
+ }
+ case SocketType::BOOLEAN_ARRAY: {
+ std::stringstream ss;
+ const array<bool> &value = node->get_bool_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ ss << xml_write_boolean(value[i]);
+ if (i != value.size() - 1)
+ ss << " ";
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::FLOAT: {
+ attr = (double)node->get_float(socket);
+ break;
+ }
+ case SocketType::FLOAT_ARRAY: {
+ std::stringstream ss;
+ const array<float> &value = node->get_float_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ ss << value[i];
+ if (i != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::INT: {
+ attr = node->get_int(socket);
+ break;
+ }
+ case SocketType::UINT: {
+ attr = node->get_uint(socket);
+ break;
+ }
+ case SocketType::INT_ARRAY: {
+ std::stringstream ss;
+ const array<int> &value = node->get_int_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ ss << value[i];
+ if (i != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::COLOR:
+ case SocketType::VECTOR:
+ case SocketType::POINT:
+ case SocketType::NORMAL: {
+ float3 value = node->get_float3(socket);
+ attr =
+ string_printf("%g %g %g", (double)value.x, (double)value.y, (double)value.z).c_str();
+ break;
+ }
+ case SocketType::COLOR_ARRAY:
+ case SocketType::VECTOR_ARRAY:
+ case SocketType::POINT_ARRAY:
+ case SocketType::NORMAL_ARRAY: {
+ std::stringstream ss;
+ const array<float3> &value = node->get_float3_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ ss << string_printf(
+ "%g %g %g", (double)value[i].x, (double)value[i].y, (double)value[i].z);
+ if (i != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::POINT2: {
+ float2 value = node->get_float2(socket);
+ attr = string_printf("%g %g", (double)value.x, (double)value.y).c_str();
+ break;
+ }
+ case SocketType::POINT2_ARRAY: {
+ std::stringstream ss;
+ const array<float2> &value = node->get_float2_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ ss << string_printf("%g %g", (double)value[i].x, (double)value[i].y);
+ if (i != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::STRING:
+ case SocketType::ENUM: {
+ attr = node->get_string(socket).c_str();
+ break;
+ }
+ case SocketType::STRING_ARRAY: {
+ std::stringstream ss;
+ const array<ustring> &value = node->get_string_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ ss << value[i];
+ if (i != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::TRANSFORM: {
+ Transform tfm = node->get_transform(socket);
+ std::stringstream ss;
+ for (int i = 0; i < 3; i++) {
+ ss << string_printf("%g %g %g %g ",
+ (double)tfm[i][0],
+ (double)tfm[i][1],
+ (double)tfm[i][2],
+ (double)tfm[i][3]);
+ }
+ ss << string_printf("%g %g %g %g", 0.0, 0.0, 0.0, 1.0);
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::TRANSFORM_ARRAY: {
+ std::stringstream ss;
+ const array<Transform> &value = node->get_transform_array(socket);
+ for (size_t j = 0; j < value.size(); j++) {
+ const Transform &tfm = value[j];
- for(int i = 0; i < 3; i++) {
- ss << string_printf("%g %g %g %g ", (double)tfm[i][0], (double)tfm[i][1], (double)tfm[i][2], (double)tfm[i][3]);
- }
- ss << string_printf("%g %g %g %g", 0.0, 0.0, 0.0, 1.0);
- if(j != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::NODE:
- {
- Node *value = node->get_node(socket);
- if(value) {
- attr = value->name.c_str();
- }
- break;
- }
- case SocketType::NODE_ARRAY:
- {
- std::stringstream ss;
- const array<Node*>& value = node->get_node_array(socket);
- for(size_t i = 0; i < value.size(); i++) {
- if(value[i]) {
- ss << value[i]->name.c_str();
- }
- if(i != value.size() - 1) {
- ss << " ";
- }
- }
- attr = ss.str().c_str();
- break;
- }
- case SocketType::CLOSURE:
- case SocketType::UNDEFINED:
- break;
- }
- }
+ for (int i = 0; i < 3; i++) {
+ ss << string_printf("%g %g %g %g ",
+ (double)tfm[i][0],
+ (double)tfm[i][1],
+ (double)tfm[i][2],
+ (double)tfm[i][3]);
+ }
+ ss << string_printf("%g %g %g %g", 0.0, 0.0, 0.0, 1.0);
+ if (j != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::NODE: {
+ Node *value = node->get_node(socket);
+ if (value) {
+ attr = value->name.c_str();
+ }
+ break;
+ }
+ case SocketType::NODE_ARRAY: {
+ std::stringstream ss;
+ const array<Node *> &value = node->get_node_array(socket);
+ for (size_t i = 0; i < value.size(); i++) {
+ if (value[i]) {
+ ss << value[i]->name.c_str();
+ }
+ if (i != value.size() - 1) {
+ ss << " ";
+ }
+ }
+ attr = ss.str().c_str();
+ break;
+ }
+ case SocketType::CLOSURE:
+ case SocketType::UNDEFINED:
+ break;
+ }
+ }
- return xml_node;
+ return xml_node;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/graph/node_xml.h b/intern/cycles/graph/node_xml.h
index 5fecf40f96c..15bbf5d5621 100644
--- a/intern/cycles/graph/node_xml.h
+++ b/intern/cycles/graph/node_xml.h
@@ -25,10 +25,10 @@
CCL_NAMESPACE_BEGIN
struct XMLReader {
- map<ustring, Node*> node_map;
+ map<ustring, Node *> node_map;
};
-void xml_read_node(XMLReader& reader, Node *node, xml_node xml_node);
+void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node);
xml_node xml_write_node(Node *node, xml_node xml_root);
CCL_NAMESPACE_END