Skip to content

Commit d043cb6

Browse files
committed
fix: fixing two confusing bugs with coordinates
Issue was that the reference coordinate was incorrectly not being applied, causing coordinates to shift over time, and then I had fixed code downstream of this which was masking the problem
1 parent cba59cf commit d043cb6

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.44912726, g: 0.49919963, b: 0.5757154, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44824904, g: 0.49827605, b: 0.5755831, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
@@ -8481,7 +8481,7 @@ PrefabInstance:
84818481
objectReference: {fileID: 2108153954}
84828482
- target: {fileID: 1302158968166640874, guid: 734f6254569c01842b9d2e2ff1b1d7ae, type: 3}
84838483
propertyPath: m_IsActive
8484-
value: 1
8484+
value: 0
84858485
objectReference: {fileID: 0}
84868486
- target: {fileID: 1302158968379378328, guid: 734f6254569c01842b9d2e2ff1b1d7ae, type: 3}
84878487
propertyPath: m_LocalScale.x

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,12 @@ public override void SetProbeAngles(Vector3 angles)
805805
/// <returns></returns>
806806
public override (Vector3 tipCoordWorldU, Vector3 tipRightWorldU, Vector3 tipUpWorldU, Vector3 tipForwardWorldU) GetTipWorldU()
807807
{
808-
Vector3 tipCoordWorldU = BrainAtlasManager.WorldT2WorldU(_probeTipT.position);
809-
Vector3 tipRightWorldU = (BrainAtlasManager.WorldT2WorldU(_probeTipT.position + _probeTipT.right, false) - tipCoordWorldU).normalized;
810-
Vector3 tipUpWorldU = (BrainAtlasManager.WorldT2WorldU(_probeTipT.position + _probeTipT.up, false) - tipCoordWorldU).normalized;
811-
Vector3 tipForwardWorldU = (BrainAtlasManager.WorldT2WorldU(_probeTipT.position + _probeTipT.forward, false) - tipCoordWorldU).normalized;
808+
// Note: we need to use the reference coordinates here so that the world positions resolve to (0,0,0) at Bregma,
809+
// otherwise any rotations that get applied will be incorrect
810+
Vector3 tipCoordWorldU = BrainAtlasManager.WorldT2WorldU(_probeTipT.position, true);
811+
Vector3 tipRightWorldU = (BrainAtlasManager.WorldT2WorldU(_probeTipT.position + _probeTipT.right, true) - tipCoordWorldU).normalized;
812+
Vector3 tipUpWorldU = (BrainAtlasManager.WorldT2WorldU(_probeTipT.position + _probeTipT.up, true) - tipCoordWorldU).normalized;
813+
Vector3 tipForwardWorldU = (BrainAtlasManager.WorldT2WorldU(_probeTipT.position + _probeTipT.forward, true) - tipCoordWorldU).normalized;
812814

813815
return (tipCoordWorldU, tipRightWorldU, tipUpWorldU, tipForwardWorldU);
814816
}

Assets/Scripts/Pinpoint/Probes/ProbeManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,7 @@ public void UpdateSurfacePosition()
801801
// get the surface coordinate in un-transformed world space
802802
_brainSurfaceWorldU = BrainAtlasManager.ActiveReferenceAtlas.AtlasIdx2World(entryCoordAtlasIdx);
803803
// go back into transformed space, only using the reference coordinate for the entry coordinate (not the transform coordinate)
804-
_brainSurfaceWorldT = BrainAtlasManager.WorldU2WorldT(_brainSurfaceWorldU, false);
805-
804+
_brainSurfaceWorldT = BrainAtlasManager.WorldU2WorldT(_brainSurfaceWorldU, true);
806805
_brainSurfaceCoordT = BrainAtlasManager.ActiveAtlasTransform.U2T(
807806
BrainAtlasManager.ActiveReferenceAtlas.World2Atlas(_brainSurfaceWorldU, true));
808807
}
@@ -829,7 +828,7 @@ public void UpdateSurfacePosition()
829828
Vector3 tipInBrain = tipAtlasIdxU;
830829

831830
// Adjust the tip coordinate to put it into the brain
832-
// This is kind of a dumb algorithm, we
831+
// This is kind of a dumb algorithm
833832
if (!probeInBrain)
834833
{
835834
// Get which direction we need to go

0 commit comments

Comments
 (0)