From 2af597fbdbbb214d63f277d7973dbb60436c681a Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 11 Feb 2026 15:05:11 +0100 Subject: [PATCH] improved pheromone steering --- Editor/ClusterInspector.cs | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/Editor/ClusterInspector.cs b/Editor/ClusterInspector.cs index 6d94ed5..9728495 100644 --- a/Editor/ClusterInspector.cs +++ b/Editor/ClusterInspector.cs @@ -572,13 +572,18 @@ public class ClusterInspector : Editor { if (showSynapses) { anythingChanged = ConnectNucleus(this.prefab, this.currentNucleus); - AddSynapse(this.prefab, this.currentNucleus); + anythingChanged = AddSynapse(this.prefab, this.currentNucleus); EditorGUILayout.Space(); - if (this.currentNucleus is Neuron neuron2) - neuron2.combinator = (Neuron.CombinatorType)EditorGUILayout.EnumPopup("Combinator", neuron2.combinator); + if (this.currentNucleus is Neuron neuron2) { + Neuron.CombinatorType newCombinator = (Neuron.CombinatorType)EditorGUILayout.EnumPopup("Combinator", neuron2.combinator); + anythingChanged |= newCombinator != neuron2.combinator; + neuron2.combinator = newCombinator; + } - this.currentNucleus.bias = EditorGUILayout.Vector3Field("Bias", this.currentNucleus.bias); + Vector3 newBias = EditorGUILayout.Vector3Field("Bias", this.currentNucleus.bias); + anythingChanged |= newBias != this.currentNucleus.bias; + this.currentNucleus.bias = newBias; NucleusArray array = null; if (this.currentNucleus.synapses.Count > 0) { @@ -682,10 +687,11 @@ public class ClusterInspector : Editor { void OnSceneGUI(SceneView sceneView) { if (this.gameObject != null) { - Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue); - // worldVector = worldVector.normalized; - Handles.color = Color.yellow; - Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); + foreach (Nucleus nucleus in this.currentNucleus.array.nuclei) { + Vector3 worldVector = this.gameObject.transform.TransformVector(nucleus.outputValue); + Handles.color = Color.yellow; + Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); + } } } @@ -824,17 +830,16 @@ public class ClusterInspector : Editor { return true; } - protected virtual void AddSynapse(ClusterPrefab cluster, Nucleus nucleus) { + protected virtual bool AddSynapse(ClusterPrefab cluster, Nucleus nucleus) { if (cluster == null) - return; + return false; - //string[] options = { "Neuron", "MemoryCell", "Selector", "Cluster" }; - //int selectedInputType = -1; - //selectedInputType = EditorGUILayout.Popup("Add", selectedInputType, options); - //if (selectedInputType >= 0) Nucleus.Type selectedType = (Nucleus.Type)EditorGUILayout.EnumPopup("Add", Nucleus.Type.None); - if (selectedType != Nucleus.Type.None) - AddInput(selectedType, this.currentNucleus); + if (selectedType == Nucleus.Type.None) + return false; + + AddInput(selectedType, this.currentNucleus); + return true; } protected virtual void DisconnectNucleus(Neuron nucleus) {