Skip to content

Commit f39667a

Browse files
committed
Iterate
1 parent 9e00ab6 commit f39667a

File tree

6 files changed

+101
-84
lines changed

6 files changed

+101
-84
lines changed

org.mixedrealitytoolkit.input/Controllers/HandModel.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Transform ModelPrefab
6969
/// the hand model prefab when implementing <see cref="ISelectInputVisualizer"/>.
7070
/// </summary>
7171
public XRInputButtonReader SelectInput => selectInput;
72-
72+
7373
#endregion Associated hand select values
7474

7575
/// <summary>
@@ -90,9 +90,13 @@ protected virtual void Start()
9090
Debug.Assert(selectInput != null, $"The Select Input reader for {handNode} is not set and will not be used with the instantiated hand model.");
9191

9292
// Set the select input reader for the model if it implements ISelectInputVisualizer
93-
if (selectInput != null && model != null && model.TryGetComponent(out ISelectInputVisualizer selectInputVisualizer))
93+
if (selectInput != null && model != null)
9494
{
95-
selectInputVisualizer.SelectInput = selectInput;
95+
ISelectInputVisualizer[] selectInputVisualizers = model.GetComponentsInChildren<ISelectInputVisualizer>();
96+
foreach (ISelectInputVisualizer selectInputVisualizer in selectInputVisualizers)
97+
{
98+
selectInputVisualizer.SelectInput = selectInput;
99+
}
96100
}
97101
}
98102
}

org.mixedrealitytoolkit.input/Visualizers/HandMeshVisualizer.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Copyright (c) Mixed Reality Toolkit Contributors
22
// Licensed under the BSD 3-Clause
33

4+
using System;
45
using System.Collections.Generic;
56
using UnityEngine;
67
using UnityEngine.XR;
8+
using UnityEngine.XR.Interaction.Toolkit;
79
using UnityEngine.XR.Interaction.Toolkit.Inputs.Readers;
810

911
namespace MixedReality.Toolkit.Input
@@ -70,6 +72,10 @@ public XRInputButtonReader SelectInput
7072
// Scratch list for checking for the presence of display subsystems.
7173
private readonly List<XRDisplaySubsystem> displaySubsystems = new List<XRDisplaySubsystem>();
7274

75+
// The XRController that is used to determine the pinch strength (i.e., select value!)
76+
[Obsolete("This field is obsolete and will be removed in a future version. Use the SelectInput property instead.")]
77+
private XRBaseController controller;
78+
7379
/// <summary>
7480
/// The list of button input readers used by this interactor. This interactor will automatically enable or disable direct actions
7581
/// if that mode is used during <see cref="OnEnable"/> and <see cref="OnDisable"/>.
@@ -201,8 +207,22 @@ private bool TryGetSelectionValue(out float value)
201207
return true;
202208
}
203209

210+
bool success = false;
204211
value = 0.0f;
205-
return false;
212+
213+
#pragma warning disable CS0618 // XRBaseController is obsolete
214+
if (controller == null)
215+
{
216+
controller = GetComponentInParent<XRBaseController>();
217+
}
218+
if (controller != null)
219+
{
220+
value = controller.selectInteractionState.value;
221+
success = true;
222+
}
223+
#pragma warning restore CS0618 // XRBaseController is obsolete
224+
225+
return success;
206226
}
207227
}
208228
}

org.mixedrealitytoolkit.input/Visualizers/HandMeshVisualizerManager.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

org.mixedrealitytoolkit.input/Visualizers/HandMeshVisualizerManager.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

org.mixedrealitytoolkit.input/Visualizers/Prefabs/openxr_right_hand.prefab

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ GameObject:
567567
m_Component:
568568
- component: {fileID: 3973969148631863464}
569569
- component: {fileID: -7366846053233975685}
570-
- component: {fileID: 9181990906488135268}
571570
m_Layer: 0
572571
m_Name: openxr_right_hand
573572
m_TagString: Untagged
@@ -626,21 +625,6 @@ MonoBehaviour:
626625
m_Flags: 0
627626
m_Flags: 0
628627
m_Reference: {fileID: 0}
629-
--- !u!114 &9181990906488135268
630-
MonoBehaviour:
631-
m_ObjectHideFlags: 0
632-
m_CorrespondingSourceObject: {fileID: 0}
633-
m_PrefabInstance: {fileID: 0}
634-
m_PrefabAsset: {fileID: 0}
635-
m_GameObject: {fileID: 4354293980546992658}
636-
m_Enabled: 1
637-
m_EditorHideFlags: 0
638-
m_Script: {fileID: 11500000, guid: 595ce5ac335c53647a1f7270d450d94b, type: 3}
639-
m_Name:
640-
m_EditorClassIdentifier:
641-
visualizers:
642-
- {fileID: 2263138549649042646}
643-
- {fileID: 1800205545854781715}
644628
--- !u!1 &4657295888579565740
645629
GameObject:
646630
m_ObjectHideFlags: 0
@@ -805,9 +789,39 @@ MonoBehaviour:
805789
m_EditorClassIdentifier:
806790
handNode: 5
807791
showHandsOnTransparentDisplays: 0
792+
pinchAmountMaterialProperty: _PinchAmount
793+
selectInput:
794+
m_InputSourceMode: 2
795+
m_InputActionPerformed:
796+
m_Name: Select
797+
m_Type: 1
798+
m_ExpectedControlType:
799+
m_Id: 5a174afe-679f-4e85-a45a-988046773313
800+
m_Processors:
801+
m_Interactions:
802+
m_SingletonActionBindings: []
803+
m_Flags: 0
804+
m_InputActionValue:
805+
m_Name: Select Value
806+
m_Type: 0
807+
m_ExpectedControlType: Axis
808+
m_Id: 8594ff63-7803-4c60-a5c8-62dc67ba5c1a
809+
m_Processors:
810+
m_Interactions:
811+
m_SingletonActionBindings: []
812+
m_Flags: 0
813+
m_InputActionReferencePerformed: {fileID: 0}
814+
m_InputActionReferenceValue: {fileID: 0}
815+
m_ObjectReferenceObject: {fileID: 0}
816+
m_ManualPerformed: 0
817+
m_ManualValue: 0
818+
m_ManualQueuePerformed: 0
819+
m_ManualQueueWasPerformedThisFrame: 0
820+
m_ManualQueueWasCompletedThisFrame: 0
821+
m_ManualQueueValue: 0
822+
m_ManualQueueTargetFrame: 0
808823
meshFilter: {fileID: 3936565761691908697}
809824
handRenderer: {fileID: 769216864695519206}
810-
pinchAmountMaterialProperty: _PinchAmount
811825
--- !u!1 &5839269735351241340
812826
GameObject:
813827
m_ObjectHideFlags: 0
@@ -924,9 +938,40 @@ MonoBehaviour:
924938
m_EditorClassIdentifier:
925939
handNode: 5
926940
showHandsOnTransparentDisplays: 0
941+
pinchAmountMaterialProperty: _PinchAmount
942+
selectInput:
943+
m_InputSourceMode: 2
944+
m_InputActionPerformed:
945+
m_Name: Select
946+
m_Type: 1
947+
m_ExpectedControlType:
948+
m_Id: 455696a2-5c34-4e97-838a-bc2b6ac85675
949+
m_Processors:
950+
m_Interactions:
951+
m_SingletonActionBindings: []
952+
m_Flags: 0
953+
m_InputActionValue:
954+
m_Name: Select Value
955+
m_Type: 0
956+
m_ExpectedControlType: Axis
957+
m_Id: de553aeb-f229-4e9f-af88-39757e695f7d
958+
m_Processors:
959+
m_Interactions:
960+
m_SingletonActionBindings: []
961+
m_Flags: 0
962+
m_InputActionReferencePerformed: {fileID: 0}
963+
m_InputActionReferenceValue: {fileID: 0}
964+
m_ObjectReferenceObject: {fileID: 0}
965+
m_ManualPerformed: 0
966+
m_ManualValue: 0
967+
m_ManualQueuePerformed: 0
968+
m_ManualQueueWasPerformedThisFrame: 0
969+
m_ManualQueueWasCompletedThisFrame: 0
970+
m_ManualQueueValue: 0
971+
m_ManualQueueTargetFrame: 0
927972
wrist: {fileID: 5446693289115484214}
928973
handRenderer: {fileID: 5709336421934327412}
929-
pinchAmountMaterialProperty: _PinchAmount
974+
primaryMeshVisualizer: {fileID: 2263138549649042646}
930975
--- !u!1 &6561479249547925302
931976
GameObject:
932977
m_ObjectHideFlags: 0

org.mixedrealitytoolkit.input/Visualizers/RiggedHandVisualizer/RiggedHandMeshVisualizer.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Collections.Generic;
77
using UnityEngine;
88
using UnityEngine.XR;
9-
using UnityEngine.XR.Interaction.Toolkit.Inputs.Readers;
109

1110
namespace MixedReality.Toolkit.Input
1211
{
@@ -30,6 +29,10 @@ public class RiggedHandMeshVisualizer : HandMeshVisualizer
3029
[Tooltip("Renderer of the hand mesh")]
3130
private SkinnedMeshRenderer handRenderer = null;
3231

32+
[SerializeField]
33+
[Tooltip("The primary visualizer. Rigged hand will not render if the primary is rendering.")]
34+
private HandMeshVisualizer primaryMeshVisualizer = null;
35+
3336
protected override Renderer HandRenderer => handRenderer;
3437

3538
// Automatically calculated over time, based on the accumulated error
@@ -230,7 +233,12 @@ private float JointError(Vector3 armatureJointPosition, Vector3 userJointPositio
230233
protected override bool ShouldRenderHand()
231234
{
232235
// If we're missing anything, don't render the hand.
233-
return handsSubsystem != null && wrist != null && handRenderer != null && base.ShouldRenderHand();
236+
// Also don't render if the preferred visualizer is rendering.
237+
return handsSubsystem != null
238+
&& wrist != null
239+
&& handRenderer != null
240+
&& (primaryMeshVisualizer == null || !primaryMeshVisualizer.IsRendering)
241+
&& base.ShouldRenderHand();
234242
}
235243
}
236244
}

0 commit comments

Comments
 (0)