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@pandora.be>2013-05-10 19:10:54 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-10 19:10:54 +0400
commit8e9b6daa8ea5d47fad5e9ec4e8a75c2df7f9b2dc (patch)
treec97c7424ae2aa1a999f008b9592e1754953146e3 /intern/cycles
parent65ed588c8b68b4bbea0e48a0222f5e8844774bd9 (diff)
Fix for recent bugfix with anisotropic node crash, could do invalid memory access.
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/render/graph.cpp13
-rw-r--r--intern/cycles/render/graph.h1
2 files changed, 8 insertions, 6 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index f081e2db7af..6f8082487d4 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -135,6 +135,7 @@ void ShaderNode::attributes(AttributeRequestSet *attributes)
ShaderGraph::ShaderGraph()
{
finalized = false;
+ num_node_ids = 0;
add(new OutputNode());
}
@@ -147,7 +148,7 @@ ShaderGraph::~ShaderGraph()
ShaderNode *ShaderGraph::add(ShaderNode *node)
{
assert(!finalized);
- node->id = nodes.size();
+ node->id = num_node_ids++;
nodes.push_back(node);
return node;
}
@@ -314,7 +315,7 @@ void ShaderGraph::copy_nodes(set<ShaderNode*>& nodes, map<ShaderNode*, ShaderNod
void ShaderGraph::remove_unneeded_nodes()
{
- vector<bool> removed(nodes.size(), false);
+ vector<bool> removed(num_node_ids, false);
bool any_node_removed = false;
/* find and unlink proxy nodes */
@@ -459,11 +460,9 @@ void ShaderGraph::clean()
* nodes that don't feed into the output. how cycles are broken is
* undefined, they are invalid input, the important thing is to not crash */
- vector<bool> visited(nodes.size(), false);
- vector<bool> on_stack(nodes.size(), false);
+ vector<bool> visited(num_node_ids, false);
+ vector<bool> on_stack(num_node_ids, false);
- list<ShaderNode*> newnodes;
-
/* break cycles */
break_cycles(output(), visited, on_stack);
@@ -482,6 +481,8 @@ void ShaderGraph::clean()
}
/* remove unused nodes */
+ list<ShaderNode*> newnodes;
+
foreach(ShaderNode *node, nodes) {
if(visited[node->id])
newnodes.push_back(node);
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 8e91a9ddc07..5c4a44af3fc 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -226,6 +226,7 @@ public:
class ShaderGraph {
public:
list<ShaderNode*> nodes;
+ size_t num_node_ids;
bool finalized;
ShaderGraph();