Skip to content

Commit f2ae00e

Browse files
committed
Add 180 degree rotation to solver attachment points
to account for the updated glTF coordinate space.
1 parent af25483 commit f2ae00e

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

Assets/HoloToolkit/Utilities/Scripts/Solvers/SolverHandler.cs

+7-21
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public TrackedObjectToReferenceEnum TrackedObjectToReference
4646
if (trackedObjectToReference != value)
4747
{
4848
trackedObjectToReference = value;
49-
TransformTarget = null;
49+
OnControllerLost();
5050
AttachToNewTrackedObject();
5151
}
5252
}
@@ -66,7 +66,7 @@ public Vector3 AdditionalOffset
6666
set
6767
{
6868
additionalOffset = value;
69-
UpdateOffsetTransform();
69+
TrackTransform(TransformTarget);
7070
}
7171
}
7272

@@ -76,7 +76,7 @@ public Vector3 AdditionalRotation
7676
set
7777
{
7878
additionalRotation = value;
79-
UpdateOffsetTransform();
79+
TrackTransform(TransformTarget);
8080
}
8181
}
8282

@@ -202,24 +202,7 @@ public virtual void AttachToNewTrackedObject()
202202

203203
private void TrackTransform(Transform newTrackedTransform)
204204
{
205-
if (RequiresOffset())
206-
{
207-
TransformTarget = MakeOffsetTransform(newTrackedTransform);
208-
}
209-
else
210-
{
211-
TransformTarget = newTrackedTransform;
212-
}
213-
}
214-
215-
private bool RequiresOffset()
216-
{
217-
return AdditionalOffset.sqrMagnitude != 0 || AdditionalRotation.sqrMagnitude != 0;
218-
}
219-
220-
private void UpdateOffsetTransform()
221-
{
222-
TransformTarget = MakeOffsetTransform(TransformTarget);
205+
TransformTarget = MakeOffsetTransform(newTrackedTransform);
223206
}
224207

225208
private Transform MakeOffsetTransform(Transform parentTransform)
@@ -233,6 +216,9 @@ private Transform MakeOffsetTransform(Transform parentTransform)
233216
transformWithOffset.transform.localPosition = AdditionalOffset;
234217
transformWithOffset.transform.localRotation = Quaternion.Euler(AdditionalRotation);
235218
transformWithOffset.name = string.Format("{0} on {1} with offset {2}, {3}", gameObject.name, TrackedObjectToReference.ToString(), AdditionalOffset, AdditionalRotation);
219+
// In order to account for the reversed normals due to the glTF coordinate system change, we need to provide rotated attachment points.
220+
transformWithOffset.transform.Rotate(0, 180, 0);
221+
236222
return transformWithOffset.transform;
237223
}
238224

0 commit comments

Comments
 (0)