Skip to content

Commit

Permalink
#5639: Nodes that are explicitly kept by the user won't have their la…
Browse files Browse the repository at this point in the history
…yers modified
  • Loading branch information
codereader committed Jun 8, 2021
1 parent 8e64384 commit 245ce0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 6 additions & 0 deletions libs/scene/merge/LayerMerger.h
Expand Up @@ -321,6 +321,12 @@ class LayerMerger
continue;
}

// We keep all the layer memberships of nodes that the user wants to keep
if (_sourceNodes.count(pair.first) == 0)
{
continue;
}

_log << "Marking node " << baseNode->second->name() << " for removal from layer " << sourceLayerName << std::endl;
_baseNodesToRemoveFromLayers.emplace_back(std::make_pair(baseLayerId, baseNode->second));
}
Expand Down
9 changes: 3 additions & 6 deletions test/MapMerging.cpp
Expand Up @@ -1651,7 +1651,9 @@ TEST_F(LayerMergeTest, KeptNodesInRemovedLayer)

merger->adjustBaseLayers();

EXPECT_FALSE(merger->getChangeLog().empty());
// We expect no changes, since nothing else apart of the two brushes has changed
// The presence of the "8" brushes preserve the "8" layer, and therefore no change is registered
EXPECT_TRUE(merger->getChangeLog().empty());

// No removed layers
EXPECT_EQ(changeCountByType(merger->getChangeLog(), LayerMerger::Change::Type::BaseLayerCreated), 0);
Expand All @@ -1663,11 +1665,6 @@ TEST_F(LayerMergeTest, KeptNodesInRemovedLayer)
// The 8 brush must be part of this layer, and the "Shared" one too
EXPECT_TRUE(nodeIsMemberOfLayer(brush8, { "Shared", "8" }));
EXPECT_EQ(brush8->getLayers().size(), 2); // still part of "8" and "Shared"

// Finally run another merger across the scene, it shouldn't find anything to do
merger = std::make_unique<LayerMerger>(merger->getSourceRoot(), merger->getBaseRoot());
merger->adjustBaseLayers();
EXPECT_TRUE(merger->getChangeLog().empty());
}

// Layer "8" has been renamed to "8 renamed"
Expand Down

0 comments on commit 245ce0e

Please sign in to comment.