diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-09-01 12:45:22 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-09-01 12:47:54 +0300 |
commit | 45da7ce177995e0847ba8bf415505b29e0e1413f (patch) | |
tree | 9051f7591556ad92f66539719e44f218642e280b | |
parent | e8be55a4859ac87b215268558e6ee9328033f183 (diff) |
Cycles: Followup fixes for node ownership refactor.
There were some places where nodes still would end up without owners.
See D8540 and 429afe0c626a
-rw-r--r-- | intern/cycles/graph/node.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/render/graph.cpp | 14 |
2 files changed, 9 insertions, 8 deletions
diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp index 14e66959f4f..37387053d97 100644 --- a/intern/cycles/graph/node.cpp +++ b/intern/cycles/graph/node.cpp @@ -692,7 +692,8 @@ const NodeOwner *Node::get_owner() const void Node::set_owner(const NodeOwner *owner_) { - owner_ = owner; + assert(owner_); + owner = owner_; } CCL_NAMESPACE_END diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 684fe6a82c4..485d6167ee3 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -585,7 +585,7 @@ void ShaderGraph::constant_fold(Scene *scene) * that happens to ensure there is still a valid graph for displacement. */ if (has_displacement && !output()->input("Displacement")->link) { - ColorNode *value = (ColorNode *)add(new ColorNode()); + ColorNode *value = (ColorNode *)add(create_node<ColorNode>()); value->value = output()->displacement; connect(value->output("Color"), output()->input("Displacement")); @@ -999,10 +999,10 @@ void ShaderGraph::bump_from_displacement(bool use_object_space) * output, so it can finally set the shader normal, note we are only doing * this for bump from displacement, this will be the only bump allowed to * overwrite the shader normal */ - ShaderNode *set_normal = add(new SetNormalNode()); + ShaderNode *set_normal = add(create_node<SetNormalNode>()); /* add bump node and connect copied graphs to it */ - BumpNode *bump = (BumpNode *)add(new BumpNode()); + BumpNode *bump = (BumpNode *)add(create_node<BumpNode>()); bump->use_object_space = use_object_space; bump->distance = 1.0f; @@ -1012,15 +1012,15 @@ void ShaderGraph::bump_from_displacement(bool use_object_space) ShaderOutput *out_dy = nodes_dy[out->parent]->output(out->name()); /* convert displacement vector to height */ - VectorMathNode *dot_center = (VectorMathNode *)add(new VectorMathNode()); - VectorMathNode *dot_dx = (VectorMathNode *)add(new VectorMathNode()); - VectorMathNode *dot_dy = (VectorMathNode *)add(new VectorMathNode()); + VectorMathNode *dot_center = (VectorMathNode *)add(create_node<VectorMathNode>()); + VectorMathNode *dot_dx = (VectorMathNode *)add(create_node<VectorMathNode>()); + VectorMathNode *dot_dy = (VectorMathNode *)add(create_node<VectorMathNode>()); dot_center->type = NODE_VECTOR_MATH_DOT_PRODUCT; dot_dx->type = NODE_VECTOR_MATH_DOT_PRODUCT; dot_dy->type = NODE_VECTOR_MATH_DOT_PRODUCT; - GeometryNode *geom = (GeometryNode *)add(new GeometryNode()); + GeometryNode *geom = (GeometryNode *)add(create_node<GeometryNode>()); connect(geom->output("Normal"), dot_center->input("Vector2")); connect(geom->output("Normal"), dot_dx->input("Vector2")); connect(geom->output("Normal"), dot_dy->input("Vector2")); |