From 527f8b32b32187f754e5b176db6377736f9cb8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Mon, 26 Oct 2020 21:00:37 +0100 Subject: Cycles API: encapsulate Node socket members This encapsulates Node socket members behind a set of specific methods; as such it is no longer possible to directly access Node class members from exporters and parts of Cycles. The methods are defined via the NODE_SOCKET_API macros in `graph/ node.h`, and are for getting or setting a specific socket's value, as well as querying or modifying the state of its update flag. The setters will check whether the value has changed and tag the socket as modified appropriately. This will let us know how a Node has changed and what to update, which is the first concrete step toward a more granular scene update system. Since the setters will tag the Node sockets as modified when passed different data, this patch also removes the various `modified` methods on Nodes in favor of `Node::is_modified` which checks the sockets' update flags status. Reviewed By: brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D8544 --- intern/cycles/render/graph.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'intern/cycles/render/graph.cpp') diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 485d6167ee3..1de48aa8b0d 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -273,8 +273,8 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to) if (to->type() == SocketType::CLOSURE) { EmissionNode *emission = create_node(); - emission->color = make_float3(1.0f, 1.0f, 1.0f); - emission->strength = 1.0f; + emission->set_color(make_float3(1.0f, 1.0f, 1.0f)); + emission->set_strength(1.0f); convert = add(emission); /* Connect float inputs to Strength to save an additional Falue->Color conversion. */ if (from->type() == SocketType::FLOAT) { @@ -586,7 +586,7 @@ void ShaderGraph::constant_fold(Scene *scene) */ if (has_displacement && !output()->input("Displacement")->link) { ColorNode *value = (ColorNode *)add(create_node()); - value->value = output()->displacement; + value->set_value(output()->get_displacement()); connect(value->output("Color"), output()->input("Displacement")); } @@ -1003,8 +1003,8 @@ void ShaderGraph::bump_from_displacement(bool use_object_space) /* add bump node and connect copied graphs to it */ BumpNode *bump = (BumpNode *)add(create_node()); - bump->use_object_space = use_object_space; - bump->distance = 1.0f; + bump->set_use_object_space(use_object_space); + bump->set_distance(1.0f); ShaderOutput *out = displacement_in->link; ShaderOutput *out_center = nodes_center[out->parent]->output(out->name()); @@ -1016,9 +1016,9 @@ void ShaderGraph::bump_from_displacement(bool use_object_space) VectorMathNode *dot_dx = (VectorMathNode *)add(create_node()); VectorMathNode *dot_dy = (VectorMathNode *)add(create_node()); - dot_center->type = NODE_VECTOR_MATH_DOT_PRODUCT; - dot_dx->type = NODE_VECTOR_MATH_DOT_PRODUCT; - dot_dy->type = NODE_VECTOR_MATH_DOT_PRODUCT; + dot_center->set_math_type(NODE_VECTOR_MATH_DOT_PRODUCT); + dot_dx->set_math_type(NODE_VECTOR_MATH_DOT_PRODUCT); + dot_dy->set_math_type(NODE_VECTOR_MATH_DOT_PRODUCT); GeometryNode *geom = (GeometryNode *)add(create_node()); connect(geom->output("Normal"), dot_center->input("Vector2")); @@ -1072,7 +1072,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight if (fin->link) connect(fin->link, fac_in); else - mix_node->fac = node->get_float(fin->socket_type); + mix_node->set_fac(node->get_float(fin->socket_type)); if (weight_out) connect(weight_out, weight_in); @@ -1107,12 +1107,12 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight if (weight_in->link) connect(weight_in->link, math_node->input("Value1")); else - math_node->value1 = weight_value; + math_node->set_value1(weight_value); if (weight_out) connect(weight_out, math_node->input("Value2")); else - math_node->value2 = 1.0f; + math_node->set_value2(1.0f); weight_out = math_node->output("Value"); if (weight_in->link) -- cgit v1.2.3