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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2016-05-08 01:28:21 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-05-28 15:07:19 +0300
commit98ad47332466b13f35de80639a54b3493786fddb (patch)
tree697f738d070c8a9965e7c9956201ebb1bc3be634 /intern/cycles/graph
parent9d5aead88f4d62152f7f4a36f84fe0e1dc3463d7 (diff)
Code refactor: nodify Cycles camera and fix some mistakes in XML node read.
Differential Revision: https://developer.blender.org/D2016
Diffstat (limited to 'intern/cycles/graph')
-rw-r--r--intern/cycles/graph/node.cpp5
-rw-r--r--intern/cycles/graph/node.h1
-rw-r--r--intern/cycles/graph/node_xml.cpp20
3 files changed, 22 insertions, 4 deletions
diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp
index d482577b73b..98b66fb9a7a 100644
--- a/intern/cycles/graph/node.cpp
+++ b/intern/cycles/graph/node.cpp
@@ -104,6 +104,11 @@ void Node::set(const SocketType& input, float3 value)
get_socket_value<float3>(this, input) = value;
}
+void Node::set(const SocketType& input, const char *value)
+{
+ set(input, ustring(value));
+}
+
void Node::set(const SocketType& input, ustring value)
{
if(input.type == SocketType::STRING) {
diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h
index 33971fa714a..de06df10265 100644
--- a/intern/cycles/graph/node.h
+++ b/intern/cycles/graph/node.h
@@ -41,6 +41,7 @@ struct Node
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);
diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp
index fe06a243998..a6040405c30 100644
--- a/intern/cycles/graph/node_xml.cpp
+++ b/intern/cycles/graph/node_xml.cpp
@@ -117,8 +117,9 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
array<int> value;
value.resize(tokens.size());
- for(size_t i = 0; i < value.size(); i++)
+ for(size_t i = 0; i < value.size(); i++) {
value[i] = (int)atoi(attr.value());
+ }
node->set(socket, value);
break;
}
@@ -127,7 +128,7 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
case SocketType::POINT:
case SocketType::NORMAL:
{
- array<float> value;
+ array<float3> value;
xml_read_float_array<3>(value, attr);
if(value.size() == 1) {
node->set(socket, value[0]);
@@ -161,11 +162,21 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
break;
}
case SocketType::STRING:
- case SocketType::ENUM:
{
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;
@@ -173,8 +184,9 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
array<ustring> value;
value.resize(tokens.size());
- for(size_t i = 0; i < value.size(); i++)
+ for(size_t i = 0; i < value.size(); i++) {
value[i] = ustring(tokens[i]);
+ }
node->set(socket, value);
break;
}