[Bf-blender-cvs] [1422f0dd] master: Fix Cycles external OSL shader not working with relative file paths.
Brecht Van Lommel
noreply at git.blender.org
Sun May 1 01:45:53 CEST 2016
Commit: 1422f0dd1697d7b671a7b447fd58db7dfe775821
Author: Brecht Van Lommel
Date: Sun May 1 00:50:49 2016 +0200
Branches: master
https://developer.blender.org/rB1422f0dd1697d7b671a7b447fd58db7dfe775821
Fix Cycles external OSL shader not working with relative file paths.
===================================================================
M intern/cycles/blender/blender_shader.cpp
M intern/cycles/render/nodes.h
===================================================================
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index ba806e2..3f919bc 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -602,12 +602,14 @@ static ShaderNode *add_node(Scene *scene,
* input/output type info needed for proper node construction.
*/
OSL::OSLQuery query;
+ string absolute_filepath;
if(!bytecode_hash.empty()) {
query.open_bytecode(b_script_node.bytecode());
}
else {
- OSLShaderManager::osl_query(query, b_script_node.filepath());
+ absolute_filepath = blender_absolute_path(b_data, b_ntree, b_script_node.filepath());
+ OSLShaderManager::osl_query(query, absolute_filepath);
}
/* TODO(sergey): Add proper query info error parsing. */
@@ -617,12 +619,11 @@ static ShaderNode *add_node(Scene *scene,
* so the names match those of the corresponding parameters exactly.
*
* Note 2: ShaderInput/ShaderOutput store shallow string copies only!
- * Socket names must be stored in the extra lists instead. */
+ * So we register them as ustring to ensure the pointer stays valid. */
BL::Node::inputs_iterator b_input;
for(b_script_node.inputs.begin(b_input); b_input != b_script_node.inputs.end(); ++b_input) {
- script_node->input_names.push_back(ustring(b_input->name()));
- ShaderInput *input = script_node->add_input(script_node->input_names.back().c_str(),
+ ShaderInput *input = script_node->add_input(ustring(b_input->name()).c_str(),
convert_osl_socket_type(query, *b_input));
set_default_value(input, *b_input, b_data, b_ntree);
}
@@ -630,8 +631,7 @@ static ShaderNode *add_node(Scene *scene,
BL::Node::outputs_iterator b_output;
for(b_script_node.outputs.begin(b_output); b_output != b_script_node.outputs.end(); ++b_output) {
- script_node->output_names.push_back(ustring(b_output->name()));
- script_node->add_output(script_node->output_names.back().c_str(),
+ script_node->add_output(ustring(b_output->name()).c_str(),
convert_osl_socket_type(query, *b_output));
}
@@ -645,7 +645,7 @@ static ShaderNode *add_node(Scene *scene,
}
else {
/* set filepath */
- script_node->filepath = blender_absolute_path(b_data, b_ntree, b_script_node.filepath());
+ script_node->filepath = absolute_filepath;
}
node = script_node;
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 7400770..0b3ab68 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -977,11 +977,6 @@ public:
string filepath;
string bytecode_hash;
- /* ShaderInput/ShaderOutput only stores a shallow string copy (const char *)!
- * The actual socket names have to be stored externally to avoid memory errors. */
- vector<ustring> input_names;
- vector<ustring> output_names;
-
virtual bool equals(const ShaderNode * /*other*/) { return false; }
};
More information about the Bf-blender-cvs
mailing list