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:
Diffstat (limited to 'intern/cycles/render/graph.h')
-rw-r--r--intern/cycles/render/graph.h105
1 files changed, 29 insertions, 76 deletions
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index bd3f5ca689a..760b19f447a 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -17,6 +17,8 @@
#ifndef __GRAPH_H__
#define __GRAPH_H__
+#include "node.h"
+
#include "kernel_types.h"
#include "util_list.h"
@@ -39,23 +41,6 @@ class SVMCompiler;
class OSLCompiler;
class OutputNode;
-/* Socket Type
- *
- * Data type for inputs and outputs */
-
-enum ShaderSocketType {
- SHADER_SOCKET_UNDEFINED,
-
- SHADER_SOCKET_FLOAT,
- SHADER_SOCKET_INT,
- SHADER_SOCKET_COLOR,
- SHADER_SOCKET_VECTOR,
- SHADER_SOCKET_POINT,
- SHADER_SOCKET_NORMAL,
- SHADER_SOCKET_CLOSURE,
- SHADER_SOCKET_STRING
-};
-
/* Bump
*
* For bump mapping, a node may be evaluated multiple times, using different
@@ -86,30 +71,6 @@ enum ShaderNodeSpecialType {
SHADER_SPECIAL_TYPE_BUMP,
};
-/* Enum
- *
- * Utility class for enum values. */
-
-class ShaderEnum {
-public:
- 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) { return left.find(x) != left.end(); }
- bool exists(int y) { return right.find(y) != right.end(); }
-
- int operator[](const char *x) { return left[ustring(x)]; }
- int operator[](ustring x) { return left[x]; }
- ustring operator[](int y) { return right[y]; }
-
-protected:
- map<ustring, int> left;
- map<int, ustring> right;
-};
-
/* Input
*
* Input socket for a shader node. May be linked to an output or not. If not
@@ -118,39 +79,27 @@ protected:
class ShaderInput {
public:
- enum DefaultValue {
- TEXTURE_GENERATED,
- TEXTURE_UV,
- INCOMING,
- NORMAL,
- POSITION,
- TANGENT,
- NONE
- };
-
- enum Usage {
- USE_SVM = 1,
- USE_OSL = 2,
- USE_ALL = USE_SVM|USE_OSL
- };
-
- ShaderInput(ShaderNode *parent, const char *name, ShaderSocketType type);
- void set(const float3& v) { value = v; }
- void set(float f) { value = make_float3(f, 0, 0); }
- void set(const ustring v) { value_string = v; }
-
- const char *name;
- ShaderSocketType type;
+ ShaderInput(ShaderNode *parent, const char *name, SocketType::Type type);
+
+ ustring name() { return name_; }
+ int flags() { return flags_; }
+ SocketType::Type type() { return type_; }
+
+ float3& value() { return value_; }
+ float& value_float() { return value_.x; }
+ ustring& value_string() { return value_string_; }
+
+ ustring name_;
+ SocketType::Type type_;
ShaderNode *parent;
ShaderOutput *link;
- DefaultValue default_value;
- float3 value;
- ustring value_string;
+ float3 value_;
+ ustring value_string_;
int stack_offset; /* for SVM compiler */
- int usage;
+ int flags_;
};
/* Output
@@ -159,12 +108,15 @@ public:
class ShaderOutput {
public:
- ShaderOutput(ShaderNode *parent, const char *name, ShaderSocketType type);
+ ShaderOutput(ShaderNode *parent, const char *name, SocketType::Type type);
- const char *name;
- ShaderNode *parent;
- ShaderSocketType type;
+ ustring name() { return name_; }
+ SocketType::Type type() { return type_; }
+ ustring name_;
+ SocketType::Type type_;
+
+ ShaderNode *parent;
vector<ShaderInput*> links;
int stack_offset; /* for SVM compiler */
@@ -182,11 +134,12 @@ public:
ShaderInput *input(const char *name);
ShaderOutput *output(const char *name);
+ ShaderInput *input(ustring name);
+ ShaderOutput *output(ustring name);
- ShaderInput *add_input(const char *name, ShaderSocketType type, float value=0.0f, int usage=ShaderInput::USE_ALL);
- ShaderInput *add_input(const char *name, ShaderSocketType type, float3 value, int usage=ShaderInput::USE_ALL);
- ShaderInput *add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage=ShaderInput::USE_ALL);
- ShaderOutput *add_output(const char *name, ShaderSocketType type);
+ ShaderInput *add_input(const char *name, SocketType::Type type, float value=0.0f, int flags=0);
+ ShaderInput *add_input(const char *name, SocketType::Type type, float3 value, int flags=0);
+ ShaderOutput *add_output(const char *name, SocketType::Type type);
virtual ShaderNode *clone() const = 0;
virtual void attributes(Shader *shader, AttributeRequestSet *attributes);