Improved subcluster support
This commit is contained in:
parent
c6d9f727c0
commit
b556aa62fc
@ -8,9 +8,16 @@ public class Cluster : ScriptableObject, INucleus {
|
|||||||
|
|
||||||
public Cluster cluster => this;
|
public Cluster cluster => this;
|
||||||
|
|
||||||
|
// The ScriptableObject asset from which the runtime object has been created
|
||||||
|
public Cluster asset;
|
||||||
|
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
public List<IReceptor> nuclei = new();
|
public List<IReceptor> nuclei = new();
|
||||||
|
|
||||||
public List<Cluster> subClusters = new();
|
public List<Cluster> subClusters = new();
|
||||||
|
public void AddSubCluster(Cluster subCluster) {
|
||||||
|
this.subClusters.Add(subCluster);
|
||||||
|
}
|
||||||
|
|
||||||
public INucleus output => this.nuclei[0] as INucleus;
|
public INucleus output => this.nuclei[0] as INucleus;
|
||||||
|
|
||||||
|
|||||||
@ -13,18 +13,19 @@ MonoBehaviour:
|
|||||||
m_Name: Identity
|
m_Name: Identity
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Cluster
|
m_EditorClassIdentifier: Assembly-CSharp::Cluster
|
||||||
nuclei:
|
nuclei:
|
||||||
- rid: 2243601242842202169
|
- rid: 2243601242842202241
|
||||||
|
subClusters: []
|
||||||
references:
|
references:
|
||||||
version: 2
|
version: 2
|
||||||
RefIds:
|
RefIds:
|
||||||
- rid: 2243601242842202169
|
- rid: 2243601242842202241
|
||||||
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
||||||
data:
|
data:
|
||||||
_name: Output
|
_name: Output
|
||||||
_synapses: []
|
_synapses: []
|
||||||
_receivers: []
|
_receivers: []
|
||||||
_array:
|
_array:
|
||||||
rid: 2243601242842202170
|
rid: 2243601242842202242
|
||||||
_curvePreset: 0
|
_curvePreset: 0
|
||||||
curve:
|
curve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -52,9 +53,9 @@ MonoBehaviour:
|
|||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
curveMax: 1
|
curveMax: 1
|
||||||
average: 0
|
average: 0
|
||||||
- rid: 2243601242842202170
|
- rid: 2243601242842202242
|
||||||
type: {class: NucleusArray, ns: , asm: Assembly-CSharp}
|
type: {class: NucleusArray, ns: , asm: Assembly-CSharp}
|
||||||
data:
|
data:
|
||||||
nuclei:
|
_nuclei:
|
||||||
- rid: 2243601242842202169
|
- rid: 2243601242842202241
|
||||||
name: Output
|
name: Output
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class Synapse {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
public Synapse(Cluster cluster, float weight = 1.0f) {
|
public Synapse(Cluster cluster, float weight = 1.0f) {
|
||||||
this.clusterNucleus = cluster;
|
this.clusterNucleus = cluster.asset;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -541,7 +541,7 @@ public class ClusterInspector : Editor {
|
|||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
ConnectNucleus(cluster, this.currentNucleus);
|
ConnectNucleus(this.cluster, this.currentNucleus);
|
||||||
if (GUILayout.Button("Add Input Neuron"))
|
if (GUILayout.Button("Add Input Neuron"))
|
||||||
AddInputNeuron(this.currentNucleus);
|
AddInputNeuron(this.currentNucleus);
|
||||||
if (GUILayout.Button("Add Input Cluster"))
|
if (GUILayout.Button("Add Input Cluster"))
|
||||||
@ -552,6 +552,10 @@ public class ClusterInspector : Editor {
|
|||||||
if (GUILayout.Button("Delete this neuron"))
|
if (GUILayout.Button("Delete this neuron"))
|
||||||
DeleteNeuron(this.currentNucleus);
|
DeleteNeuron(this.currentNucleus);
|
||||||
|
|
||||||
|
if (this.currentNucleus is Cluster subCluster) {
|
||||||
|
if (GUILayout.Button("Edit Cluster"))
|
||||||
|
EditCluster(subCluster);
|
||||||
|
}
|
||||||
|
|
||||||
// if (this.gameObject != null) {
|
// if (this.gameObject != null) {
|
||||||
// Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
// Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
||||||
@ -598,11 +602,21 @@ public class ClusterInspector : Editor {
|
|||||||
BrainPickerWindow.ShowPicker(brain => OnClusterPicked(nucleus, brain), "Select Cluster");
|
BrainPickerWindow.ShowPicker(brain => OnClusterPicked(nucleus, brain), "Select Cluster");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClusterPicked(INucleus nucleus, Cluster cluster) {
|
private void OnClusterPicked(INucleus nucleus, Cluster subCluster) {
|
||||||
Cluster clusterInstance = Instantiate(cluster);
|
Cluster clusterInstance = Instantiate(subCluster);
|
||||||
|
clusterInstance.asset = subCluster;
|
||||||
|
this.cluster.AddSubCluster(subCluster);
|
||||||
clusterInstance.AddReceiver(nucleus);
|
clusterInstance.AddReceiver(nucleus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EditCluster(Cluster subCluster) {
|
||||||
|
//var currentActiveObject = Selection.activeObject;
|
||||||
|
Selection.activeObject = subCluster;
|
||||||
|
EditorGUIUtility.PingObject(subCluster);
|
||||||
|
var editor = Editor.CreateEditor(subCluster);
|
||||||
|
//Selection.activeObject = currentActiveObject;
|
||||||
|
}
|
||||||
|
|
||||||
// Connect to another nucleus in the same cluster
|
// Connect to another nucleus in the same cluster
|
||||||
protected virtual void ConnectNucleus(Cluster cluster, INucleus nucleus) {
|
protected virtual void ConnectNucleus(Cluster cluster, INucleus nucleus) {
|
||||||
if (cluster == null)
|
if (cluster == null)
|
||||||
|
|||||||
@ -12,20 +12,21 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 60a957541c24c57e78018c202ebb1d9b, type: 3}
|
m_Script: {fileID: 11500000, guid: 60a957541c24c57e78018c202ebb1d9b, type: 3}
|
||||||
m_Name: New Cluster
|
m_Name: New Cluster
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Cluster
|
m_EditorClassIdentifier: Assembly-CSharp::Cluster
|
||||||
|
asset: {fileID: 0}
|
||||||
nuclei:
|
nuclei:
|
||||||
- rid: 2243601242842202229
|
- rid: 2243601242842202259
|
||||||
subClusters: []
|
subClusters: []
|
||||||
references:
|
references:
|
||||||
version: 2
|
version: 2
|
||||||
RefIds:
|
RefIds:
|
||||||
- rid: 2243601242842202229
|
- rid: 2243601242842202259
|
||||||
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
||||||
data:
|
data:
|
||||||
_name: Output
|
_name: Output
|
||||||
_synapses: []
|
_synapses: []
|
||||||
_receivers: []
|
_receivers: []
|
||||||
_array:
|
_array:
|
||||||
rid: 2243601242842202230
|
rid: 2243601242842202260
|
||||||
_curvePreset: 0
|
_curvePreset: 0
|
||||||
curve:
|
curve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -53,9 +54,9 @@ MonoBehaviour:
|
|||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
curveMax: 1
|
curveMax: 1
|
||||||
average: 0
|
average: 0
|
||||||
- rid: 2243601242842202230
|
- rid: 2243601242842202260
|
||||||
type: {class: NucleusArray, ns: , asm: Assembly-CSharp}
|
type: {class: NucleusArray, ns: , asm: Assembly-CSharp}
|
||||||
data:
|
data:
|
||||||
_nuclei:
|
_nuclei:
|
||||||
- rid: 2243601242842202229
|
- rid: 2243601242842202259
|
||||||
name: Output
|
name: Output
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 83e4ef8976534236989bcb1a9342dbf8
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 36081359186edfec998d891a1feeb17b, type: 3}
|
|
||||||
m_Name: RoamingBrain
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::NanoBrainObj
|
|
||||||
title:
|
|
||||||
count: 0
|
|
||||||
color: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
texture: {fileID: 0}
|
|
||||||
nuclei:
|
|
||||||
- id: -1707533328
|
|
||||||
_name: Root
|
|
||||||
synapses:
|
|
||||||
- nucleusId: -112538112
|
|
||||||
weight: 10
|
|
||||||
curvePreset: 0
|
|
||||||
curve:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
curveMax: 0
|
|
||||||
receivers: []
|
|
||||||
nucleusType:
|
|
||||||
_curvePreset: 0
|
|
||||||
curve:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve:
|
|
||||||
- serializedVersion: 3
|
|
||||||
time: 0
|
|
||||||
value: 0
|
|
||||||
inSlope: 0
|
|
||||||
outSlope: 1
|
|
||||||
tangentMode: 0
|
|
||||||
weightedMode: 0
|
|
||||||
inWeight: 0
|
|
||||||
outWeight: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
time: 1
|
|
||||||
value: 1
|
|
||||||
inSlope: 1
|
|
||||||
outSlope: 0
|
|
||||||
tangentMode: 0
|
|
||||||
weightedMode: 0
|
|
||||||
inWeight: 0
|
|
||||||
outWeight: 0
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
curveMax: 1
|
|
||||||
average: 0
|
|
||||||
inverse: 0
|
|
||||||
exponent: 1
|
|
||||||
- id: -112538112
|
|
||||||
_name: Avoidance
|
|
||||||
synapses:
|
|
||||||
- nucleusId: 407735232
|
|
||||||
weight: -1
|
|
||||||
curvePreset: 0
|
|
||||||
curve:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
curveMax: 0
|
|
||||||
receivers:
|
|
||||||
- nucleusId: -1707533328
|
|
||||||
nucleusType:
|
|
||||||
_curvePreset: 0
|
|
||||||
curve:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve:
|
|
||||||
- serializedVersion: 3
|
|
||||||
time: 0
|
|
||||||
value: 0
|
|
||||||
inSlope: 0
|
|
||||||
outSlope: 1
|
|
||||||
tangentMode: 0
|
|
||||||
weightedMode: 0
|
|
||||||
inWeight: 0
|
|
||||||
outWeight: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
time: 1
|
|
||||||
value: 1
|
|
||||||
inSlope: 1
|
|
||||||
outSlope: 0
|
|
||||||
tangentMode: 0
|
|
||||||
weightedMode: 0
|
|
||||||
inWeight: 0
|
|
||||||
outWeight: 0
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
curveMax: 1
|
|
||||||
average: 0
|
|
||||||
inverse: 0
|
|
||||||
exponent: 1
|
|
||||||
perceptei:
|
|
||||||
- id: 407735232
|
|
||||||
_name: Boundary
|
|
||||||
synapses: []
|
|
||||||
receivers:
|
|
||||||
- nucleusId: -112538112
|
|
||||||
nucleusType: Perceptoid
|
|
||||||
_curvePreset: 0
|
|
||||||
curve:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
curveMax: 0
|
|
||||||
average: 0
|
|
||||||
inverse: 0
|
|
||||||
exponent: 1
|
|
||||||
thingType: 1
|
|
||||||
thingId: 0
|
|
||||||
rootId: -1707533328
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: af8d90b8b4b9dcad7837130c4143d91c
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fc1a4800a8c531eb4855b436bc9084ae
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Loading…
x
Reference in New Issue
Block a user