Fix #135200: Linking linking artifacts with light trees

Ensure that the light tree flattening code does not try to
share node in cases when we need to modify its bit trail.

Pull Request: https://projects.blender.org/blender/blender/pulls/135249
This commit is contained in:
Sergey Sharybin
2025-02-28 10:42:29 +01:00
committed by Sergey Sharybin
parent c4e9cc18c5
commit b9c727e255
+7 -3
View File
@@ -687,7 +687,8 @@ static std::pair<int, LightTreeMeasure> light_tree_specialize_nodes_flatten(
const uint64_t light_link_mask,
const int depth,
vector<KernelLightTreeNode> &knodes,
int &next_node_index)
int &next_node_index,
bool can_share = true)
{
assert(!node->is_instance());
@@ -703,7 +704,7 @@ static std::pair<int, LightTreeMeasure> light_tree_specialize_nodes_flatten(
node_index = next_node_index++;
new_node.make_leaf(-1, 0);
}
else if (node->light_link.shareable && node->light_link.shared_node_index != -1) {
else if (can_share && node->light_link.shareable && node->light_link.shared_node_index != -1) {
/* Share subtree already built for another light link set. */
return std::make_pair(node->light_link.shared_node_index, node->measure);
}
@@ -755,8 +756,11 @@ static std::pair<int, LightTreeMeasure> light_tree_specialize_nodes_flatten(
only_node = left_node;
}
if (only_node) {
/* Can not share the node as its bit_skip will be modified.
* Also don't store shareable_index so other branches of the tree that do not skip any nodes
* do not share node created here. */
const auto [only_index, only_measure] = light_tree_specialize_nodes_flatten(
flatten, only_node, light_link_mask, depth + 1, knodes, next_node_index);
flatten, only_node, light_link_mask, depth + 1, knodes, next_node_index, false);
assert(only_index != -1);
knodes[only_index].bit_skip++;