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
path: root/intern
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-10-30 15:21:31 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-10-30 15:21:31 +0400
commit06fb71bc4663eba957f8eca423381403eb98deca (patch)
treeb8f166b5d1587e8357e7351aed8b53012899d6c9 /intern
parentc241bf30a0ad192821e3844aeb1017551d8edf36 (diff)
Fix #37194, OSL script crashes blender. The lookup functions for finding Cycles shader inputs/outputs based on socket names are using a few modifications on the Blender socket names. But these only apply
to standard nodes where the Blender socket names can differ from associated Cycles names and may require additional indices to make them unique. Script node sockets are already unique and exact due to being generated from the script function parameters.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/blender_shader.cpp86
-rw-r--r--intern/cycles/render/graph.h3
-rw-r--r--intern/cycles/render/nodes.cpp1
3 files changed, 53 insertions, 37 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index b576181d890..a6d2b537bc7 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -673,59 +673,73 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
return node;
}
+static bool node_use_modified_socket_name(ShaderNode *node)
+{
+ if (node->special_type == SHADER_SPECIAL_TYPE_SCRIPT)
+ return false;
+
+ return true;
+}
+
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
- BL::Node::inputs_iterator b_input;
string name = b_socket.name();
- bool found = false;
- int counter = 0, total = 0;
- for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
- if (b_input->name() == name) {
- if (!found)
- counter++;
- total++;
+ if (node_use_modified_socket_name(node)) {
+ BL::Node::inputs_iterator b_input;
+ bool found = false;
+ int counter = 0, total = 0;
+
+ for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
+ if (b_input->name() == name) {
+ if (!found)
+ counter++;
+ total++;
+ }
+
+ if(b_input->ptr.data == b_socket.ptr.data)
+ found = true;
}
-
- if(b_input->ptr.data == b_socket.ptr.data)
- found = true;
+
+ /* rename if needed */
+ if (name == "Shader")
+ name = "Closure";
+
+ if (total > 1)
+ name = string_printf("%s%d", name.c_str(), counter);
}
- /* rename if needed */
- if (name == "Shader")
- name = "Closure";
-
- if (total > 1)
- name = string_printf("%s%d", name.c_str(), counter);
-
return node->input(name.c_str());
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
- BL::Node::outputs_iterator b_output;
string name = b_socket.name();
- bool found = false;
- int counter = 0, total = 0;
- for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
- if (b_output->name() == name) {
- if (!found)
- counter++;
- total++;
+ if (node_use_modified_socket_name(node)) {
+ BL::Node::outputs_iterator b_output;
+ bool found = false;
+ int counter = 0, total = 0;
+
+ for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
+ if (b_output->name() == name) {
+ if (!found)
+ counter++;
+ total++;
+ }
+
+ if(b_output->ptr.data == b_socket.ptr.data)
+ found = true;
}
-
- if(b_output->ptr.data == b_socket.ptr.data)
- found = true;
+
+ /* rename if needed */
+ if (name == "Shader")
+ name = "Closure";
+
+ if (total > 1)
+ name = string_printf("%s%d", name.c_str(), counter);
}
- /* rename if needed */
- if (name == "Shader")
- name = "Closure";
-
- if (total > 1)
- name = string_printf("%s%d", name.c_str(), counter);
-
return node->output(name.c_str());
}
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 8ebdf3cc220..dfa737115e2 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -75,7 +75,8 @@ enum ShaderNodeSpecialType {
SHADER_SPECIAL_TYPE_PROXY,
SHADER_SPECIAL_TYPE_MIX_CLOSURE,
SHADER_SPECIAL_TYPE_AUTOCONVERT,
- SHADER_SPECIAL_TYPE_GEOMETRY
+ SHADER_SPECIAL_TYPE_GEOMETRY,
+ SHADER_SPECIAL_TYPE_SCRIPT
};
/* Enum
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 621d52bbbbf..5352840d2cb 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3719,6 +3719,7 @@ void SetNormalNode::compile(OSLCompiler& compiler)
OSLScriptNode::OSLScriptNode()
: ShaderNode("osl_script")
{
+ special_type = SHADER_SPECIAL_TYPE_SCRIPT;
}
void OSLScriptNode::compile(SVMCompiler& compiler)