Skip to content

Commit 0332206

Browse files
authored
Updated TrackedPoseDriver to make use of Transform.SetLocalPositionAndRotation (#1716)
* Updated TrackedPoseDriver to make use of Transform.SetLocalPositionAndRotation when available * Replaced file scoped #define with asmdef version define for easier understanding * Added version defines for 2022.1 and 2022.2 patch versions that added the APIs also
1 parent ff181b1 commit 0332206

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ however, it has to be formatted properly to pass verification tests.
1919
### Fixed
2020
- Fixed missing prefab errors in InputDeviceTester project ([case ISXB-420](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-420)).
2121
- Fixed serialization migration in the Tracked Pose Driver component causing bindings to clear when prefabs are used in some cases ([case ISXB-512](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-512), [case ISXB-521](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-521)).
22+
- Fixed Tracked Pose Driver to use `Transform.SetLocalPositionAndRotation` when available to improve performance. Based on the user contribution from [DevDunk](https://forum.unity.com/members/devdunk.4432119/) in a [forum post](https://forum.unity.com/threads/more-performant-tracked-pose-driver-solution-included.1462691).
2223
- Fixed the `Clone` methods of `InputAction` and `InputActionMap` so it copies the Initial State Check flag (`InputAction.wantsInitialStateCheck`) of input actions.
2324

2425
## [1.6.3] - 2023-07-11

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRota
579579
var positionValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Position) != 0;
580580
var rotationValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Rotation) != 0;
581581

582+
#if HAS_SET_LOCAL_POSITION_AND_ROTATION
583+
if (m_TrackingType == TrackingType.RotationAndPosition && rotationValid && positionValid)
584+
{
585+
transform.SetLocalPositionAndRotation(newPosition, newRotation);
586+
return;
587+
}
588+
#endif
589+
582590
if (rotationValid &&
583591
(m_TrackingType == TrackingType.RotationAndPosition ||
584592
m_TrackingType == TrackingType.RotationOnly))

Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"precompiledReferences": [],
1111
"autoReferenced": true,
1212
"defineConstraints": [],
13-
"versionDefines": [
14-
{
13+
"versionDefines": [
14+
{
1515
"name": "com.unity.xr.oculus",
1616
"expression": "1.0.3",
1717
"define": "DISABLE_BUILTIN_INPUT_SYSTEM_OCULUS"
@@ -55,6 +55,21 @@
5555
"name": "com.unity.ugui",
5656
"expression": "1.0.0",
5757
"define": "UNITY_INPUT_SYSTEM_ENABLE_UI"
58+
},
59+
{
60+
"name": "Unity",
61+
"expression": "[2021.3.11,2022.1)",
62+
"define": "HAS_SET_LOCAL_POSITION_AND_ROTATION"
63+
},
64+
{
65+
"name": "Unity",
66+
"expression": "[2022.1.19,2022.2)",
67+
"define": "HAS_SET_LOCAL_POSITION_AND_ROTATION"
68+
},
69+
{
70+
"name": "Unity",
71+
"expression": "2022.2",
72+
"define": "HAS_SET_LOCAL_POSITION_AND_ROTATION"
5873
}
5974
],
6075
"noEngineReferences": false

0 commit comments

Comments
 (0)