Skip to content

Commit f52c56d

Browse files
author
lawwong
committed
Update to v1.17.0
* Changes - Now support Focus 3 Tracker through [VBS](https://business.vive.com/us/support/vbs/category_howto/vive-business-streaming.html) - Now button for Focus 3 Tracker is mapping to ControllerButton.ApplicationMenu instead of ControllerButton.A - Remove Graphic Jobs recommended settings for Wave - According to Unity document, Graphics Jobs only supported on certain environment(Vulkan) on Android. * Bug Fixes - Fix Grabbable object with PoseFreezer calculating wrong pose when the object root is not at (0,0,0) - Fix device status for WaveHandTracking doesn't reset correctly
2 parents 5d23f18 + c908c52 commit f52c56d

File tree

17 files changed

+1290
-102
lines changed

17 files changed

+1290
-102
lines changed

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DEventData.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public class Pointer3DEventData : PointerEventData
6666

6767
public float pressDistance;
6868
public GameObject pressEnter;
69-
public bool pressPrecessed;
69+
public bool pressProcessed;
70+
[System.Obsolete("Use pressProcessed instead.")]
71+
public bool pressPrecessed { get { return pressProcessed; } set { pressProcessed = value; } }
7072

7173
public Pointer3DEventData(Pointer3DRaycaster ownerRaycaster, EventSystem eventSystem) : base(eventSystem)
7274
{

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ protected void CleanUpRaycaster(Pointer3DRaycaster raycaster)
227227

228228
buttonEventData.Reset();
229229

230-
if (buttonEventData.pressPrecessed)
230+
if (buttonEventData.pressProcessed)
231231
{
232232
ProcessPressUp(buttonEventData);
233233
HandlePressExitAndEnter(buttonEventData, null);
@@ -378,14 +378,14 @@ protected virtual void ProcessPress(Pointer3DEventData eventData)
378378
{
379379
if (eventData.GetPress())
380380
{
381-
if (!eventData.pressPrecessed)
381+
if (!eventData.pressProcessed)
382382
{
383383
ProcessPressDown(eventData);
384384
}
385385

386386
HandlePressExitAndEnter(eventData, eventData.pointerCurrentRaycast.gameObject);
387387
}
388-
else if (eventData.pressPrecessed)
388+
else if (eventData.pressProcessed)
389389
{
390390
ProcessPressUp(eventData);
391391
HandlePressExitAndEnter(eventData, null);
@@ -396,7 +396,7 @@ protected void ProcessPressDown(Pointer3DEventData eventData)
396396
{
397397
var currentOverGo = eventData.pointerCurrentRaycast.gameObject;
398398

399-
eventData.pressPrecessed = true;
399+
eventData.pressProcessed = true;
400400
eventData.eligibleForClick = true;
401401
eventData.delta = Vector2.zero;
402402
eventData.dragging = false;
@@ -473,7 +473,7 @@ protected void ProcessPressUp(Pointer3DEventData eventData)
473473
ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.dropHandler);
474474
}
475475

476-
eventData.pressPrecessed = false;
476+
eventData.pressProcessed = false;
477477
eventData.eligibleForClick = false;
478478
eventData.pointerPress = null;
479479
eventData.rawPointerPress = null;

Assets/HTC.UnityPlugin/VRModule/Modules/OculusVRModule.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ private bool IsHand()
264264
private string m_systemHeadsetName;
265265
private OVRPlugin.TrackingOrigin m_prevTrackingSpace;
266266

267+
private VRModule.SubmoduleBase.Collection submodules = new VRModule.SubmoduleBase.Collection();
268+
269+
public override uint reservedDeviceIndex { get { return (uint)(s_index2node.Length - 1); } }
270+
267271
#if VIU_OCULUSVR_20_0_OR_NEWER
268272
private struct SkeletonData
269273
{
@@ -366,12 +370,16 @@ public override bool ShouldActiveModule()
366370
return XRSettings.enabled && XRSettings.loadedDeviceName == "Oculus";
367371
#endif
368372
#pragma warning restore 0162
373+
374+
submodules.ActivateAllModules();
369375
}
370376

371377
public override void OnActivated()
372378
{
373379
Debug.Log("OculusVRModule activated.");
374380

381+
submodules.DeactivateAllModules();
382+
375383
m_systemHeadsetType = OVRPlugin.GetSystemHeadsetType();
376384
m_systemHeadsetName = m_systemHeadsetType.ToString();
377385
m_prevTrackingSpace = OVRPlugin.GetTrackingOriginType();
@@ -480,7 +488,7 @@ public override void BeforeRenderUpdate()
480488
{
481489
FlushDeviceState();
482490

483-
for (uint i = 0u, imax = GetDeviceStateLength(); i < imax; ++i)
491+
for (uint i = 0u, imax = (uint)s_index2node.Length; i < imax; ++i)
484492
{
485493
var node = s_index2node[i];
486494
var deviceClass = s_index2class[i];
@@ -840,6 +848,10 @@ public override void BeforeRenderUpdate()
840848
//}
841849
}
842850

851+
submodules.UpdateAllModulesActivity();
852+
submodules.UpdateModulesDeviceConnectionAndPoses();
853+
submodules.UpdateModulesDeviceInput();
854+
843855
ProcessConnectedDeviceChanged();
844856
ProcessDevicePoseChanged();
845857
ProcessDeviceInputChanged();

Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ private void UpdateViveWristTrackerState(IVRModuleDeviceStateRW state, InputDevi
603603
bool primaryButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.primaryButton);
604604
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton);
605605

606-
state.SetButtonPress(VRModuleRawButton.A, primaryButton);
606+
state.SetButtonPress(VRModuleRawButton.ApplicationMenu, primaryButton);
607607
state.SetButtonPress(VRModuleRawButton.System, menuButton);
608608
}
609609

Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModuleBase.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ private struct XRInputSubsystemProfile
8888
new WaveTrackerSubmodule()
8989
);
9090

91+
private bool[] prevDeviceConnected = new bool[VRModule.MAX_DEVICE_COUNT];
92+
private bool[] currDeviceConnected = new bool[VRModule.MAX_DEVICE_COUNT];
93+
private void FlushDeviceConnectedState()
94+
{
95+
var temp = prevDeviceConnected;
96+
prevDeviceConnected = currDeviceConnected;
97+
currDeviceConnected = temp;
98+
Array.Clear(currDeviceConnected, 0, (int)VRModule.MAX_DEVICE_COUNT);
99+
}
100+
91101
protected VRModuleKnownXRLoader KnownActiveLoader { get { return knownActiveLoader; } }
92102
protected VRModuleKnownXRInputSubsystem KnownActiveInputSubsystem { get { return knownActiveInputSubsystem; } }
93103

@@ -219,26 +229,40 @@ public sealed override void BeforeRenderUpdate()
219229
currState.angularVelocity = GetDeviceFeatureValueOrDefault(device, CommonUsages.deviceAngularVelocity);
220230
}
221231

232+
currDeviceConnected[deviceIndex] = true;
233+
222234
// TODO: update hand skeleton pose
223235
}
224236

225237
// unmap index for disconnected device state
226-
deviceIndex = 0u;
227-
for (var len = GetDeviceStateLength(); deviceIndex < len; ++deviceIndex)
238+
for (uint i = 0u, imax = VRModule.MAX_DEVICE_COUNT; i < imax; ++i)
228239
{
229-
if (indexMap.IsMapped(deviceIndex))
240+
if (prevDeviceConnected[i] && !currDeviceConnected[i])
230241
{
231-
EnsureValidDeviceState(deviceIndex, out prevState, out currState);
232-
if (prevState.isConnected && !currState.isConnected)
242+
if (indexMap.IsMapped(deviceIndex))
233243
{
234244
indexMap.UnmapByIndex(deviceIndex);
245+
}
246+
else
247+
{
248+
Debug.LogWarning("[UnityXRModule] Disconnected device[" + deviceIndex + "] already unmapped");
249+
}
250+
251+
if (TryGetValidDeviceState(deviceIndex, out prevState, out currState) && currState.isConnected)
252+
{
235253
currState.Reset();
236254
if (uxrRightIndex == deviceIndex) { uxrRightIndex = INVALID_DEVICE_INDEX; }
237255
if (uxrLeftIndex == deviceIndex) { uxrLeftIndex = INVALID_DEVICE_INDEX; }
238256
}
257+
else
258+
{
259+
Debug.LogWarning("[UnityXRModule] Disconnected device[" + deviceIndex + "] already been reset");
260+
}
239261
}
240262
}
241263

264+
FlushDeviceConnectedState();
265+
242266
submodules.UpdateModulesDeviceConnectionAndPoses();
243267

244268
// process hand role

Assets/HTC.UnityPlugin/VRModule/Submodules/WaveHandTrackingSubmodule.cs

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ protected override void OnDeactivated()
6464
protected override void OnUpdateDeviceConnectionAndPoses()
6565
{
6666
trackingActivator.SetActive(deviceFeature.supportTracking);
67+
gestureActivator.SetActive(VRModuleSettings.enableWaveHandGesture && deviceFeature.supportGesture);
6768

6869
if (VRModule.trackingSpaceType == VRModuleTrackingSpaceType.RoomScale)
6970
{
@@ -74,10 +75,16 @@ protected override void OnUpdateDeviceConnectionAndPoses()
7475
trackingActivator.TryFetchData(WVR_PoseOriginModel.WVR_PoseOriginModel_OriginOnHead);
7576
}
7677

78+
gestureActivator.TryFetchData();
79+
80+
var isFocused = Interop.WVR_IsInputFocusCapturedBySystem();
81+
var isLeftValid = !isFocused && (trackingActivator.isLeftValid || gestureActivator.isLeftValid);
82+
var isRightValid = !isFocused && (trackingActivator.isRightValid || gestureActivator.isRightValid);
83+
7784
IVRModuleDeviceState prevState;
7885
IVRModuleDeviceStateRW currState;
7986
// update connection/pose for left hand devices
80-
if (trackingActivator.isLeftValid)
87+
if (isLeftValid)
8188
{
8289
if (leftDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
8390
{
@@ -97,7 +104,10 @@ protected override void OnUpdateDeviceConnectionAndPoses()
97104
}
98105

99106
currState.isConnected = true;
107+
100108
trackingActivator.UpdateJoints(currState, true);
109+
trackingActivator.UpdateDeviceInput(currState, true);
110+
gestureActivator.UpdateDeviceInput(currState, true);
101111
}
102112
else
103113
{
@@ -109,7 +119,7 @@ protected override void OnUpdateDeviceConnectionAndPoses()
109119
}
110120
}
111121

112-
if (trackingActivator.isRightValid)
122+
if (isRightValid)
113123
{
114124
if (rightDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
115125
{
@@ -129,7 +139,10 @@ protected override void OnUpdateDeviceConnectionAndPoses()
129139
}
130140

131141
currState.isConnected = true;
142+
132143
trackingActivator.UpdateJoints(currState, false);
144+
trackingActivator.UpdateDeviceInput(currState, false);
145+
gestureActivator.UpdateDeviceInput(currState, false);
133146
}
134147
else
135148
{
@@ -142,46 +155,6 @@ protected override void OnUpdateDeviceConnectionAndPoses()
142155
}
143156
}
144157

145-
protected override void OnUpdateDeviceInput()
146-
{
147-
gestureActivator.SetActive(VRModuleSettings.enableWaveHandGesture && deviceFeature.supportGesture);
148-
149-
gestureActivator.TryFetchData();
150-
151-
IVRModuleDeviceState prevState;
152-
IVRModuleDeviceStateRW currState;
153-
154-
if (leftDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
155-
{
156-
if (gestureActivator.isLeftValid)
157-
{
158-
EnsureValidDeviceState(leftDeviceIndex, out prevState, out currState);
159-
gestureActivator.UpdateGestureInput(currState, true);
160-
}
161-
162-
if (trackingActivator.isLeftValid)
163-
{
164-
EnsureValidDeviceState(leftDeviceIndex, out prevState, out currState);
165-
trackingActivator.UpdateDeviceInput(currState, true);
166-
}
167-
}
168-
169-
if (rightDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
170-
{
171-
if (gestureActivator.isRightValid)
172-
{
173-
EnsureValidDeviceState(rightDeviceIndex, out prevState, out currState);
174-
gestureActivator.UpdateGestureInput(currState, false);
175-
}
176-
177-
if (trackingActivator.isRightValid)
178-
{
179-
EnsureValidDeviceState(rightDeviceIndex, out prevState, out currState);
180-
trackingActivator.UpdateDeviceInput(currState, false);
181-
}
182-
}
183-
}
184-
185158
public override uint GetLeftHandedIndex() { return leftDeviceIndex; }
186159

187160
public override uint GetRightHandedIndex() { return rightDeviceIndex; }
@@ -200,7 +173,7 @@ public static bool TryGetLeftPinchRay(out Vector3 origin, out Vector3 direction)
200173
Coordinate.GetVectorFromGL(pinch.pinch.origin, out origin);
201174
Coordinate.GetVectorFromGL(pinch.pinch.direction, out direction);
202175

203-
return true;
176+
return pinch.state.type != WVR_HandPoseType.WVR_HandPoseType_Invalid;
204177
}
205178

206179
public static bool TryGetRightPinchRay(out Vector3 origin, out Vector3 direction)
@@ -217,7 +190,7 @@ public static bool TryGetRightPinchRay(out Vector3 origin, out Vector3 direction
217190
Coordinate.GetVectorFromGL(pinch.pinch.origin, out origin);
218191
Coordinate.GetVectorFromGL(pinch.pinch.direction, out direction);
219192

220-
return true;
193+
return pinch.state.type != WVR_HandPoseType.WVR_HandPoseType_Invalid;
221194
}
222195

223196
private enum FeatureActivity
@@ -492,9 +465,9 @@ public bool TryFetchData(WVR_PoseOriginModel originModel)
492465
return false;
493466
}
494467

495-
public bool isLeftValid { get { return trackingData.left.isValidPose && !Interop.WVR_IsInputFocusCapturedBySystem(); } }
468+
public bool isLeftValid { get { return trackingData.left.isValidPose; } }
496469

497-
public bool isRightValid { get { return trackingData.right.isValidPose && !Interop.WVR_IsInputFocusCapturedBySystem(); } }
470+
public bool isRightValid { get { return trackingData.right.isValidPose; } }
498471

499472
public WVR_HandPoseState_t getLeftPinchData { get { return pinchData.left; } }
500473

@@ -787,20 +760,21 @@ public bool TryFetchData()
787760
return false;
788761
}
789762

790-
public void UpdateGestureInput(IVRModuleDeviceStateRW state, bool isLeft)
763+
public void UpdateDeviceInput(IVRModuleDeviceStateRW state, bool isLeft)
791764
{
792765
var gesture = isLeft ? gestureData.left : gestureData.right;
766+
793767
state.SetButtonPress(VRModuleRawButton.GestureFist, gesture == WVR_HandGestureType.WVR_HandGestureType_Fist);
794-
state.SetButtonPress(VRModuleRawButton.GestureFive, gesture == WVR_HandGestureType.WVR_HandGestureType_Five);
795-
state.SetButtonPress(VRModuleRawButton.GestureIndexUp, gesture == WVR_HandGestureType.WVR_HandGestureType_IndexUp);
796-
state.SetButtonPress(VRModuleRawButton.GestureOk, gesture == WVR_HandGestureType.WVR_HandGestureType_OK);
797-
state.SetButtonPress(VRModuleRawButton.GestureThumbUp, gesture == WVR_HandGestureType.WVR_HandGestureType_ThumbUp);
798-
state.SetButtonPress(VRModuleRawButton.System, gesture == WVR_HandGestureType_WVR_HandGestureType_Palm_Pinch);
799768
state.SetButtonTouch(VRModuleRawButton.GestureFist, gesture == WVR_HandGestureType.WVR_HandGestureType_Fist);
769+
state.SetButtonPress(VRModuleRawButton.GestureFive, gesture == WVR_HandGestureType.WVR_HandGestureType_Five);
800770
state.SetButtonTouch(VRModuleRawButton.GestureFive, gesture == WVR_HandGestureType.WVR_HandGestureType_Five);
771+
state.SetButtonPress(VRModuleRawButton.GestureIndexUp, gesture == WVR_HandGestureType.WVR_HandGestureType_IndexUp);
801772
state.SetButtonTouch(VRModuleRawButton.GestureIndexUp, gesture == WVR_HandGestureType.WVR_HandGestureType_IndexUp);
773+
state.SetButtonPress(VRModuleRawButton.GestureOk, gesture == WVR_HandGestureType.WVR_HandGestureType_OK);
802774
state.SetButtonTouch(VRModuleRawButton.GestureOk, gesture == WVR_HandGestureType.WVR_HandGestureType_OK);
775+
state.SetButtonPress(VRModuleRawButton.GestureThumbUp, gesture == WVR_HandGestureType.WVR_HandGestureType_ThumbUp);
803776
state.SetButtonTouch(VRModuleRawButton.GestureThumbUp, gesture == WVR_HandGestureType.WVR_HandGestureType_ThumbUp);
777+
state.SetButtonPress(VRModuleRawButton.System, gesture == WVR_HandGestureType_WVR_HandGestureType_Palm_Pinch);
804778
state.SetButtonTouch(VRModuleRawButton.System, gesture == WVR_HandGestureType_WVR_HandGestureType_Palm_Pinch);
805779
}
806780

Assets/HTC.UnityPlugin/VRModule/VRModuleBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ private struct WVRCtrlProfile
8080

8181
public abstract int moduleIndex { get; }
8282

83+
// reserved device index, so any device index less then this will not be occupied by submodule
84+
public virtual uint reservedDeviceIndex { get { return HMD_DEVICE_INDEX; } }
85+
8386
public virtual bool ShouldActiveModule() { return false; }
8487

8588
public void Activated()

Assets/HTC.UnityPlugin/VRModule/VRModuleManager.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,21 @@ private void EnsureValidDeviceState(uint index, out IVRModuleDeviceState prevSta
197197
// this function will skip VRModule.HMD_DEVICE_INDEX (preserved index for HMD)
198198
private uint FindAndEnsureUnusedNotHMDDeviceState(out IVRModuleDeviceState prevState, out IVRModuleDeviceStateRW currState)
199199
{
200+
var index = (m_activatedModuleBase == null ? VRModule.HMD_DEVICE_INDEX : m_activatedModuleBase.reservedDeviceIndex) + 1u;
200201
var len = GetDeviceStateLength();
201-
for (uint i = 0u, imax = len; i < imax; ++i)
202+
for (; index < len; ++index)
202203
{
203-
if (i == VRModule.HMD_DEVICE_INDEX) { continue; }
204-
if (TryGetValidDeviceState(i, out prevState, out currState))
204+
if (TryGetValidDeviceState(index, out prevState, out currState))
205205
{
206206
if (prevState.isConnected) { continue; }
207207
if (currState.isConnected) { continue; }
208+
return index;
208209
}
209-
210-
EnsureValidDeviceState(i, out prevState, out currState);
211-
return i;
210+
break;
212211
}
213212

214-
EnsureValidDeviceState(len, out prevState, out currState);
215-
return len;
213+
EnsureValidDeviceState(index, out prevState, out currState);
214+
return index;
216215
}
217216

218217
private void Update()

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/WaveVRSettings.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ public WaveVRRecommendedSettings()
4747
#endif
4848
recommendedValue = true,
4949
});
50-
51-
#if UNITY_5_4_OR_NEWER
52-
Add(new VIUVersionCheck.RecommendedSetting<bool>()
53-
{
54-
settingTitle = "Graphic Jobs",
55-
skipCheckFunc = () => !VIUSettingsEditor.supportWaveVR,
56-
currentValueFunc = () => PlayerSettings.graphicsJobs,
57-
setValueFunc = v => PlayerSettings.graphicsJobs = v,
58-
recommendedValue = true,
59-
});
60-
#endif
6150
}
6251
}
6352

0 commit comments

Comments
 (0)