Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph corruption #21

Open
khalimwu opened this issue Sep 21, 2021 · 0 comments
Open

Graph corruption #21

khalimwu opened this issue Sep 21, 2021 · 0 comments

Comments

@khalimwu
Copy link

khalimwu commented Sep 21, 2021

More than once i'm getting data from an old graph setting. For example if at some past moment i had 2 nodes in a random future day i get corruption due to a node being null. (only 1 node is really present on the graph but 2 nodes are present internally, only 1 being valid and the other being a null pointer). The issue is fixed forcing save, however it has happened to me that even then, after a couple days, the blueprint is corrupted again.

Probably the most important change is this one where i do check if an edge was already present

`bool UAssetGraphSchema_GenericGraph::CreateAutomaticConversionNodeAndConnections(UEdGraphPin* A, UEdGraphPin* B) const
{
UEdNode_GenericGraphNode* NodeA = Cast<UEdNode_GenericGraphNode>(A->GetOwningNode());
UEdNode_GenericGraphNode* NodeB = Cast<UEdNode_GenericGraphNode>(B->GetOwningNode());

// Are nodes and pins all valid?
if (!NodeA || !NodeA->GetOutputPin() || !NodeB || !NodeB->GetInputPin())
	return false;
	
// My code: if we are creating a connection between two nodes that already got a connection, skip it.
if ( A->Direction == EGPD_Output )
{
	if ( NodeA->GenericGraphNode &&
		 NodeA->GenericGraphNode->GetEdge( NodeB->GenericGraphNode ) )
		return false;
}
else
{
	if ( NodeB->GenericGraphNode &&
		 NodeB->GenericGraphNode->GetEdge( NodeA->GenericGraphNode ) )
		return false;
}
//

UGenericGraph* Graph = NodeA->GenericGraphNode->GetGraph();

FVector2D InitPos((NodeA->NodePosX + NodeB->NodePosX) / 2, (NodeA->NodePosY + NodeB->NodePosY) / 2);

FAssetSchemaAction_GenericGraph_NewEdge Action;
Action.NodeTemplate = NewObject<UEdNode_GenericGraphEdge>(NodeA->GetGraph());
Action.NodeTemplate->SetEdge(NewObject<UGenericGraphEdge>(Action.NodeTemplate, Graph->EdgeType));
UEdNode_GenericGraphEdge* EdgeNode = Cast<UEdNode_GenericGraphEdge>(Action.PerformAction(NodeA->GetGraph(), nullptr, InitPos, false));

// Always create connections from node A to B, don't allow adding in reverse
EdgeNode->CreateConnections(NodeA, NodeB);

return true;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant