From 4f8a6abbe9379097ba7b12cdcb4955ccf439917e Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Thu, 23 Apr 2026 11:50:59 +0200 Subject: [PATCH] Improved (but not fixed) cross-cluster monitoring --- Editor/ClusterViewer.cs | 49 ++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/Editor/ClusterViewer.cs b/Editor/ClusterViewer.cs index 1af3311..fabe732 100644 --- a/Editor/ClusterViewer.cs +++ b/Editor/ClusterViewer.cs @@ -245,7 +245,7 @@ namespace NanoBrain { float maxValue = 1; if (this.currentNucleus is Cluster cluster) { - float spacing = 400f / cluster.siblingClusters.Length; + float spacing = 400f / cluster.instanceCount; float margin = 10 + spacing / 2; float xMin = 150 - size; float xMax = 150 + size; @@ -260,14 +260,24 @@ namespace NanoBrain { Handles.color = Color.black; Handles.DrawAAConvexPolygon(verts); int row = 0; - foreach (Cluster sibling in cluster.siblingClusters) { + if (cluster.siblingClusters == null) { Vector3 pos = new(150, margin + row * spacing, 0.0f); Handles.color = Color.white; // The selected sibling highlight ring Handles.DrawSolidDisc(pos, Vector3.forward, size + 2); - DrawNucleus(sibling, pos, maxValue, size); + DrawNucleus(cluster, pos, maxValue, size); row++; } + else { + foreach (Cluster sibling in cluster.siblingClusters) { + Vector3 pos = new(150, margin + row * spacing, 0.0f); + Handles.color = Color.white; + // The selected sibling highlight ring + Handles.DrawSolidDisc(pos, Vector3.forward, size + 2); + DrawNucleus(sibling, pos, maxValue, size); + row++; + } + } GUIStyle style = new(EditorStyles.label) { alignment = TextAnchor.UpperCenter, normal = { textColor = Color.white }, @@ -316,11 +326,14 @@ namespace NanoBrain { else return; - // For top-level nodes, add link to previous editor or 'all-outputs' + // For top-level nodes, add link to previous editor and/or 'Outputs' int nodeCount = receivers.Count(); - if (nucleus == this.selectedOutput) {// && ClusterViewer.previousPrefab != null) { - // Add link to previous editor + if (nucleus == this.selectedOutput) { + // Add link to 'Outpus' nodeCount++; + if (ClusterViewer.previousPrefab != null) + // Add link to previous editor + nodeCount++; } // Determine the maximum value in this layer @@ -353,11 +366,14 @@ namespace NanoBrain { } if (nucleus == this.selectedOutput) { Vector3 pos = new(50, margin + row * spacing, 0); - DrawEdge(parentPos, pos); - if (ClusterViewer.previousPrefab != null) + if (ClusterViewer.previousPrefab != null) { + DrawEdge(parentPos, pos); DrawClusterPrefab(ClusterViewer.previousPrefab, pos, size); - else - DrawAllOutputs(pos, size); + row++; + } + pos = new(50, margin + row * spacing, 0); + DrawEdge(parentPos, pos); + DrawAllOutputs(pos, size); } } @@ -658,7 +674,7 @@ namespace NanoBrain { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter, }; - Handles.Label(position, "All\noutputs", labelTextStyle); + Handles.Label(position, "Outputs", labelTextStyle); Rect neuronRect = new(position.x - size, position.y - size, size * 2, size * 2); Event e = Event.current; @@ -711,8 +727,15 @@ namespace NanoBrain { protected void OnNeuronClick(Nucleus nucleus) { if (nucleus == this.currentNucleus) { if (Application.isPlaying) { - if (nucleus is Cluster) - expandArray = !expandArray; + if (nucleus is Cluster cluster) { + if (expandArray) { + this.currentNucleus = cluster.defaultOutput; + if (this.currentNucleus is Neuron neuron && neuron.receivers.Count == 0) + this.selectedOutput = this.currentNucleus; expandArray = false; + } + else + expandArray = !expandArray; + } else expandArray = false; }