Optimize Visject native graph connections loading with less loops

This commit is contained in:
Wojtek Figat
2026-03-23 18:29:01 +01:00
parent 3baec506e2
commit 1e44bb1832

View File

@@ -27,8 +27,9 @@ public:
typedef ParameterType Parameter;
private:
struct TmpConnectionHint
struct PendingConnectionHint
{
GraphBox** Target;
Node* Node;
byte BoxID;
};
@@ -177,7 +178,7 @@ public:
uint32 version;
stream->ReadUint32(&version);
Array<TmpConnectionHint> tmpHints;
Array<PendingConnectionHint> tmpHints;
if (version < 7000)
{
LOG(Warning, "Not supported Visject Surface version. Open and re-save asset with Flax 1.11.");
@@ -252,12 +253,12 @@ public:
uint32 targetNodeID;
stream->ReadUint32(&targetNodeID);
byte targetBoxID = stream->ReadByte();
TmpConnectionHint hint;
PendingConnectionHint hint;
hint.Node = GetNode(targetNodeID);
if (hint.Node == nullptr)
return true;
hint.BoxID = targetBoxID;
box->Connections[k] = (Box*)(intptr)tmpHints.Count();
hint.Target = &box->Connections[k];
tmpHints.Add(hint);
}
}
@@ -275,21 +276,10 @@ public:
return true;
// Setup connections
for (int32 i = 0; i < Nodes.Count(); i++)
for (int32 hintIndex = 0; hintIndex < tmpHints.Count(); hintIndex++)
{
auto node = &Nodes[i];
for (int32 j = 0; j < node->Boxes.Count(); j++)
{
Box* box = &node->Boxes[j];
if (box->Parent == nullptr)
continue;
for (int32 k = 0; k < box->Connections.Count(); k++)
{
int32 hintIndex = (int32)(intptr)box->Connections[k];
TmpConnectionHint hint = tmpHints[hintIndex];
box->Connections[k] = hint.Node->GetBox(hint.BoxID);
}
}
PendingConnectionHint hint = tmpHints[hintIndex];
*hint.Target = hint.Node->GetBox(hint.BoxID);
}
// Ending char