Skip to content

Commit 1a958ab

Browse files
FIX: Fixed an issue where ReadUnprocessedValueFromState in PoseControl always returning default values.
1 parent 960cee5 commit 1a958ab

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ however, it has to be formatted properly to pass verification tests.
1818
- Fixed issue when using MultiplayerEventSystems where the visual state of UI controls would change due to constant toggling of CanvasGroup.interactable on and off ([case ISXB-112](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-112)).
1919
- Fixed an issue where the Input Action asset icon would not be visible during asset creation ([case ISXB-6](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-6)).
2020
- Fixed DualSense low frequency motor speed being always set to min value.
21+
- Fixed an issue where `ReadUnprocessedValueFromState` in PoseControl always returning default values.
2122

2223
## [1.4.1] - 2022-05-30
2324

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Controls/PoseControl.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,26 @@ protected override void FinishSetup()
209209
/// <inheritdoc />
210210
public override unsafe PoseState ReadUnprocessedValueFromState(void* statePtr)
211211
{
212-
var valuePtr = (PoseState*)((byte*)statePtr + (int)m_StateBlock.byteOffset);
213-
return *valuePtr;
212+
return new PoseState()
213+
{
214+
isTracked = isTracked.ReadUnprocessedValueFromState(statePtr) > 0.5f,
215+
trackingState = (TrackingState)trackingState.ReadUnprocessedValueFromState(statePtr),
216+
position = position.ReadUnprocessedValueFromState(statePtr),
217+
rotation = rotation.ReadUnprocessedValueFromState(statePtr),
218+
velocity = velocity.ReadUnprocessedValueFromState(statePtr),
219+
angularVelocity = angularVelocity.ReadUnprocessedValueFromState(statePtr),
220+
};
214221
}
215222

216223
/// <inheritdoc />
217224
public override unsafe void WriteValueIntoState(PoseState value, void* statePtr)
218225
{
219-
var valuePtr = (PoseState*)((byte*)statePtr + (int)m_StateBlock.byteOffset);
220-
UnsafeUtility.MemCpy(valuePtr, UnsafeUtility.AddressOf(ref value), UnsafeUtility.SizeOf<PoseState>());
226+
isTracked.WriteValueIntoState(value.isTracked, statePtr);
227+
trackingState.WriteValueIntoState((uint)value.trackingState, statePtr);
228+
position.WriteValueIntoState(value.position, statePtr);
229+
rotation.WriteValueIntoState(value.rotation, statePtr);
230+
velocity.WriteValueIntoState(value.velocity, statePtr);
231+
angularVelocity.WriteValueIntoState(value.angularVelocity, statePtr);
221232
}
222233
}
223234
}

0 commit comments

Comments
 (0)