Skip to content

Commit 7692164

Browse files
committed
fix: changing BLDistance to BLRatio, works much better, also fixing a tedious bug where the Probes GO had a non-zero transform
1 parent 1451af0 commit 7692164

File tree

7 files changed

+31
-50
lines changed

7 files changed

+31
-50
lines changed

Assets/Prefabs/Managers/Probes.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Transform:
2727
m_GameObject: {fileID: 5815862267276796598}
2828
serializedVersion: 2
2929
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
30-
m_LocalPosition: {x: 0, y: 3.668, z: 1.4000001}
30+
m_LocalPosition: {x: 0, y: 0, z: 0}
3131
m_LocalScale: {x: 1, y: 1, z: 1}
3232
m_ConstrainProportionsScale: 0
3333
m_Children: []

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,6 +3138,10 @@ PrefabInstance:
31383138
propertyPath: m_AnchoredPosition.x
31393139
value: 0
31403140
objectReference: {fileID: 0}
3141+
- target: {fileID: 341190943836276264, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3142+
propertyPath: m_IsOn
3143+
value: 0
3144+
objectReference: {fileID: 0}
31413145
- target: {fileID: 341190943836276264, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31423146
propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_Target
31433147
value:
@@ -9516,7 +9520,7 @@ PrefabInstance:
95169520
objectReference: {fileID: 0}
95179521
- target: {fileID: 8016510558008620337, guid: 482bfae3ba88b424e96d7fcd669f7b73, type: 3}
95189522
propertyPath: BregmaLambdaChangedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
9519-
value: ChangeBLDistance
9523+
value: ChangeBLRatio
95209524
objectReference: {fileID: 0}
95219525
- target: {fileID: 8016510558008620337, guid: 482bfae3ba88b424e96d7fcd669f7b73, type: 3}
95229526
propertyPath: BregmaLambdaChangedEvent.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName
@@ -11462,34 +11466,6 @@ PrefabInstance:
1146211466
propertyPath: _channelMapAssetRefs.Array.data[10].m_AssetGUID
1146311467
value: 6c610f1cb26c1f44a98acd88b4bdd650
1146411468
objectReference: {fileID: 0}
11465-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11466-
propertyPath: m_LocalPosition.x
11467-
value: 0
11468-
objectReference: {fileID: 0}
11469-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11470-
propertyPath: m_LocalPosition.y
11471-
value: 3.668
11472-
objectReference: {fileID: 0}
11473-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11474-
propertyPath: m_LocalPosition.z
11475-
value: 1.4000001
11476-
objectReference: {fileID: 0}
11477-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11478-
propertyPath: m_LocalRotation.w
11479-
value: 1
11480-
objectReference: {fileID: 0}
11481-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11482-
propertyPath: m_LocalRotation.x
11483-
value: 0
11484-
objectReference: {fileID: 0}
11485-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11486-
propertyPath: m_LocalRotation.y
11487-
value: 0
11488-
objectReference: {fileID: 0}
11489-
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
11490-
propertyPath: m_LocalRotation.z
11491-
value: 0
11492-
objectReference: {fileID: 0}
1149311469
- target: {fileID: 5480079517456965108, guid: de6f5b0508e9ae947a6bd003a9efd91a, type: 3}
1149411470
propertyPath: m_LocalEulerAnglesHint.x
1149511471
value: 0

Assets/Scripts/Pinpoint/Probes/Controllers/CartesianProbeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ public override void SetProbePosition()
707707
transform.rotation = _initialRotation;
708708

709709
// Manually adjust the coordinates and rotation
710-
transform.position += Insertion.PositionWorldT();
710+
transform.position = Insertion.PositionWorldT();
711711
transform.RotateAround(_probeTipT.position, transform.up, Insertion.Yaw);
712712
transform.RotateAround(_probeTipT.position, transform.right, Insertion.Pitch);
713713
transform.RotateAround(_probeTipT.position, _probeTipT.up, Insertion.Roll);

Assets/Scripts/Pinpoint/TrajectoryPlannerManager.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public async void Startup()
214214
() => _probeQuickSettings.GetComponentInChildren<QuickSettingsLockBehavior>().UpdateSprite(ProbeManager.ActiveProbeManager.ProbeController.Locked));
215215
ProbeManager.ActiveProbeUIUpdateEvent.AddListener(() => SetSurfaceDebugColor(ProbeManager.ActiveProbeManager.Color));
216216

217+
if (_firstTime || _atlasReset)
218+
{
219+
Settings.BregmaLambdaRatio = 1f;
220+
}
221+
217222
// Complete
218223
PlayerPrefs.SetInt("scene-atlas-reset", 0);
219224
StartupEvent_Complete.Invoke();
@@ -1025,14 +1030,12 @@ public void SetBLUI()
10251030
/// <summary>
10261031
/// Change the bregma-lamba distance. By default this is 4.15f, so if it isn't that value, then we need to add an isometric scaling to the current transform
10271032
/// </summary>
1028-
/// <param name="newBLDistance"></param>
1029-
public void ChangeBLDistance(float newBLDistance)
1033+
/// <param name="blRatio"></param>
1034+
public void ChangeBLRatio(float blRatio)
10301035
{
1031-
if (BrainAtlasManager.ActiveReferenceAtlas == null || newBLDistance == _blDistance.DefaultBLDistance)
1036+
if (BrainAtlasManager.ActiveReferenceAtlas == null)
10321037
return;
10331038

1034-
float blRatio = newBLDistance / _blDistance.DefaultBLDistance;
1035-
10361039
#if UNITY_EDITOR
10371040
Debug.Log($"(BL Distance) Re-scaling to {blRatio}");
10381041
#endif

Assets/Scripts/Pinpoint/UI/BregmaLambdaBehavior.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ public void SetBLRange(float min, float max, float blDistance)
3535
_blSlider.SetValueWithoutNotify(blDistance);
3636
}
3737

38-
public void SetText(float value)
38+
public void SetSliderAndText(float ratio)
3939
{
40-
_sliderText.text = $"{Mathf.RoundToInt(value * 100f) / 100f}";
40+
_blSlider.SetValueWithoutNotify(ratio * _blDistance);
41+
_sliderText.text = $"{Mathf.RoundToInt(ratio * _blDistance * 100f) / 100f}";
4142
}
4243

4344
private void SetSetting(float value)
4445
{
45-
Settings.BregmaLambdaDistance = value;
46+
// Convert to ratio then set
47+
Settings.BregmaLambdaRatio = value / _blDistance;
4648
}
4749
}

Assets/Scripts/Pinpoint/Utilities/Settings.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,20 +340,20 @@ public static string AtlasTransformName
340340
}
341341
}
342342

343-
private const float BREGMALAMBDA_DEFAULT = -1f;
343+
private const float BREGMALAMBDA_DEFAULT = 1f;
344344
public UnityEvent<float> BregmaLambdaChangedEvent;
345345

346-
public static float BregmaLambdaDistance
346+
public static float BregmaLambdaRatio
347347
{
348348
get
349349
{
350-
return data.BregmaLambdaDistance;
350+
return data.BregmaLambdaRatio;
351351
}
352352
set
353353
{
354-
data.BregmaLambdaDistance = value;
354+
data.BregmaLambdaRatio = value;
355355
Save();
356-
Instance.BregmaLambdaChangedEvent.Invoke(data.BregmaLambdaDistance);
356+
Instance.BregmaLambdaChangedEvent.Invoke(data.BregmaLambdaRatio);
357357
}
358358
}
359359

@@ -629,7 +629,7 @@ private void Load(bool fromDefaults = false)
629629
data.ShowAtlas3DSlices = SHOW3DSLICE_DEFAULT;
630630
data.RelativeCoord = RELCOORD_DEFAULT;
631631
data.AtlasTransformName = INVIVO_DEFAULT;
632-
data.BregmaLambdaDistance = BREGMALAMBDA_DEFAULT;
632+
data.BregmaLambdaRatio = BREGMALAMBDA_DEFAULT;
633633

634634
// ephys link
635635
data.EphysLinkServerIP = "";
@@ -713,9 +713,9 @@ private void Apply()
713713

714714
// the relative coordinate needs to be set, since it gets propagated downstream
715715
ReferenceCoord = data.RelativeCoord;
716-
BregmaLambdaDistance = data.BregmaLambdaDistance;
716+
BregmaLambdaRatio = data.BregmaLambdaRatio;
717717

718-
// Accounts
718+
// Accounts
719719
_stayLoggedInToggle.SetIsOnWithoutNotify(StayLoggedIn);
720720

721721
// API
@@ -820,7 +820,7 @@ private struct InternalData
820820
public int ShowAtlas3DSlices;
821821
public Vector3 RelativeCoord;
822822
public string AtlasTransformName;
823-
public float BregmaLambdaDistance;
823+
public float BregmaLambdaRatio;
824824

825825
// Ephys link
826826
public string EphysLinkServerIP;

Packages/packages-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@
223223
"depth": 0,
224224
"source": "git",
225225
"dependencies": {},
226-
"hash": "8f1d5e978814b53f242ddd32e18c9f6dfc29cc23"
226+
"hash": "0bc6ec2b1fb9c71341d63a366a542662986d4141"
227227
},
228228
"vbl.urchin": {
229229
"version": "https://github.com/VirtualBrainLab/Urchin.git?path=/UnityClient/Packages/vbl.urchin",
230230
"depth": 0,
231231
"source": "git",
232232
"dependencies": {},
233-
"hash": "3933774b041f0ce14d99bff3cbf747018edc29ff"
233+
"hash": "212b78ec0f757bd88b76d470b872a36730408f9f"
234234
},
235235
"com.unity.modules.ai": {
236236
"version": "1.0.0",

0 commit comments

Comments
 (0)