Skip to content

Commit

Permalink
#5643: Conflicts of type "ModificationOfRemovedEntity" transform into…
Browse files Browse the repository at this point in the history
… AddEntityNodes on accept. To see what's going on, the removed node needs to be added to the target scene for preview purposes.
  • Loading branch information
codereader committed Jun 20, 2021
1 parent 24cf022 commit d5bdd83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 16 additions & 3 deletions radiantcore/map/MergeActionNode.cpp
Expand Up @@ -303,10 +303,23 @@ bool RegularMergeActionNode::hasActiveActions()
return _action && _action->isActive();
}

std::shared_ptr<scene::merge::AddCloneToParentAction> RegularMergeActionNode::getAddNodeAction()
{
// In case this is a conflicting source action modified an entity that is no longer present, add the old node
auto conflictAction = std::dynamic_pointer_cast<scene::merge::IConflictResolutionAction>(_action);

if (conflictAction && conflictAction->getConflictType() == scene::merge::ConflictType::ModificationOfRemovedEntity)
{
return std::dynamic_pointer_cast<scene::merge::AddCloneToParentAction>(conflictAction->getSourceAction());
}

// Check the regular action for type AddEntityNode
return std::dynamic_pointer_cast<scene::merge::AddCloneToParentAction>(_action);
}

void RegularMergeActionNode::addPreviewNodeForAddAction()
{
// We add the node to the target scene, for preview purposes
auto addNodeAction = std::dynamic_pointer_cast<scene::merge::AddCloneToParentAction>(_action);
auto addNodeAction = getAddNodeAction();

if (addNodeAction)
{
Expand All @@ -317,7 +330,7 @@ void RegularMergeActionNode::addPreviewNodeForAddAction()

void RegularMergeActionNode::removePreviewNodeForAddAction()
{
auto addNodeAction = std::dynamic_pointer_cast<scene::merge::AddCloneToParentAction>(_action);
auto addNodeAction = getAddNodeAction();

if (addNodeAction)
{
Expand Down
2 changes: 2 additions & 0 deletions radiantcore/map/MergeActionNode.h
Expand Up @@ -118,6 +118,8 @@ class RegularMergeActionNode final :
private:
void addPreviewNodeForAddAction();
void removePreviewNodeForAddAction();

std::shared_ptr<scene::merge::AddCloneToParentAction> getAddNodeAction();
};

}

0 comments on commit d5bdd83

Please sign in to comment.