From 1e44bb18321e19a6290721714a6bbe6091576ab4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 23 Mar 2026 18:29:01 +0100 Subject: [PATCH] Optimize Visject native graph connections loading with less loops --- Source/Engine/Visject/Graph.h | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/Source/Engine/Visject/Graph.h b/Source/Engine/Visject/Graph.h index 19aa3e892..700cea17f 100644 --- a/Source/Engine/Visject/Graph.h +++ b/Source/Engine/Visject/Graph.h @@ -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 tmpHints; + Array 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