Compositor: Use frame for Map Value node versioning

Ref: #143441

The Map Value node was removed. During versioning, it gets replaced by
other equivalent nodes.
This PR adds a frame around the newly created nodes with a label that
clarifies the reason these nodes were added.

Pull Request: https://projects.blender.org/blender/blender/pulls/143800
This commit is contained in:
Habib Gahbiche
2025-08-05 11:39:56 +02:00
parent e239c7f43c
commit ac134c5a51

View File

@@ -892,6 +892,12 @@ static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
}
}
bNode *frame = blender::bke::node_add_static_node(nullptr, *node_tree, NODE_FRAME);
frame->parent = node->parent;
STRNCPY(frame->label, IFACE_("Versioning: Map Value node was removed"));
NodeFrame *frame_data = static_cast<NodeFrame *>(frame->storage);
frame_data->label_size = 10;
/* If the value input is not connected, add a value node with the computed value. */
if (!value_link) {
const float value = static_cast<bNodeSocketValueFloat *>(value_input->default_value)->value;
@@ -903,7 +909,8 @@ static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
bNode &value_node = version_node_add_empty(*node_tree, "ShaderNodeValue");
bNodeSocket &value_output = version_node_add_socket(
*node_tree, value_node, SOCK_OUT, "NodeSocketFloat", "Value");
value_node.parent = node->parent;
value_node.parent = frame;
value_node.location[0] = node->location[0];
value_node.location[1] = node->location[1];
@@ -939,7 +946,7 @@ static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
bNodeSocket &add_output = version_node_add_socket(
*node_tree, add_node, SOCK_OUT, "NodeSocketFloat", "Value");
add_node.parent = node->parent;
add_node.parent = frame;
add_node.custom1 = NODE_MATH_ADD;
add_node.location[0] = node->location[0];
add_node.location[1] = node->location[1];
@@ -956,7 +963,7 @@ static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
/* Add a multiply node to multiply by the size. */
bNode &multiply_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
multiply_node.parent = node->parent;
multiply_node.parent = frame;
multiply_node.custom1 = NODE_MATH_MULTIPLY;
multiply_node.location[0] = add_node.location[0];
multiply_node.location[1] = add_node.location[1] - 40.0f;
@@ -983,7 +990,7 @@ static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
if (use_min) {
/* Add a maximum node to clamp by the minimum. */
bNode &max_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
max_node.parent = node->parent;
max_node.parent = frame;
max_node.custom1 = NODE_MATH_MAXIMUM;
max_node.location[0] = final_node->location[0];
max_node.location[1] = final_node->location[1] - 40.0f;
@@ -1010,7 +1017,7 @@ static void do_version_map_value_node(bNodeTree *node_tree, bNode *node)
if (use_max) {
/* Add a minimum node to clamp by the maximum. */
bNode &min_node = version_node_add_empty(*node_tree, "ShaderNodeMath");
min_node.parent = node->parent;
min_node.parent = frame;
min_node.custom1 = NODE_MATH_MINIMUM;
min_node.location[0] = final_node->location[0];
min_node.location[1] = final_node->location[1] - 40.0f;