Separation works again

This commit is contained in:
Pascal Serrarens 2026-02-18 17:47:48 +01:00
parent f72a37b248
commit c110a6e723
2 changed files with 113 additions and 103 deletions

View File

@ -263,39 +263,40 @@ public class ClusterInspector : Editor {
// Draw selected Nucleus
if (expandArray) {
if (this.currentNucleus is ReceptorArray receptor) {
float maxValue = 0;
foreach (Nucleus nucleus in receptor.instances) {
float value = length(nucleus.outputValue);
if (value > maxValue)
maxValue = value;
}
// if (this.currentNucleus is ReceptorArray receptor) {
// float maxValue = 0;
// foreach (Nucleus nucleus in receptor.instances) {
// float value = length(nucleus.outputValue);
// if (value > maxValue)
// maxValue = value;
// }
float spacing = 400f / receptor.instances.Count();
float margin = 10 + spacing / 2;
float xMin = 150 - size;
float xMax = 150 + size;
float yMin = 10 + margin - size / 2;
float yMax = 400 - margin + size;
Vector3[] verts = new Vector3[4] {
new(xMin, yMin, 0),
new(xMax, yMin, 0),
new(xMax, yMax, 0),
new(xMin, yMax, 0)
};
Handles.color = Color.black;
Handles.DrawAAConvexPolygon(verts);
int row = 0;
foreach (Nucleus nucleus in receptor.instances) {
Vector3 pos = new(150, margin + row * spacing, 0.0f);
Handles.color = Color.white;
// The selected nucleus highlight ring
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
DrawNucleus(nucleus, pos, maxValue, size);
row++;
}
}
else if (this.currentNucleus is Receptor receptor1) {
// float spacing = 400f / receptor.instances.Count();
// float margin = 10 + spacing / 2;
// float xMin = 150 - size;
// float xMax = 150 + size;
// float yMin = 10 + margin - size / 2;
// float yMax = 400 - margin + size;
// Vector3[] verts = new Vector3[4] {
// new(xMin, yMin, 0),
// new(xMax, yMin, 0),
// new(xMax, yMax, 0),
// new(xMin, yMax, 0)
// };
// Handles.color = Color.black;
// Handles.DrawAAConvexPolygon(verts);
// int row = 0;
// foreach (Nucleus nucleus in receptor.instances) {
// Vector3 pos = new(150, margin + row * spacing, 0.0f);
// Handles.color = Color.white;
// // The selected nucleus highlight ring
// Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
// DrawNucleus(nucleus, pos, maxValue, size);
// row++;
// }
// }
// else
if (this.currentNucleus is IReceptor receptor1) {
float maxValue = 0;
foreach (Nucleus nucleus in receptor1.array.nuclei) {
float value = length(nucleus.outputValue);
@ -332,13 +333,14 @@ public class ClusterInspector : Editor {
fontStyle = FontStyle.Bold,
};
Vector3 labelPos = new(150, yMax + size + 5, 0);
int colonPos = receptor1.name.IndexOf(":");
string receptorName = receptor1.GetName();
int colonPos = receptorName.IndexOf(":");
if (colonPos > 0) {
string baseName = receptor1.name[..colonPos];
string baseName = receptorName[..colonPos];
Handles.Label(labelPos, baseName, style);
}
else
Handles.Label(labelPos, receptor1.name, style);
Handles.Label(labelPos, receptorName, style);
}
else {
Handles.color = Color.white;
@ -502,10 +504,17 @@ public class ClusterInspector : Editor {
};
if (nucleus is Receptor receptor1) {
if (receptor1.array == null || receptor1.array.nuclei == null || receptor1.array.nuclei.Count() == 0)
receptor1.array = new NucleusArray(nucleus);
if ((!expandArray || receptor1.array.nuclei.First() != this.currentNucleus) && receptor1.array.nuclei.Count() > 1) {
// draw the array size label
if (expandArray) { //} && receptor1.array.nuclei.First() == this.currentNucleus) {
style.alignment = TextAnchor.LowerCenter;
Vector3 labelPos1 = position + Vector3.down * (size + 5); // below disc along up axis
int colonPos1 = nucleus.name.IndexOf(":");
if (colonPos1 > 0) {
string extName = nucleus.name[(colonPos1 + 2)..];
Handles.Label(labelPos1, extName, style);
}
}
else {
if (color.grayscale > 0.5f)
style.normal.textColor = Color.black;
else
@ -523,13 +532,14 @@ public class ClusterInspector : Editor {
// }
if (nucleus is ClusterReceptor clusterReceptor) {
// draw the array size label
if (expandArray && clusterReceptor.array.nuclei.First() == this.currentNucleus) {
style.alignment = TextAnchor.LowerCenter;
Vector3 labelPos = position + Vector3.down * (size + 5); // below disc along up axis
int colonPos = nucleus.name.IndexOf(":");
if (colonPos > 0) {
string extName = nucleus.name[(colonPos + 2)..];
Handles.Label(labelPos, extName, style);
Vector3 labelPos2 = position + Vector3.down * (size + 5); // below disc along up axis
int colonPos2 = nucleus.name.IndexOf(":");
if (colonPos2 > 0) {
string extName = nucleus.name[(colonPos2 + 2)..];
Handles.Label(labelPos2, extName, style);
}
}
else {
@ -542,26 +552,26 @@ public class ClusterInspector : Editor {
}
}
if (expandArray && nucleus is Receptor receptor2 && receptor2.array.nuclei.First() == this.currentNucleus) {
style.alignment = TextAnchor.LowerCenter;
Vector3 labelPos = position + Vector3.down * (size + 5); // below disc along up axis
int colonPos = nucleus.name.IndexOf(":");
if (colonPos > 0) {
string extName = nucleus.name[(colonPos + 2)..];
Handles.Label(labelPos, extName, style);
}
}
else {
// if (expandArray && nucleus is Receptor receptor2 && receptor2.array.nuclei.First() == this.currentNucleus) {
// style.alignment = TextAnchor.LowerCenter;
// Vector3 labelPos = position + Vector3.down * (size + 5); // below disc along up axis
// int colonPos = nucleus.name.IndexOf(":");
// if (colonPos > 0) {
// string extName = nucleus.name[(colonPos + 2)..];
// Handles.Label(labelPos, extName, style);
// }
// }
// else {
style.alignment = TextAnchor.UpperCenter;
Vector3 labelPos = position - Vector3.down * (size + 5); // below disc along up axis
int colonPos = nucleus.name.IndexOf(":");
if (colonPos > 0 && colonPos < nucleus.name.Length - 2) {
string baseName = nucleus.name[..colonPos];
Handles.Label(labelPos, baseName, style);
if (expandArray || (colonPos > 0 && colonPos < nucleus.name.Length - 2)) {
// string baseName = nucleus.name[..colonPos];
// Handles.Label(labelPos, baseName, style);
}
else
Handles.Label(labelPos, nucleus.name, style);
}
// }
if (nucleus is Cluster) {
Handles.color = Color.white;

View File

@ -38,7 +38,7 @@ public class NucleusArray {
newArray[i] = this._nuclei[i];
if (this._nuclei[0] is Nucleus nucleus) {
newArray[newLength - 1] = nucleus.Clone(prefab);
newArray[newLength - 1].name += $"{newLength - 1}";
newArray[newLength - 1].name += $": {newLength - 1}";
}
this._nuclei = newArray;