Cluster reimport fixes
This commit is contained in:
parent
befb69d00c
commit
8801fa2ff2
@ -439,9 +439,24 @@ namespace NanoBrain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ReimportCluster(Cluster subCluster) {
|
private void ReimportCluster(Cluster subCluster) {
|
||||||
Cluster reimportedCluster = new(subCluster.prefab, this.prefab);
|
if (subCluster.siblingClusters == null || subCluster.siblingClusters.Length <= 0) {
|
||||||
subCluster.MoveReceivers(reimportedCluster);
|
Cluster reimportedCluster = new(subCluster.prefab, this.prefab);
|
||||||
// subcluster should be garbage now...
|
subCluster.MoveReceivers(reimportedCluster);
|
||||||
|
// subcluster should be garbage now...
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<Cluster> newSiblingsList = new();
|
||||||
|
foreach (Cluster sibling in subCluster.siblingClusters) {
|
||||||
|
Cluster reimportedCluster = new(sibling.prefab, this.prefab) {
|
||||||
|
name = sibling.name
|
||||||
|
};
|
||||||
|
sibling.MoveReceivers(reimportedCluster);
|
||||||
|
newSiblingsList.Add(reimportedCluster);
|
||||||
|
}
|
||||||
|
Cluster[] newSiblings = newSiblingsList.ToArray();
|
||||||
|
foreach (Cluster sibling in newSiblings)
|
||||||
|
sibling.siblingClusters = newSiblings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int selectedConnectNucleus = -1;
|
int selectedConnectNucleus = -1;
|
||||||
|
|||||||
@ -402,6 +402,8 @@ namespace NanoBrain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool SameSiblingsAs(Cluster[] otherSiblingClusters) {
|
public bool SameSiblingsAs(Cluster[] otherSiblingClusters) {
|
||||||
|
if (this.siblingClusters == null)
|
||||||
|
return false;
|
||||||
for (int ix = 0; ix < this.siblingClusters.Length; ix++) {
|
for (int ix = 0; ix < this.siblingClusters.Length; ix++) {
|
||||||
if (this.siblingClusters[ix] != otherSiblingClusters[ix])
|
if (this.siblingClusters[ix] != otherSiblingClusters[ix])
|
||||||
return false;
|
return false;
|
||||||
@ -592,23 +594,23 @@ namespace NanoBrain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void MoveReceivers(Cluster newCluster) {
|
public void MoveReceivers(Cluster newCluster) {
|
||||||
|
Debug.Log($"Move receivers for {this.name} to {newCluster.name}");
|
||||||
foreach (Nucleus outputNucleus in this.clusterNuclei) {
|
foreach (Nucleus outputNucleus in this.clusterNuclei) {
|
||||||
if (outputNucleus is not Neuron output)
|
if (outputNucleus is not Neuron output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Find the existing output in the new cluster
|
// Find the existing output in the new cluster
|
||||||
if (newCluster.GetNucleus(output.name) is not Neuron newOutput) {
|
if (newCluster.GetNucleus(output.name) is not Neuron newOutput) {
|
||||||
Debug.LogWarning("Could not find output {output.name} in {newCluster.name}");
|
Debug.LogWarning($"Could not find output {this.name}.{output.name} in {newCluster.name}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Debug.Log($"Check {output.name} receivers");
|
Debug.Log($"Check {this.name}.{output.name} receivers");
|
||||||
Nucleus[] receivers = output.receivers.ToArray();
|
Nucleus[] receivers = output.receivers.ToArray();
|
||||||
foreach (Nucleus receiver in receivers) {
|
foreach (Nucleus receiver in receivers) {
|
||||||
Debug.Log(".");
|
|
||||||
if (receiver.clusterPrefab != this.prefab) {
|
if (receiver.clusterPrefab != this.prefab) {
|
||||||
// Replace synapse with new synapse
|
// Replace synapse with new synapse
|
||||||
// to the new cluster
|
// to the new cluster
|
||||||
Debug.Log($"move {receiver.name} from {output.name} to {newOutput.name}");
|
Debug.Log($"move {receiver.name} from {this.name}.{output.name} to {newCluster.name}.{newOutput.name}");
|
||||||
Synapse synapse = receiver.GetSynapse(output);
|
Synapse synapse = receiver.GetSynapse(output);
|
||||||
newOutput.AddReceiver(receiver, synapse.weight);
|
newOutput.AddReceiver(receiver, synapse.weight);
|
||||||
output.RemoveReceiver(receiver);
|
output.RemoveReceiver(receiver);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user