Skip to content

Commit 9934ed6

Browse files
authored
fix: atlas transform ignored by pathfinder (#593)
1 parent 42efe93 commit 9934ed6

File tree

5 files changed

+76
-16
lines changed

5 files changed

+76
-16
lines changed

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,15 +3119,15 @@ PrefabInstance:
31193119
objectReference: {fileID: 1703646459}
31203120
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31213121
propertyPath: m_AnchorMax.y
3122-
value: 1
3122+
value: 0
31233123
objectReference: {fileID: 0}
31243124
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31253125
propertyPath: m_AnchorMin.y
3126-
value: 1
3126+
value: 0
31273127
objectReference: {fileID: 0}
31283128
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31293129
propertyPath: m_AnchoredPosition.x
3130-
value: 169.88
3130+
value: 0
31313131
objectReference: {fileID: 0}
31323132
- target: {fileID: 341190943836276264, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31333133
propertyPath: m_IsOn
@@ -3263,19 +3263,19 @@ PrefabInstance:
32633263
objectReference: {fileID: 0}
32643264
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32653265
propertyPath: m_AnchorMax.y
3266-
value: 1
3266+
value: 0
32673267
objectReference: {fileID: 0}
32683268
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32693269
propertyPath: m_AnchorMin.y
3270-
value: 1
3270+
value: 0
32713271
objectReference: {fileID: 0}
32723272
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32733273
propertyPath: m_AnchoredPosition.x
3274-
value: 354.84
3274+
value: 0
32753275
objectReference: {fileID: 0}
32763276
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32773277
propertyPath: m_AnchoredPosition.y
3278-
value: -15
3278+
value: 0
32793279
objectReference: {fileID: 0}
32803280
- target: {fileID: 341190944071593138, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32813281
propertyPath: m_AnchorMax.x
@@ -3555,19 +3555,19 @@ PrefabInstance:
35553555
objectReference: {fileID: 0}
35563556
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35573557
propertyPath: m_AnchorMax.y
3558-
value: 1
3558+
value: 0
35593559
objectReference: {fileID: 0}
35603560
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35613561
propertyPath: m_AnchorMin.y
3562-
value: 1
3562+
value: 0
35633563
objectReference: {fileID: 0}
35643564
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35653565
propertyPath: m_AnchoredPosition.x
3566-
value: 384.91998
3566+
value: 0
35673567
objectReference: {fileID: 0}
35683568
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35693569
propertyPath: m_AnchoredPosition.y
3570-
value: -15
3570+
value: 0
35713571
objectReference: {fileID: 0}
35723572
- target: {fileID: 341190944411999430, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35733573
propertyPath: m_AnchorMax.y

Assets/Scripts/Pinpoint/CoordinateSystems/ManipulatorSpace.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ namespace Pinpoint.CoordinateSystems
55
{
66
public sealed class ManipulatorSpace : CoordinateSpace
77
{
8-
// Default to Sensapex dimensions
9-
public override Vector3 Dimensions { get; }
8+
#region Properties
9+
1010
public override string Name => "Manipulator";
11+
public override Vector3 Dimensions { get; }
12+
13+
#endregion
14+
1115

1216
public ManipulatorSpace(Vector3 dimensions)
1317
{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using BrainAtlas.CoordinateSystems;
3+
using UnityEngine;
4+
5+
namespace Pinpoint.CoordinateSystems
6+
{
7+
public class PathfinderSpace : CoordinateSpace
8+
{
9+
#region Properties
10+
11+
public override string Name => "Pathfinder";
12+
public override Vector3 Dimensions => Vector3.one * 15f;
13+
14+
#endregion
15+
16+
17+
public override Vector3 Space2World(Vector3 coordSpace, bool useReference = true)
18+
{
19+
return new Vector3(coordSpace.x, -coordSpace.z, -coordSpace.y);
20+
}
21+
22+
public override Vector3 World2Space(Vector3 coordWorld, bool useReference = true)
23+
{
24+
return new Vector3(coordWorld.x, -coordWorld.z, -coordWorld.y);
25+
}
26+
27+
public override Vector3 Space2World_Vector(Vector3 vecSpace)
28+
{
29+
return Space2World(vecSpace);
30+
}
31+
32+
public override Vector3 World2Space_Vector(Vector3 vecWorld)
33+
{
34+
return World2Space(vecWorld);
35+
}
36+
}
37+
}

Assets/Scripts/Pinpoint/CoordinateSystems/PathfinderSpace.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,17 @@ private void EchoPosition(Vector4 pos)
146146
{
147147
if (!enabled && _probeController == null) return;
148148

149-
// Check for special pathfinder mode (directly set probe position, no calculations needed)
149+
// Check for special Pathfinder mode (directly set probe position, no calculations needed)
150150
if (NumAxes == -1)
151151
{
152152
CommunicationManager.Instance.GetAngles(ManipulatorID, angles =>
153153
{
154154
_probeController.SetProbeAngles(new Vector3(angles.x, 90 - angles.y, angles.z));
155-
_probeController.SetProbePosition(new Vector3(pos.y, pos.x, pos.z));
155+
156+
// Convert Pathfinder space coordinates into active atlas space
157+
_probeController.SetProbePosition(
158+
BrainAtlasManager.ActiveReferenceAtlas.World2Atlas_Vector(
159+
CoordinateSpace.Space2World_Vector(pos)));
156160
});
157161
}
158162
else
@@ -268,7 +272,11 @@ void StartEchoing()
268272

269273
public void UpdateSpaceAndTransform()
270274
{
271-
CoordinateSpace = new ManipulatorSpace(Dimensions);
275+
CoordinateSpace = NumAxes switch
276+
{
277+
-1 => new PathfinderSpace(),
278+
_ => new ManipulatorSpace(Dimensions)
279+
};
272280
CoordinateTransform = NumAxes switch
273281
{
274282
4 => IsRightHanded

0 commit comments

Comments
 (0)