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

[2.8.1] Fix null ref in WindowsMixedRealityXRSDKArticulatedHand #10622

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public WindowsMixedRealityXRSDKArticulatedHand(
private readonly ArticulatedHandDefinition handDefinition;
private readonly WindowsMixedRealityHandMeshProvider handMeshProvider;

private readonly MixedRealityPose[] unityJointPoses = null;
private MixedRealityPose[] jointPoses = null;

private static readonly HandFinger[] handFingers = Enum.GetValues(typeof(HandFinger)) as HandFinger[];
private readonly List<Bone> fingerBones = new List<Bone>();
Expand All @@ -66,9 +66,9 @@ public WindowsMixedRealityXRSDKArticulatedHand(
/// <inheritdoc/>
public bool TryGetJoint(TrackedHandJoint joint, out MixedRealityPose pose)
{
if (unityJointPoses != null)
if (jointPoses != null)
{
pose = unityJointPoses[(int)joint];
pose = jointPoses[(int)joint];
return pose != default(MixedRealityPose);
}

Expand Down Expand Up @@ -136,6 +136,11 @@ private void UpdateHandData(InputDevice inputDevice)

if (inputDevice.TryGetFeatureValue(CommonUsages.handData, out Hand hand))
{
if (jointPoses == null)
{
jointPoses = new MixedRealityPose[ArticulatedHandPose.JointCount];
}

foreach (HandFinger finger in handFingers)
{
if (hand.TryGetFingerBones(finger, fingerBones))
Expand All @@ -157,18 +162,18 @@ private void UpdateHandData(InputDevice inputDevice)
position = MixedRealityPlayspace.TransformPoint(position);
rotation = MixedRealityPlayspace.Rotation * rotation;

unityJointPoses[ConvertToArrayIndex(finger, i)] = new MixedRealityPose(position, rotation);
jointPoses[ConvertToArrayIndex(finger, i)] = new MixedRealityPose(position, rotation);
}
}

// Unity doesn't provide a palm joint, so we synthesize one here
MixedRealityPose palmPose = CurrentControllerPose;
palmPose.Rotation *= (ControllerHandedness == Handedness.Left ? leftPalmOffset : rightPalmOffset);
unityJointPoses[(int)TrackedHandJoint.Palm] = palmPose;
jointPoses[(int)TrackedHandJoint.Palm] = palmPose;
}
}

handDefinition?.UpdateHandJoints(unityJointPoses);
handDefinition?.UpdateHandJoints(jointPoses);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class UwpAppxBuildToolsTest
xmlns:mobile='http://schemas.microsoft.com/appx/manifest/mobile/windows10'
IgnorableNamespaces='uap uap2 uap3 uap4 mp mobile iot'
xmlns='http://schemas.microsoft.com/appx/manifest/foundation/windows10'>
<Identity Name='Microsoft.MixedReality.Toolkit' Publisher='CN=Microsoft' Version='2.8.0.0' />
<Identity Name='Microsoft.MixedReality.Toolkit' Publisher='CN=Microsoft' Version='2.8.1.0' />
<mp:PhoneIdentity PhoneProductId='85c8bcd4-fbac-44ed-adf6-bfc01242a27f' PhonePublisherId='00000000-0000-0000-0000-000000000000' />
<Properties>
<DisplayName>MixedRealityToolkit</DisplayName>
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 2.8.0
bundleVersion: 2.8.1
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down Expand Up @@ -700,7 +700,7 @@ PlayerSettings:
m_RenderingPath: 1
m_MobileRenderingPath: 1
metroPackageName: Microsoft.MixedReality.Toolkit
metroPackageVersion: 2.8.0.0
metroPackageVersion: 2.8.1.0
metroCertificatePath: Assets/WSATestCertificate.pfx
metroCertificatePassword:
metroCertificateSubject: Microsoft
Expand Down
2 changes: 1 addition & 1 deletion pipelines/config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variables:
# match (see scripts/packaging/versionmetadata.ps1)
# ProjectSettings/ProjectSettings.asset: bundleVersion: x.x.x
# ProjectSettings/ProjectSettings.asset: metroPackageVersion: x.x.x.0
MRTKVersion: 2.8.0
MRTKVersion: 2.8.1
MRTKReleaseTag: '' # final version component, e.g. 'RC2.1' or empty string
ToolsRepoName: mixedrealitytoolkit.build
ToolsDir: $(Build.SourcesDirectory)\$(ToolsRepoName)