Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Corrected behaviour of TrackedPoseDriver when no device is connected. #1823

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Assets/Tests/InputSystem/Plugins/XRTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,35 @@ public void Components_TrackedPoseDriver_RetainsPoseWhenTrackedDeviceRemoved()
}
}

[Test]
[Category("Components")]
public void Components_TrackedPoseDriver_RetainsPoseWhenNoTrackedDeviceIsConnected()
{
// Tests/reproduces the scenario described in https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-699
// i.e. that rotation and/or position is not updated if device is not connected and track state isn't ignored.

var position = new Vector3(1f, 2f, 3f);
var rotation = new Quaternion(0.09853293f, 0.09853293f, 0.09853293f, 0.9853293f);

var go = new GameObject();
go.transform.position = position;
go.transform.rotation = rotation;

var tpd = go.AddComponent<TrackedPoseDriver>();
tpd.updateType = TrackedPoseDriver.UpdateType.Update;
tpd.trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition;
tpd.ignoreTrackingState = false;
var transform = tpd.transform;

Assert.That(transform.position, Is.EqualTo(position));
Assert.That(transform.rotation, Is.EqualTo(rotation));

InputSystem.Update(InputUpdateType.Dynamic);

Assert.That(transform.position, Is.EqualTo(position));
Assert.That(transform.rotation, Is.EqualTo(rotation));
}

[Test]
[Category("Layouts")]
public void Layouts_PoseControlsCanBeCreatedBySubcontrols()
Expand Down
2 changes: 2 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed pointerId staying the same when simultaneously releasing and then pressing in the same frame on mobile using touch. [ISXB-1006](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-845)
- Fixed ISubmitHandler.OnSubmit event processing when operating in Manual Update mode (ISXB-1141)
- Fixed Rename mode is not entered and name is autocompleted to default when creating a new Action Map on 2022.3. [ISXB-1151](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1151)
- Fixed a bug that would case `TrackedBasedDriver` to update position and rotation when no HMD device is connected [ISXB-699](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-699) instead of keeping it unchanged.
- Fixed unexpected control scheme switch when using `OnScreenControl` and pointer based schemes which registed "Cancel" event on every frame.[ISXB-656](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-656)
- Fixed an issue with The "Add Control Scheme..." popup window so that it now persists until any changes are explicitly Saved or Cancelled [case ISXB-1131](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1131)

Expand Down Expand Up @@ -245,6 +246,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed incorrect documentation in InputSystem.actions and InputSystem.onActionsChanged property API contract.
- Fixed an issue where `InputSystem.actions` could be incorrectly evaluated if the associated asset was deleted.


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra new line

## [1.8.0-pre.2] - 2023-11-09

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,27 @@ void ReadTrackingState()
{
// Treat an Input Action Reference with no reference the same as
// an enabled Input Action with no authored bindings, and allow driving the Transform pose.
m_CurrentTrackingState = TrackingStates.Position | TrackingStates.Rotation;
// TODO Remove if suggested fix seems valid. m_CurrentTrackingState = TrackingStates.Position | TrackingStates.Rotation;

// Check if we have transform and rotation controls to drive the pose.
var positionInputAction = m_PositionInput.action;
var rotationInputAction = m_RotationInput.action;
if (positionInputAction != null && positionInputAction.m_BindingsCount > 0 && rotationInputAction != null && rotationInputAction.m_BindingsCount > 0)
{
m_CurrentTrackingState = TrackingStates.Position | TrackingStates.Rotation;
}
else if (positionInputAction != null && positionInputAction.m_BindingsCount > 0)
{
m_CurrentTrackingState = TrackingStates.Position;
}
else if (rotationInputAction != null && rotationInputAction.m_BindingsCount > 0)
{
m_CurrentTrackingState = TrackingStates.Rotation;
}
else
{
m_CurrentTrackingState = TrackingStates.None;
}
return;
}

Expand Down