Skip to content

Commit

Permalink
Update to v1.17.0
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lawwong committed Apr 27, 2022
2 parents 5d23f18 + c908c52 commit f52c56d
Show file tree
Hide file tree
Showing 17 changed files with 1,290 additions and 102 deletions.
4 changes: 3 additions & 1 deletion Assets/HTC.UnityPlugin/Pointer3D/Pointer3DEventData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public class Pointer3DEventData : PointerEventData

public float pressDistance;
public GameObject pressEnter;
public bool pressPrecessed;
public bool pressProcessed;
[System.Obsolete("Use pressProcessed instead.")]
public bool pressPrecessed { get { return pressProcessed; } set { pressProcessed = value; } }

public Pointer3DEventData(Pointer3DRaycaster ownerRaycaster, EventSystem eventSystem) : base(eventSystem)
{
Expand Down
10 changes: 5 additions & 5 deletions Assets/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected void CleanUpRaycaster(Pointer3DRaycaster raycaster)

buttonEventData.Reset();

if (buttonEventData.pressPrecessed)
if (buttonEventData.pressProcessed)
{
ProcessPressUp(buttonEventData);
HandlePressExitAndEnter(buttonEventData, null);
Expand Down Expand Up @@ -378,14 +378,14 @@ protected virtual void ProcessPress(Pointer3DEventData eventData)
{
if (eventData.GetPress())
{
if (!eventData.pressPrecessed)
if (!eventData.pressProcessed)
{
ProcessPressDown(eventData);
}

HandlePressExitAndEnter(eventData, eventData.pointerCurrentRaycast.gameObject);
}
else if (eventData.pressPrecessed)
else if (eventData.pressProcessed)
{
ProcessPressUp(eventData);
HandlePressExitAndEnter(eventData, null);
Expand All @@ -396,7 +396,7 @@ protected void ProcessPressDown(Pointer3DEventData eventData)
{
var currentOverGo = eventData.pointerCurrentRaycast.gameObject;

eventData.pressPrecessed = true;
eventData.pressProcessed = true;
eventData.eligibleForClick = true;
eventData.delta = Vector2.zero;
eventData.dragging = false;
Expand Down Expand Up @@ -473,7 +473,7 @@ protected void ProcessPressUp(Pointer3DEventData eventData)
ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.dropHandler);
}

eventData.pressPrecessed = false;
eventData.pressProcessed = false;
eventData.eligibleForClick = false;
eventData.pointerPress = null;
eventData.rawPointerPress = null;
Expand Down
14 changes: 13 additions & 1 deletion Assets/HTC.UnityPlugin/VRModule/Modules/OculusVRModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ private bool IsHand()
private string m_systemHeadsetName;
private OVRPlugin.TrackingOrigin m_prevTrackingSpace;

private VRModule.SubmoduleBase.Collection submodules = new VRModule.SubmoduleBase.Collection();

public override uint reservedDeviceIndex { get { return (uint)(s_index2node.Length - 1); } }

#if VIU_OCULUSVR_20_0_OR_NEWER
private struct SkeletonData
{
Expand Down Expand Up @@ -366,12 +370,16 @@ public override bool ShouldActiveModule()
return XRSettings.enabled && XRSettings.loadedDeviceName == "Oculus";
#endif
#pragma warning restore 0162

submodules.ActivateAllModules();
}

public override void OnActivated()
{
Debug.Log("OculusVRModule activated.");

submodules.DeactivateAllModules();

m_systemHeadsetType = OVRPlugin.GetSystemHeadsetType();
m_systemHeadsetName = m_systemHeadsetType.ToString();
m_prevTrackingSpace = OVRPlugin.GetTrackingOriginType();
Expand Down Expand Up @@ -480,7 +488,7 @@ public override void BeforeRenderUpdate()
{
FlushDeviceState();

for (uint i = 0u, imax = GetDeviceStateLength(); i < imax; ++i)
for (uint i = 0u, imax = (uint)s_index2node.Length; i < imax; ++i)
{
var node = s_index2node[i];
var deviceClass = s_index2class[i];
Expand Down Expand Up @@ -840,6 +848,10 @@ public override void BeforeRenderUpdate()
//}
}

submodules.UpdateAllModulesActivity();
submodules.UpdateModulesDeviceConnectionAndPoses();
submodules.UpdateModulesDeviceInput();

ProcessConnectedDeviceChanged();
ProcessDevicePoseChanged();
ProcessDeviceInputChanged();
Expand Down
2 changes: 1 addition & 1 deletion Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ private void UpdateViveWristTrackerState(IVRModuleDeviceStateRW state, InputDevi
bool primaryButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.primaryButton);
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton);

state.SetButtonPress(VRModuleRawButton.A, primaryButton);
state.SetButtonPress(VRModuleRawButton.ApplicationMenu, primaryButton);
state.SetButtonPress(VRModuleRawButton.System, menuButton);
}

Expand Down
34 changes: 29 additions & 5 deletions Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ private struct XRInputSubsystemProfile
new WaveTrackerSubmodule()
);

private bool[] prevDeviceConnected = new bool[VRModule.MAX_DEVICE_COUNT];
private bool[] currDeviceConnected = new bool[VRModule.MAX_DEVICE_COUNT];
private void FlushDeviceConnectedState()
{
var temp = prevDeviceConnected;
prevDeviceConnected = currDeviceConnected;
currDeviceConnected = temp;
Array.Clear(currDeviceConnected, 0, (int)VRModule.MAX_DEVICE_COUNT);
}

protected VRModuleKnownXRLoader KnownActiveLoader { get { return knownActiveLoader; } }
protected VRModuleKnownXRInputSubsystem KnownActiveInputSubsystem { get { return knownActiveInputSubsystem; } }

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

currDeviceConnected[deviceIndex] = true;

// TODO: update hand skeleton pose
}

// unmap index for disconnected device state
deviceIndex = 0u;
for (var len = GetDeviceStateLength(); deviceIndex < len; ++deviceIndex)
for (uint i = 0u, imax = VRModule.MAX_DEVICE_COUNT; i < imax; ++i)
{
if (indexMap.IsMapped(deviceIndex))
if (prevDeviceConnected[i] && !currDeviceConnected[i])
{
EnsureValidDeviceState(deviceIndex, out prevState, out currState);
if (prevState.isConnected && !currState.isConnected)
if (indexMap.IsMapped(deviceIndex))
{
indexMap.UnmapByIndex(deviceIndex);
}
else
{
Debug.LogWarning("[UnityXRModule] Disconnected device[" + deviceIndex + "] already unmapped");
}

if (TryGetValidDeviceState(deviceIndex, out prevState, out currState) && currState.isConnected)
{
currState.Reset();
if (uxrRightIndex == deviceIndex) { uxrRightIndex = INVALID_DEVICE_INDEX; }
if (uxrLeftIndex == deviceIndex) { uxrLeftIndex = INVALID_DEVICE_INDEX; }
}
else
{
Debug.LogWarning("[UnityXRModule] Disconnected device[" + deviceIndex + "] already been reset");
}
}
}

FlushDeviceConnectedState();

submodules.UpdateModulesDeviceConnectionAndPoses();

// process hand role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected override void OnDeactivated()
protected override void OnUpdateDeviceConnectionAndPoses()
{
trackingActivator.SetActive(deviceFeature.supportTracking);
gestureActivator.SetActive(VRModuleSettings.enableWaveHandGesture && deviceFeature.supportGesture);

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

gestureActivator.TryFetchData();

var isFocused = Interop.WVR_IsInputFocusCapturedBySystem();
var isLeftValid = !isFocused && (trackingActivator.isLeftValid || gestureActivator.isLeftValid);
var isRightValid = !isFocused && (trackingActivator.isRightValid || gestureActivator.isRightValid);

IVRModuleDeviceState prevState;
IVRModuleDeviceStateRW currState;
// update connection/pose for left hand devices
if (trackingActivator.isLeftValid)
if (isLeftValid)
{
if (leftDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
{
Expand All @@ -97,7 +104,10 @@ protected override void OnUpdateDeviceConnectionAndPoses()
}

currState.isConnected = true;

trackingActivator.UpdateJoints(currState, true);
trackingActivator.UpdateDeviceInput(currState, true);
gestureActivator.UpdateDeviceInput(currState, true);
}
else
{
Expand All @@ -109,7 +119,7 @@ protected override void OnUpdateDeviceConnectionAndPoses()
}
}

if (trackingActivator.isRightValid)
if (isRightValid)
{
if (rightDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
{
Expand All @@ -129,7 +139,10 @@ protected override void OnUpdateDeviceConnectionAndPoses()
}

currState.isConnected = true;

trackingActivator.UpdateJoints(currState, false);
trackingActivator.UpdateDeviceInput(currState, false);
gestureActivator.UpdateDeviceInput(currState, false);
}
else
{
Expand All @@ -142,46 +155,6 @@ protected override void OnUpdateDeviceConnectionAndPoses()
}
}

protected override void OnUpdateDeviceInput()
{
gestureActivator.SetActive(VRModuleSettings.enableWaveHandGesture && deviceFeature.supportGesture);

gestureActivator.TryFetchData();

IVRModuleDeviceState prevState;
IVRModuleDeviceStateRW currState;

if (leftDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
{
if (gestureActivator.isLeftValid)
{
EnsureValidDeviceState(leftDeviceIndex, out prevState, out currState);
gestureActivator.UpdateGestureInput(currState, true);
}

if (trackingActivator.isLeftValid)
{
EnsureValidDeviceState(leftDeviceIndex, out prevState, out currState);
trackingActivator.UpdateDeviceInput(currState, true);
}
}

if (rightDeviceIndex != VRModule.INVALID_DEVICE_INDEX)
{
if (gestureActivator.isRightValid)
{
EnsureValidDeviceState(rightDeviceIndex, out prevState, out currState);
gestureActivator.UpdateGestureInput(currState, false);
}

if (trackingActivator.isRightValid)
{
EnsureValidDeviceState(rightDeviceIndex, out prevState, out currState);
trackingActivator.UpdateDeviceInput(currState, false);
}
}
}

public override uint GetLeftHandedIndex() { return leftDeviceIndex; }

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

return true;
return pinch.state.type != WVR_HandPoseType.WVR_HandPoseType_Invalid;
}

public static bool TryGetRightPinchRay(out Vector3 origin, out Vector3 direction)
Expand All @@ -217,7 +190,7 @@ public static bool TryGetRightPinchRay(out Vector3 origin, out Vector3 direction
Coordinate.GetVectorFromGL(pinch.pinch.origin, out origin);
Coordinate.GetVectorFromGL(pinch.pinch.direction, out direction);

return true;
return pinch.state.type != WVR_HandPoseType.WVR_HandPoseType_Invalid;
}

private enum FeatureActivity
Expand Down Expand Up @@ -492,9 +465,9 @@ public bool TryFetchData(WVR_PoseOriginModel originModel)
return false;
}

public bool isLeftValid { get { return trackingData.left.isValidPose && !Interop.WVR_IsInputFocusCapturedBySystem(); } }
public bool isLeftValid { get { return trackingData.left.isValidPose; } }

public bool isRightValid { get { return trackingData.right.isValidPose && !Interop.WVR_IsInputFocusCapturedBySystem(); } }
public bool isRightValid { get { return trackingData.right.isValidPose; } }

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

Expand Down Expand Up @@ -787,20 +760,21 @@ public bool TryFetchData()
return false;
}

public void UpdateGestureInput(IVRModuleDeviceStateRW state, bool isLeft)
public void UpdateDeviceInput(IVRModuleDeviceStateRW state, bool isLeft)
{
var gesture = isLeft ? gestureData.left : gestureData.right;

state.SetButtonPress(VRModuleRawButton.GestureFist, gesture == WVR_HandGestureType.WVR_HandGestureType_Fist);
state.SetButtonPress(VRModuleRawButton.GestureFive, gesture == WVR_HandGestureType.WVR_HandGestureType_Five);
state.SetButtonPress(VRModuleRawButton.GestureIndexUp, gesture == WVR_HandGestureType.WVR_HandGestureType_IndexUp);
state.SetButtonPress(VRModuleRawButton.GestureOk, gesture == WVR_HandGestureType.WVR_HandGestureType_OK);
state.SetButtonPress(VRModuleRawButton.GestureThumbUp, gesture == WVR_HandGestureType.WVR_HandGestureType_ThumbUp);
state.SetButtonPress(VRModuleRawButton.System, gesture == WVR_HandGestureType_WVR_HandGestureType_Palm_Pinch);
state.SetButtonTouch(VRModuleRawButton.GestureFist, gesture == WVR_HandGestureType.WVR_HandGestureType_Fist);
state.SetButtonPress(VRModuleRawButton.GestureFive, gesture == WVR_HandGestureType.WVR_HandGestureType_Five);
state.SetButtonTouch(VRModuleRawButton.GestureFive, gesture == WVR_HandGestureType.WVR_HandGestureType_Five);
state.SetButtonPress(VRModuleRawButton.GestureIndexUp, gesture == WVR_HandGestureType.WVR_HandGestureType_IndexUp);
state.SetButtonTouch(VRModuleRawButton.GestureIndexUp, gesture == WVR_HandGestureType.WVR_HandGestureType_IndexUp);
state.SetButtonPress(VRModuleRawButton.GestureOk, gesture == WVR_HandGestureType.WVR_HandGestureType_OK);
state.SetButtonTouch(VRModuleRawButton.GestureOk, gesture == WVR_HandGestureType.WVR_HandGestureType_OK);
state.SetButtonPress(VRModuleRawButton.GestureThumbUp, gesture == WVR_HandGestureType.WVR_HandGestureType_ThumbUp);
state.SetButtonTouch(VRModuleRawButton.GestureThumbUp, gesture == WVR_HandGestureType.WVR_HandGestureType_ThumbUp);
state.SetButtonPress(VRModuleRawButton.System, gesture == WVR_HandGestureType_WVR_HandGestureType_Palm_Pinch);
state.SetButtonTouch(VRModuleRawButton.System, gesture == WVR_HandGestureType_WVR_HandGestureType_Palm_Pinch);
}

Expand Down
3 changes: 3 additions & 0 deletions Assets/HTC.UnityPlugin/VRModule/VRModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ private struct WVRCtrlProfile

public abstract int moduleIndex { get; }

// reserved device index, so any device index less then this will not be occupied by submodule
public virtual uint reservedDeviceIndex { get { return HMD_DEVICE_INDEX; } }

public virtual bool ShouldActiveModule() { return false; }

public void Activated()
Expand Down
15 changes: 7 additions & 8 deletions Assets/HTC.UnityPlugin/VRModule/VRModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,21 @@ private void EnsureValidDeviceState(uint index, out IVRModuleDeviceState prevSta
// this function will skip VRModule.HMD_DEVICE_INDEX (preserved index for HMD)
private uint FindAndEnsureUnusedNotHMDDeviceState(out IVRModuleDeviceState prevState, out IVRModuleDeviceStateRW currState)
{
var index = (m_activatedModuleBase == null ? VRModule.HMD_DEVICE_INDEX : m_activatedModuleBase.reservedDeviceIndex) + 1u;
var len = GetDeviceStateLength();
for (uint i = 0u, imax = len; i < imax; ++i)
for (; index < len; ++index)
{
if (i == VRModule.HMD_DEVICE_INDEX) { continue; }
if (TryGetValidDeviceState(i, out prevState, out currState))
if (TryGetValidDeviceState(index, out prevState, out currState))
{
if (prevState.isConnected) { continue; }
if (currState.isConnected) { continue; }
return index;
}

EnsureValidDeviceState(i, out prevState, out currState);
return i;
break;
}

EnsureValidDeviceState(len, out prevState, out currState);
return len;
EnsureValidDeviceState(index, out prevState, out currState);
return index;
}

private void Update()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ public WaveVRRecommendedSettings()
#endif
recommendedValue = true,
});

#if UNITY_5_4_OR_NEWER
Add(new VIUVersionCheck.RecommendedSetting<bool>()
{
settingTitle = "Graphic Jobs",
skipCheckFunc = () => !VIUSettingsEditor.supportWaveVR,
currentValueFunc = () => PlayerSettings.graphicsJobs,
setValueFunc = v => PlayerSettings.graphicsJobs = v,
recommendedValue = true,
});
#endif
}
}

Expand Down
Loading

0 comments on commit f52c56d

Please sign in to comment.