diff --git a/com.htc.upm.vive.openxr/Runtime/CompositionLayer/Scripts/CompositionLayerPassthroughAPI.cs b/com.htc.upm.vive.openxr/Runtime/CompositionLayer/Scripts/CompositionLayerPassthroughAPI.cs index ce8ce5a..64868ba 100644 --- a/com.htc.upm.vive.openxr/Runtime/CompositionLayer/Scripts/CompositionLayerPassthroughAPI.cs +++ b/com.htc.upm.vive.openxr/Runtime/CompositionLayer/Scripts/CompositionLayerPassthroughAPI.cs @@ -359,10 +359,10 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough #if UNITY_STANDALONE private static void SubmitLayer() { + XR_HTC_passthrough.Interop.GetOriginEndFrameLayerList(out List layerList);//GetOriginEndFrameLayers foreach(var passthrough in passthrough2IsUnderLay.Keys) { //Get and submit layer list - XR_HTC_passthrough.Interop.GetOriginEndFrameLayerList(out List layerList);//GetOriginEndFrameLayers if (layerList.Count != 0) { Marshal.StructureToPtr(passthrough2Layer[passthrough], passthrough2LayerPtr[passthrough], false); @@ -370,9 +370,9 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough layerList.Insert(0, passthrough2LayerPtr[passthrough]); else layerList.Insert(1, passthrough2LayerPtr[passthrough]); - XR_HTC_passthrough.Interop.SubmitLayers(layerList); } } + XR_HTC_passthrough.Interop.SubmitLayers(layerList); } #endif @@ -393,21 +393,23 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough ERROR("HTC_Passthrough feature instance not found."); return false; } - - if (!passthroughFeature.PassthroughIDList.Contains(passthroughID)) - { - ERROR("Passthrough to be destroyed not found"); - return false; - } + if (!passthroughFeature.PassthroughIDList.Contains(passthroughID)) + { + ERROR("Passthrough to be destroyed not found"); + return false; + } #if UNITY_STANDALONE - XrPassthroughHTC passthrough = (XrPassthroughHTC)(ulong)passthroughID; - passthrough2Layer.Remove(passthroughID); - Marshal.FreeHGlobal(passthrough2LayerPtr[passthroughID]); - passthrough2LayerPtr.Remove(passthroughID); + XrPassthroughHTC passthrough = passthrough2Layer[passthroughID].passthrough; + XR_HTC_passthrough.xrDestroyPassthroughHTC(passthrough); passthrough2IsUnderLay.Remove(passthroughID); - Marshal.FreeHGlobal(passthrough2meshTransformInfoPtr[passthroughID]); + SubmitLayer(); + passthrough2Layer.Remove(passthroughID); + if(passthrough2LayerPtr.ContainsKey(passthroughID)) Marshal.FreeHGlobal(passthrough2LayerPtr[passthroughID]); + passthrough2LayerPtr.Remove(passthroughID); + if(passthrough2meshTransformInfoPtr.ContainsKey(passthroughID)) Marshal.FreeHGlobal(passthrough2meshTransformInfoPtr[passthroughID]); passthrough2meshTransformInfoPtr.Remove(passthroughID); passthrough2meshTransform.Remove(passthroughID); + return true; #endif #if UNITY_ANDROID diff --git a/com.htc.upm.vive.openxr/Runtime/Features/CompositionLayer/Scripts/ViveCompositionLayerPassthrough.cs b/com.htc.upm.vive.openxr/Runtime/Features/CompositionLayer/Scripts/ViveCompositionLayerPassthrough.cs index fa98073..5da2140 100644 --- a/com.htc.upm.vive.openxr/Runtime/Features/CompositionLayer/Scripts/ViveCompositionLayerPassthrough.cs +++ b/com.htc.upm.vive.openxr/Runtime/Features/CompositionLayer/Scripts/ViveCompositionLayerPassthrough.cs @@ -527,7 +527,10 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough XrResult res = xrCreatePassthroughHTC(m_XrSession, createInfo, out passthrough); if (res == XrResult.XR_SUCCESS) + { passthroughList.Add(passthrough); + passthroughIDList.Add(((int)(ulong)passthrough)); + } else ERROR("CreatePassthroughHTC() "+res); return res; @@ -541,6 +544,7 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough if (res == XrResult.XR_SUCCESS) { passthroughList.Remove(passthrough); + passthroughIDList.Remove(((int)(ulong)passthrough)); } return res; } diff --git a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Planar.unity b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Planar.unity index db09ab2..2ae1dc3 100644 --- a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Planar.unity +++ b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Planar.unity @@ -348,6 +348,7 @@ MeshRenderer: m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 @@ -396,6 +397,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 6.042} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 5 @@ -433,6 +435,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1713029778} m_RootOrder: 1 @@ -477,7 +480,12 @@ MonoBehaviour: m_LineSpacing: 1 m_Text: 'Press B to switch to Overlay. - Press A to switch to Underlay.' + Press A to switch to Underlay. + + Press + GripR to create passthrough. + + Press GripL to destroy passthrough.' --- !u!222 &563979743 CanvasRenderer: m_ObjectHideFlags: 0 @@ -513,6 +521,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 3 @@ -618,6 +627,7 @@ Transform: m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 4 @@ -789,6 +799,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 3.05} m_LocalScale: {x: 0.001, y: 0.001, z: 0.001} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1792614228} - {fileID: 563979741} @@ -828,6 +839,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1713029778} m_RootOrder: 0 @@ -905,6 +917,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} m_Name: m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 m_MoveRepeatDelay: 0.5 m_MoveRepeatRate: 0.1 m_XRTrackingOrigin: {fileID: 486770172} @@ -921,6 +934,7 @@ MonoBehaviour: m_TrackedDeviceOrientationAction: {fileID: -8081773802841398021, guid: 699f4d2073ed2e34ea7f7944795b868c, type: 3} m_DeselectOnBackgroundClick: 1 m_PointerBehavior: 0 + m_CursorLockBehavior: 0 --- !u!114 &1934135425 MonoBehaviour: m_ObjectHideFlags: 0 @@ -946,6 +960,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 diff --git a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Projection.unity b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Projection.unity index a485b03..f104ae5 100644 --- a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Projection.unity +++ b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Projection.unity @@ -150,6 +150,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 227549055} - {fileID: 1897936060} @@ -159,7 +160,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 1000, y: 135} + m_AnchoredPosition: {x: 1000, y: 75} m_SizeDelta: {x: 2000, y: 120} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &18497396 @@ -509,6 +510,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 18497395} m_RootOrder: 0 @@ -586,6 +588,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0.618, z: 2.226} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 4 @@ -618,6 +621,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1561711923} m_RootOrder: 0 @@ -691,6 +695,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1623327190} m_Father: {fileID: 1897936060} @@ -734,6 +739,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1713029778} m_RootOrder: 1 @@ -783,7 +789,12 @@ MonoBehaviour: Press X to switch to World Lock Pose. - Press Y to switch to Head Lock Pose.' + Press Y to switch to Head Lock Pose. + + Press + GripR to create passthrough. + + Press GripL to destroy passthrough.' --- !u!222 &563979743 CanvasRenderer: m_ObjectHideFlags: 0 @@ -825,6 +836,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 18497395} m_RootOrder: 2 @@ -903,6 +915,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 3 @@ -1119,6 +1132,7 @@ Transform: m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 6 @@ -1208,6 +1222,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1897936060} m_RootOrder: 0 @@ -1281,6 +1296,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 255383794} m_Father: {fileID: 1897936060} @@ -1319,6 +1335,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 461691196} m_RootOrder: 0 @@ -1476,6 +1493,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 3.05} m_LocalScale: {x: 0.001, y: 0.001, z: 0.001} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1792614228} - {fileID: 563979741} @@ -1516,6 +1534,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1713029778} m_RootOrder: 0 @@ -1590,6 +1609,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 5, y: 5, z: 5} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1315847422} - {fileID: 1561711923} @@ -1696,6 +1716,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} m_Name: m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 m_MoveRepeatDelay: 0.5 m_MoveRepeatRate: 0.1 m_XRTrackingOrigin: {fileID: 486770172} @@ -1712,6 +1733,7 @@ MonoBehaviour: m_TrackedDeviceOrientationAction: {fileID: -8081773802841398021, guid: 699f4d2073ed2e34ea7f7944795b868c, type: 3} m_DeselectOnBackgroundClick: 1 m_PointerBehavior: 0 + m_CursorLockBehavior: 0 --- !u!114 &1934135425 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1737,6 +1759,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 diff --git a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Planar.cs b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Planar.cs index 02036e7..0189377 100644 --- a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Planar.cs +++ b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Planar.cs @@ -16,10 +16,7 @@ namespace VIVE.OpenXR.CompositionLayer.Samples.Passthrough private void Update() { - if (activePassthroughID == 0) - { - StartPassthrough(); - } + if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.B)) //Set Passthrough as Overlay { @@ -29,6 +26,21 @@ namespace VIVE.OpenXR.CompositionLayer.Samples.Passthrough { SetPassthroughToUnderlay(); } + if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripR)) + { + if (activePassthroughID == 0) + { + StartPassthrough(); + } + } + if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripL)) + { + if(activePassthroughID != 0) + { + CompositionLayerPassthroughAPI.DestroyPassthrough(activePassthroughID); + activePassthroughID = 0; + } + } } public void SetPassthroughToOverlay() diff --git a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Projection.cs b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Projection.cs index d82d52d..8de4007 100644 --- a/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Projection.cs +++ b/com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Projection.cs @@ -55,11 +55,22 @@ namespace VIVE.OpenXR.CompositionLayer.Samples.Passthrough if (activePassthroughID != 0) SetPassthroughMesh(); } - if (passthroughMesh != null && passthroughMeshTransform != null) + if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripR)) { - if (activePassthroughID == 0) + if (passthroughMesh != null && passthroughMeshTransform != null) { - StartPassthrough(); + if (activePassthroughID == 0) + { + StartPassthrough(); + } + } + } + if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripL)) + { + if (activePassthroughID != 0) + { + CompositionLayerPassthroughAPI.DestroyPassthrough(activePassthroughID); + activePassthroughID = 0; } } } diff --git a/com.htc.upm.vive.openxr/package.json b/com.htc.upm.vive.openxr/package.json index e6d4a19..9b412e9 100644 --- a/com.htc.upm.vive.openxr/package.json +++ b/com.htc.upm.vive.openxr/package.json @@ -1,7 +1,7 @@ { "name": "com.htc.upm.vive.openxr", "displayName": "VIVE OpenXR Plugin", - "version": "2.4.0", + "version": "2.4.1", "unity": "2020.3", "description": "The \"VIVE OpenXR Plugin\" package enables your application to run on VIVE devices. \nThis package is a bridge between VIVE devides and Unity OpenXR.\nThis package complements Unity's \"OpenXR Plugin\" package, and enables you to use extra features, as listed in the following.\n\n- Controller Input\n- Hand Tracking\n- Wrist Tracking\n- Eye Gaze\n- CompositionLayer\n- Facial Tracking\n\n\nYou can view the documentation for additional information.", "keywords": [