Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Source/FlowEditor/Private/Asset/AssetDefinition_FlowAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Asset/SFlowDiff.h"
#include "FlowEditorModule.h"
#include "Graph/FlowGraphSettings.h"
#include "Graph/FlowGraph.h"

#include "FlowAsset.h"

Expand Down Expand Up @@ -63,6 +64,21 @@ EAssetCommandResult UAssetDefinition_FlowAsset::PerformAssetDiff(const FAssetDif
const UFlowAsset* OldFlow = Cast<UFlowAsset>(DiffArgs.OldAsset);
const UFlowAsset* NewFlow = Cast<UFlowAsset>(DiffArgs.NewAsset);

auto SetupGraph = [](const UFlowAsset* Asset)
{
if (IsValid(Asset))
{
UFlowGraph* FlowGraph = Cast<UFlowGraph>(Asset->GetGraph());
if (IsValid(FlowGraph)) // can it be invalid?
{
FlowGraph->OnLoaded(); // mainly for filling parent nodes for add-ons, because they are transient
}
}
};

SetupGraph(OldFlow);
SetupGraph(NewFlow);

// sometimes we're comparing different revisions of one single asset (other
// times we're comparing two completely separate assets altogether)
const bool bIsSingleAsset = !IsValid(OldFlow) || !IsValid(NewFlow) || (OldFlow->GetName() == NewFlow->GetName());
Expand Down
35 changes: 13 additions & 22 deletions Source/FlowEditor/Private/Asset/FlowDiffControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void FFlowGraphToDiff::GenerateTreeEntries(TArray<TSharedPtr<FBlueprintDifferenc
continue;
}

FlowNodeDiff->ParentNodeDiff = FindParentNode(Cast<UFlowGraphNode>(Node1));
FlowNodeDiff->ParentNodeDiff = FindParentDiff(Cast<UFlowGraphNode>(Node1));
if (FlowNodeDiff->ParentNodeDiff.IsValid())
{
const TSharedPtr<FFlowObjectDiff> ParentNode = FlowNodeDiff->ParentNodeDiff.Pin();
Expand Down Expand Up @@ -341,44 +341,35 @@ TSharedPtr<FFlowObjectDiff> FFlowGraphToDiff::GenerateFlowObjectDiff(const TShar
return NewFlowObjectDiff;
}

TSharedPtr<FFlowObjectDiff> FFlowGraphToDiff::FindParentNode(UFlowGraphNode* Node)
TSharedPtr<FFlowObjectDiff> FFlowGraphToDiff::FindParentDiff(UFlowGraphNode* Node)
{
if (!IsValid(Node))
{
return nullptr;
}

const UFlowGraphNode* ParentNode = Node->GetParentNode();
for (auto& FlowNodeDiff : FlowObjectDiffsByNodeName)
while ( IsValid( ParentNode ) )
{
//don't allow a pin diff be the parent of anything.
if (FlowNodeDiff.Value->DiffResult->Result.Pin1)
for (auto& FlowNodeDiff : FlowObjectDiffsByNodeName)
{
continue;
}
//if parent node is set, use that.
if (IsValid(ParentNode))
{
if (FlowNodeDiff.Value->DiffResult->Result.Node1 == ParentNode
|| FlowNodeDiff.Value->DiffResult->Result.Node2 == ParentNode)
//don't allow a pin diff be the parent of anything.
if (FlowNodeDiff.Value->DiffResult->Result.Pin1)
{
return FlowNodeDiff.Value;
continue;
}
}
//if parent node is not set (not set in node removal changes for some reason),
//try to find the parent in the SubNodes of known node changes.
else
{
const UFlowGraphNode* NodeToCheck = Cast<UFlowGraphNode>(FlowNodeDiff.Value->DiffResult->Result.Node1);
if (IsValid(NodeToCheck))
//if parent node is set, use that.
if (IsValid(ParentNode))
{
const int32 Index = NodeToCheck->SubNodes.Find(Node);
if (Index != INDEX_NONE)
if (FlowNodeDiff.Value->DiffResult->Result.Node1 == ParentNode
|| FlowNodeDiff.Value->DiffResult->Result.Node2 == ParentNode)
{
return FlowNodeDiff.Value;
}
}
}

ParentNode = ParentNode->GetParentNode();
}

return nullptr;
Expand Down
Loading