Skip to content

Commit df84116

Browse files
authored
Merge pull request #9656 from keveleigh/fix-profiler-tag
Fix profiler tag in WMRHandMeshProvider
2 parents edf7056 + a82d727 commit df84116

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

Assets/MRTK/Providers/OpenXR/Scripts/OpenXRHandMeshProvider.cs

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#endif // MSFT_OPENXR_0_2_0_OR_NEWER
99

1010
using Microsoft.MixedReality.Toolkit.Input;
11+
using Unity.Profiling;
1112

1213
namespace Microsoft.MixedReality.Toolkit.XRSDK.OpenXR
1314
{
@@ -66,49 +67,54 @@ private OpenXRHandMeshProvider(HandMeshTracker handMeshTracker, Utilities.Handed
6667
/// <param name="inputSource">Implementation of the hand input source.</param>
6768
public void SetInputSource(IMixedRealityInputSource inputSource) => this.inputSource = inputSource;
6869

70+
private static readonly ProfilerMarker UpdateHandMeshPerfMarker = new ProfilerMarker($"[MRTK] {nameof(OpenXRHandMeshProvider)}.UpdateHandMesh");
71+
6972
/// <summary>
7073
/// Updates the hand mesh based on the current state of the hand.
7174
/// </summary>
7275
public void UpdateHandMesh()
7376
{
7477
#if MSFT_OPENXR_0_2_0_OR_NEWER
75-
MixedRealityInputSystemProfile inputSystemProfile = CoreServices.InputSystem?.InputSystemProfile;
76-
MixedRealityHandTrackingProfile handTrackingProfile = inputSystemProfile != null ? inputSystemProfile.HandTrackingProfile : null;
77-
78-
if (handTrackingProfile == null || !handTrackingProfile.EnableHandMeshVisualization)
78+
using (UpdateHandMeshPerfMarker.Auto())
7979
{
80-
// If hand mesh visualization is disabled make sure to clean up if we've already initialized
81-
if (handMeshUVs != null)
80+
MixedRealityInputSystemProfile inputSystemProfile = CoreServices.InputSystem?.InputSystemProfile;
81+
MixedRealityHandTrackingProfile handTrackingProfile = inputSystemProfile != null ? inputSystemProfile.HandTrackingProfile : null;
82+
83+
if (handTrackingProfile == null || !handTrackingProfile.EnableHandMeshVisualization)
8284
{
83-
// Notify that hand mesh has been updated (cleared)
84-
CoreServices.InputSystem?.RaiseHandMeshUpdated(inputSource, handedness, new HandMeshInfo());
85-
handMeshUVs = null;
85+
// If hand mesh visualization is disabled make sure to clean up if we've already initialized
86+
if (handMeshUVs != null)
87+
{
88+
// Notify that hand mesh has been updated (cleared)
89+
CoreServices.InputSystem?.RaiseHandMeshUpdated(inputSource, handedness, new HandMeshInfo());
90+
handMeshUVs = null;
91+
}
92+
return;
8693
}
87-
return;
88-
}
8994

90-
if (handMeshUVs == null && handMeshTracker.TryGetHandMesh(FrameTime.OnUpdate, neutralPoseMesh, HandPoseType.ReferenceOpenPalm))
91-
{
92-
handMeshUVs = InitializeUVs(neutralPoseMesh.vertices);
93-
}
94-
95-
if (handMeshTracker.TryGetHandMesh(FrameTime.OnUpdate, mesh) && handMeshTracker.TryLocateHandMesh(FrameTime.OnUpdate, out Pose pose))
96-
{
97-
mesh.GetVertices(vertices);
98-
mesh.GetNormals(normals);
99-
mesh.GetTriangles(triangles, 0);
95+
if (handMeshUVs == null && handMeshTracker.TryGetHandMesh(FrameTime.OnUpdate, neutralPoseMesh, HandPoseType.ReferenceOpenPalm))
96+
{
97+
handMeshUVs = InitializeUVs(neutralPoseMesh.vertices);
98+
}
10099

101-
HandMeshInfo handMeshInfo = new HandMeshInfo
100+
if (handMeshTracker.TryGetHandMesh(FrameTime.OnUpdate, mesh) && handMeshTracker.TryLocateHandMesh(FrameTime.OnUpdate, out Pose pose))
102101
{
103-
vertices = vertices.ToArray(),
104-
normals = normals.ToArray(),
105-
triangles = triangles.ToArray(),
106-
uvs = handMeshUVs,
107-
position = pose.position,
108-
rotation = pose.rotation
109-
};
110-
111-
CoreServices.InputSystem?.RaiseHandMeshUpdated(inputSource, handedness, handMeshInfo);
102+
mesh.GetVertices(vertices);
103+
mesh.GetNormals(normals);
104+
mesh.GetTriangles(triangles, 0);
105+
106+
HandMeshInfo handMeshInfo = new HandMeshInfo
107+
{
108+
vertices = vertices.ToArray(),
109+
normals = normals.ToArray(),
110+
triangles = triangles.ToArray(),
111+
uvs = handMeshUVs,
112+
position = pose.position,
113+
rotation = pose.rotation
114+
};
115+
116+
CoreServices.InputSystem?.RaiseHandMeshUpdated(inputSource, handedness, handMeshInfo);
117+
}
112118
}
113119
}
114120

Assets/MRTK/Providers/WindowsMixedReality/Shared/WindowsMixedRealityHandMeshProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private void InitializeUVs(Vector3[] neutralPoseVertices)
107107
}
108108
}
109109

110-
private static readonly ProfilerMarker UpdateHandMeshPerfMarker = new ProfilerMarker("[MRTK] WindowsMixedRealityArticulatedHandDefinition.UpdateHandMesh");
110+
private static readonly ProfilerMarker UpdateHandMeshPerfMarker = new ProfilerMarker($"[MRTK] {nameof(WindowsMixedRealityHandMeshProvider)}.UpdateHandMesh");
111111

112112
/// <summary>
113113
/// Updates the current hand mesh based on the passed in state of the hand.

0 commit comments

Comments
 (0)