Skip to content

Commit 1c11a7e

Browse files
RogPodgekeveleigh
andauthored
Unifying articulated hand visualizer scripts (#10555)
* initial work in unifying hand visuals * additional improvements to make the rigged hands class a subclass of the base class * fixed bug with hand visualizer showing up early * Update Assets/MRTK/SDK/Features/UX/Scripts/RiggedHandVisualizer/RiggedHandVisualizer.cs Co-authored-by: Kurtis <[email protected]> * pr feedback * Vetted to work on hololens, profile adjusted accordingly * removing debug code * updated tests Co-authored-by: Kurtis <[email protected]>
1 parent 42596af commit 1c11a7e

File tree

7 files changed

+213
-288
lines changed

7 files changed

+213
-288
lines changed

Assets/MRTK/Core/Providers/Hands/BaseHandVisualizer.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void OnEnable()
3434
CoreServices.InputSystem?.RegisterHandler<IMixedRealityHandMeshHandler>(this);
3535
}
3636

37-
private void Start()
37+
protected virtual void Start()
3838
{
3939
if (Controller != null)
4040
{
@@ -78,8 +78,10 @@ public bool TryGetJointTransform(TrackedHandJoint joint, out Transform jointTran
7878
return jointTransform != null;
7979
}
8080

81+
/// <inheritdoc/>
8182
void IMixedRealitySourceStateHandler.OnSourceDetected(SourceStateEventData eventData) { }
8283

84+
/// <inheritdoc/>
8385
void IMixedRealitySourceStateHandler.OnSourceLost(SourceStateEventData eventData)
8486
{
8587
// We must check if either this or gameObject equate to null because this callback may be triggered after
@@ -93,7 +95,8 @@ void IMixedRealitySourceStateHandler.OnSourceLost(SourceStateEventData eventData
9395

9496
private static readonly ProfilerMarker OnHandJointsUpdatedPerfMarker = new ProfilerMarker("[MRTK] BaseHandVisualizer.OnHandJointsUpdated");
9597

96-
void IMixedRealityHandJointHandler.OnHandJointsUpdated(InputEventData<IDictionary<TrackedHandJoint, MixedRealityPose>> eventData)
98+
/// <inheritdoc/>
99+
public virtual void OnHandJointsUpdated(InputEventData<IDictionary<TrackedHandJoint, MixedRealityPose>> eventData)
97100
{
98101
using (OnHandJointsUpdatedPerfMarker.Auto())
99102
{
@@ -173,11 +176,12 @@ void IMixedRealityHandJointHandler.OnHandJointsUpdated(InputEventData<IDictionar
173176

174177
private static readonly ProfilerMarker OnHandMeshUpdatedPerfMarker = new ProfilerMarker("[MRTK] BaseHandVisualizer.OnHandMeshUpdated");
175178

176-
public void OnHandMeshUpdated(InputEventData<HandMeshInfo> eventData)
179+
/// <inheritdoc/>
180+
public virtual void OnHandMeshUpdated(InputEventData<HandMeshInfo> eventData)
177181
{
178182
using (OnHandMeshUpdatedPerfMarker.Auto())
179183
{
180-
if (eventData.Handedness != Controller?.ControllerHandedness)
184+
if (eventData.InputSource.SourceId != Controller.InputSource.SourceId)
181185
{
182186
return;
183187
}

Assets/MRTK/Core/Providers/InputSimulation/BaseInputSimulationService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ protected BaseController GetOrAddControllerDevice(Handedness handedness, Control
126126
{
127127
case ControllerSimulationMode.HandGestures:
128128
st = SupportedControllerType.GGVHand;
129-
inputSource = Service?.RequestNewGenericInputSource($"{handedness} Hand", RequestPointers(st, handedness), InputSourceType.Hand);
129+
inputSource = Service?.RequestNewGenericInputSource($"Simulated GGV {handedness} Hand", RequestPointers(st, handedness), InputSourceType.Hand);
130130
controller = new SimulatedGestureHand(TrackingState.Tracked, handedness, inputSource);
131131
controllerType = typeof(SimulatedGestureHand);
132132
break;
133133
case ControllerSimulationMode.ArticulatedHand:
134134
st = SupportedControllerType.ArticulatedHand;
135-
inputSource = Service?.RequestNewGenericInputSource($"{handedness} Hand", RequestPointers(st, handedness), InputSourceType.Hand);
135+
inputSource = Service?.RequestNewGenericInputSource($"Simulated Articulated {handedness} Hand", RequestPointers(st, handedness), InputSourceType.Hand);
136136
controller = new SimulatedArticulatedHand(TrackingState.Tracked, handedness, inputSource);
137137
controllerType = typeof(SimulatedArticulatedHand);
138138
break;
139139
case ControllerSimulationMode.MotionController:
140140
st = SupportedControllerType.WindowsMixedReality;
141-
inputSource = Service?.RequestNewGenericInputSource($"{handedness} MotionController", RequestPointers(st, handedness), InputSourceType.Controller);
141+
inputSource = Service?.RequestNewGenericInputSource($"Simulated {handedness} MotionController", RequestPointers(st, handedness), InputSourceType.Controller);
142142
controller = new SimulatedMotionController(TrackingState.Tracked, handedness, inputSource);
143143
controllerType = typeof(SimulatedMotionController);
144144
break;

Assets/MRTK/SDK/Features/UX/Prefabs/RiggedHandVisualizer/RiggedHandLeft.prefab

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ GameObject:
99
serializedVersion: 6
1010
m_Component:
1111
- component: {fileID: 61451597023513252}
12-
- component: {fileID: 61451597030450500}
1312
- component: {fileID: 1867417485355804207}
1413
m_Layer: 0
1514
m_Name: RiggedHandLeft
@@ -33,25 +32,6 @@ Transform:
3332
m_Father: {fileID: 0}
3433
m_RootOrder: 0
3534
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36-
--- !u!95 &61451597030450500
37-
Animator:
38-
serializedVersion: 3
39-
m_ObjectHideFlags: 0
40-
m_CorrespondingSourceObject: {fileID: 0}
41-
m_PrefabInstance: {fileID: 0}
42-
m_PrefabAsset: {fileID: 0}
43-
m_GameObject: {fileID: 61451597023024772}
44-
m_Enabled: 1
45-
m_Avatar: {fileID: 9000000, guid: 6c892af280c86f242bf75a7f74a0a017, type: 3}
46-
m_Controller: {fileID: 0}
47-
m_CullingMode: 1
48-
m_UpdateMode: 0
49-
m_ApplyRootMotion: 0
50-
m_LinearVelocityBlending: 0
51-
m_WarningMessage:
52-
m_HasTransformHierarchy: 1
53-
m_AllowConstantClipSamplingOptimization: 1
54-
m_KeepAnimatorControllerStateOnDisable: 0
5535
--- !u!114 &1867417485355804207
5636
MonoBehaviour:
5737
m_ObjectHideFlags: 0
@@ -92,42 +72,42 @@ PrefabInstance:
9272
m_Modifications:
9373
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
9474
type: 3}
95-
propertyPath: m_LocalPosition.x
75+
propertyPath: m_RootOrder
9676
value: 0
9777
objectReference: {fileID: 0}
9878
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
9979
type: 3}
100-
propertyPath: m_LocalPosition.y
80+
propertyPath: m_LocalPosition.x
10181
value: 0
10282
objectReference: {fileID: 0}
10383
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
10484
type: 3}
105-
propertyPath: m_LocalPosition.z
85+
propertyPath: m_LocalPosition.y
10686
value: 0
10787
objectReference: {fileID: 0}
10888
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
10989
type: 3}
110-
propertyPath: m_LocalRotation.x
90+
propertyPath: m_LocalPosition.z
11191
value: 0
11292
objectReference: {fileID: 0}
11393
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
11494
type: 3}
115-
propertyPath: m_LocalRotation.y
116-
value: 0
95+
propertyPath: m_LocalRotation.w
96+
value: 1
11797
objectReference: {fileID: 0}
11898
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
11999
type: 3}
120-
propertyPath: m_LocalRotation.z
100+
propertyPath: m_LocalRotation.x
121101
value: 0
122102
objectReference: {fileID: 0}
123103
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
124104
type: 3}
125-
propertyPath: m_LocalRotation.w
126-
value: 1
105+
propertyPath: m_LocalRotation.y
106+
value: 0
127107
objectReference: {fileID: 0}
128108
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,
129109
type: 3}
130-
propertyPath: m_RootOrder
110+
propertyPath: m_LocalRotation.z
131111
value: 0
132112
objectReference: {fileID: 0}
133113
- target: {fileID: -8679921383154817045, guid: 95fdbeee899cda941a9083788b822772,

Assets/MRTK/SDK/Features/UX/Prefabs/RiggedHandVisualizer/RiggedHandRight.prefab

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ GameObject:
99
serializedVersion: 6
1010
m_Component:
1111
- component: {fileID: 3512491064599082542}
12-
- component: {fileID: 3512491064608922062}
1312
- component: {fileID: 520215758443510862}
1413
m_Layer: 0
1514
m_Name: RiggedHandRight
@@ -33,25 +32,6 @@ Transform:
3332
m_Father: {fileID: 0}
3433
m_RootOrder: 0
3534
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36-
--- !u!95 &3512491064608922062
37-
Animator:
38-
serializedVersion: 3
39-
m_ObjectHideFlags: 0
40-
m_CorrespondingSourceObject: {fileID: 0}
41-
m_PrefabInstance: {fileID: 0}
42-
m_PrefabAsset: {fileID: 0}
43-
m_GameObject: {fileID: 3512491064599439886}
44-
m_Enabled: 1
45-
m_Avatar: {fileID: 9000000, guid: 02898cffd4895b644b7b0ec89fdbab9e, type: 3}
46-
m_Controller: {fileID: 0}
47-
m_CullingMode: 1
48-
m_UpdateMode: 0
49-
m_ApplyRootMotion: 0
50-
m_LinearVelocityBlending: 0
51-
m_WarningMessage:
52-
m_HasTransformHierarchy: 1
53-
m_AllowConstantClipSamplingOptimization: 1
54-
m_KeepAnimatorControllerStateOnDisable: 0
5535
--- !u!114 &520215758443510862
5636
MonoBehaviour:
5737
m_ObjectHideFlags: 0
@@ -92,42 +72,42 @@ PrefabInstance:
9272
m_Modifications:
9373
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
9474
type: 3}
95-
propertyPath: m_LocalPosition.x
75+
propertyPath: m_RootOrder
9676
value: 0
9777
objectReference: {fileID: 0}
9878
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
9979
type: 3}
100-
propertyPath: m_LocalPosition.y
80+
propertyPath: m_LocalPosition.x
10181
value: 0
10282
objectReference: {fileID: 0}
10383
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
10484
type: 3}
105-
propertyPath: m_LocalPosition.z
85+
propertyPath: m_LocalPosition.y
10686
value: 0
10787
objectReference: {fileID: 0}
10888
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
10989
type: 3}
110-
propertyPath: m_LocalRotation.x
90+
propertyPath: m_LocalPosition.z
11191
value: 0
11292
objectReference: {fileID: 0}
11393
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
11494
type: 3}
115-
propertyPath: m_LocalRotation.y
116-
value: 0
95+
propertyPath: m_LocalRotation.w
96+
value: 1
11797
objectReference: {fileID: 0}
11898
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
11999
type: 3}
120-
propertyPath: m_LocalRotation.z
100+
propertyPath: m_LocalRotation.x
121101
value: 0
122102
objectReference: {fileID: 0}
123103
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
124104
type: 3}
125-
propertyPath: m_LocalRotation.w
126-
value: 1
105+
propertyPath: m_LocalRotation.y
106+
value: 0
127107
objectReference: {fileID: 0}
128108
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,
129109
type: 3}
130-
propertyPath: m_RootOrder
110+
propertyPath: m_LocalRotation.z
131111
value: 0
132112
objectReference: {fileID: 0}
133113
- target: {fileID: -8679921383154817045, guid: b64663fc62df24747a19b63a434e3490,

0 commit comments

Comments
 (0)