Skip to content

Commit fa1969a

Browse files
author
Sean
committed
version 2.4.1
1 parent 3dd72f5 commit fa1969a

File tree

7 files changed

+90
-23
lines changed

7 files changed

+90
-23
lines changed

com.htc.upm.vive.openxr/Runtime/CompositionLayer/Scripts/CompositionLayerPassthroughAPI.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,20 @@ public static int CreateProjectedPassthrough(LayerType layerType, ViveCompositio
359359
#if UNITY_STANDALONE
360360
private static void SubmitLayer()
361361
{
362+
XR_HTC_passthrough.Interop.GetOriginEndFrameLayerList(out List<IntPtr> layerList);//GetOriginEndFrameLayers
362363
foreach(var passthrough in passthrough2IsUnderLay.Keys)
363364
{
364365
//Get and submit layer list
365-
XR_HTC_passthrough.Interop.GetOriginEndFrameLayerList(out List<IntPtr> layerList);//GetOriginEndFrameLayers
366366
if (layerList.Count != 0)
367367
{
368368
Marshal.StructureToPtr(passthrough2Layer[passthrough], passthrough2LayerPtr[passthrough], false);
369369
if (passthrough2IsUnderLay[passthrough])
370370
layerList.Insert(0, passthrough2LayerPtr[passthrough]);
371371
else
372372
layerList.Insert(1, passthrough2LayerPtr[passthrough]);
373-
XR_HTC_passthrough.Interop.SubmitLayers(layerList);
374373
}
375374
}
375+
XR_HTC_passthrough.Interop.SubmitLayers(layerList);
376376
}
377377
#endif
378378

@@ -393,21 +393,23 @@ public static bool DestroyPassthrough(int passthroughID)
393393
ERROR("HTC_Passthrough feature instance not found.");
394394
return false;
395395
}
396-
397-
if (!passthroughFeature.PassthroughIDList.Contains(passthroughID))
398-
{
399-
ERROR("Passthrough to be destroyed not found");
400-
return false;
401-
}
396+
if (!passthroughFeature.PassthroughIDList.Contains(passthroughID))
397+
{
398+
ERROR("Passthrough to be destroyed not found");
399+
return false;
400+
}
402401
#if UNITY_STANDALONE
403-
XrPassthroughHTC passthrough = (XrPassthroughHTC)(ulong)passthroughID;
402+
XrPassthroughHTC passthrough = passthrough2Layer[passthroughID].passthrough;
403+
XR_HTC_passthrough.xrDestroyPassthroughHTC(passthrough);
404+
passthrough2IsUnderLay.Remove(passthroughID);
405+
SubmitLayer();
404406
passthrough2Layer.Remove(passthroughID);
405-
Marshal.FreeHGlobal(passthrough2LayerPtr[passthroughID]);
407+
if(passthrough2LayerPtr.ContainsKey(passthroughID)) Marshal.FreeHGlobal(passthrough2LayerPtr[passthroughID]);
406408
passthrough2LayerPtr.Remove(passthroughID);
407-
passthrough2IsUnderLay.Remove(passthroughID);
408-
Marshal.FreeHGlobal(passthrough2meshTransformInfoPtr[passthroughID]);
409+
if(passthrough2meshTransformInfoPtr.ContainsKey(passthroughID)) Marshal.FreeHGlobal(passthrough2meshTransformInfoPtr[passthroughID]);
409410
passthrough2meshTransformInfoPtr.Remove(passthroughID);
410411
passthrough2meshTransform.Remove(passthroughID);
412+
411413
return true;
412414
#endif
413415
#if UNITY_ANDROID

com.htc.upm.vive.openxr/Runtime/Features/CompositionLayer/Scripts/ViveCompositionLayerPassthrough.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,10 @@ public XrResult CreatePassthroughHTC(XrPassthroughCreateInfoHTC createInfo, out
527527

528528
XrResult res = xrCreatePassthroughHTC(m_XrSession, createInfo, out passthrough);
529529
if (res == XrResult.XR_SUCCESS)
530+
{
530531
passthroughList.Add(passthrough);
532+
passthroughIDList.Add(((int)(ulong)passthrough));
533+
}
531534
else
532535
ERROR("CreatePassthroughHTC() "+res);
533536
return res;
@@ -541,6 +544,7 @@ public XrResult DestroyPassthroughHTC(XrPassthroughHTC passthrough)
541544
if (res == XrResult.XR_SUCCESS)
542545
{
543546
passthroughList.Remove(passthrough);
547+
passthroughIDList.Remove(((int)(ulong)passthrough));
544548
}
545549
return res;
546550
}

com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Planar.unity

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ MeshRenderer:
348348
m_CastShadows: 1
349349
m_ReceiveShadows: 1
350350
m_DynamicOccludee: 1
351+
m_StaticShadowCaster: 0
351352
m_MotionVectors: 1
352353
m_LightProbeUsage: 1
353354
m_ReflectionProbeUsage: 1
@@ -396,6 +397,7 @@ Transform:
396397
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
397398
m_LocalPosition: {x: 0, y: 0, z: 6.042}
398399
m_LocalScale: {x: 1, y: 1, z: 1}
400+
m_ConstrainProportionsScale: 0
399401
m_Children: []
400402
m_Father: {fileID: 0}
401403
m_RootOrder: 5
@@ -433,6 +435,7 @@ RectTransform:
433435
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
434436
m_LocalPosition: {x: 0, y: 0, z: 0}
435437
m_LocalScale: {x: 1, y: 1, z: 1}
438+
m_ConstrainProportionsScale: 0
436439
m_Children: []
437440
m_Father: {fileID: 1713029778}
438441
m_RootOrder: 1
@@ -477,7 +480,12 @@ MonoBehaviour:
477480
m_LineSpacing: 1
478481
m_Text: 'Press B to switch to Overlay.
479482
480-
Press A to switch to Underlay.'
483+
Press A to switch to Underlay.
484+
485+
Press
486+
GripR to create passthrough.
487+
488+
Press GripL to destroy passthrough.'
481489
--- !u!222 &563979743
482490
CanvasRenderer:
483491
m_ObjectHideFlags: 0
@@ -513,6 +521,7 @@ Transform:
513521
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
514522
m_LocalPosition: {x: 0, y: 0, z: 0}
515523
m_LocalScale: {x: 1, y: 1, z: 1}
524+
m_ConstrainProportionsScale: 0
516525
m_Children: []
517526
m_Father: {fileID: 0}
518527
m_RootOrder: 3
@@ -618,6 +627,7 @@ Transform:
618627
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
619628
m_LocalPosition: {x: 0, y: 0, z: 0}
620629
m_LocalScale: {x: 1, y: 1, z: 1}
630+
m_ConstrainProportionsScale: 0
621631
m_Children: []
622632
m_Father: {fileID: 0}
623633
m_RootOrder: 4
@@ -789,6 +799,7 @@ RectTransform:
789799
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
790800
m_LocalPosition: {x: 0, y: 0, z: 3.05}
791801
m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
802+
m_ConstrainProportionsScale: 0
792803
m_Children:
793804
- {fileID: 1792614228}
794805
- {fileID: 563979741}
@@ -828,6 +839,7 @@ RectTransform:
828839
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
829840
m_LocalPosition: {x: 0, y: 0, z: 0}
830841
m_LocalScale: {x: 1, y: 1, z: 1}
842+
m_ConstrainProportionsScale: 0
831843
m_Children: []
832844
m_Father: {fileID: 1713029778}
833845
m_RootOrder: 0
@@ -905,6 +917,7 @@ MonoBehaviour:
905917
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
906918
m_Name:
907919
m_EditorClassIdentifier:
920+
m_SendPointerHoverToParent: 1
908921
m_MoveRepeatDelay: 0.5
909922
m_MoveRepeatRate: 0.1
910923
m_XRTrackingOrigin: {fileID: 486770172}
@@ -921,6 +934,7 @@ MonoBehaviour:
921934
m_TrackedDeviceOrientationAction: {fileID: -8081773802841398021, guid: 699f4d2073ed2e34ea7f7944795b868c, type: 3}
922935
m_DeselectOnBackgroundClick: 1
923936
m_PointerBehavior: 0
937+
m_CursorLockBehavior: 0
924938
--- !u!114 &1934135425
925939
MonoBehaviour:
926940
m_ObjectHideFlags: 0
@@ -946,6 +960,7 @@ Transform:
946960
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
947961
m_LocalPosition: {x: 0, y: 0, z: 0}
948962
m_LocalScale: {x: 1, y: 1, z: 1}
963+
m_ConstrainProportionsScale: 0
949964
m_Children: []
950965
m_Father: {fileID: 0}
951966
m_RootOrder: 2

com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scenes/Passthrough_Projection.unity

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ RectTransform:
150150
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
151151
m_LocalPosition: {x: 0, y: 0, z: 0}
152152
m_LocalScale: {x: 1, y: 1, z: 1}
153+
m_ConstrainProportionsScale: 0
153154
m_Children:
154155
- {fileID: 227549055}
155156
- {fileID: 1897936060}
@@ -159,7 +160,7 @@ RectTransform:
159160
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
160161
m_AnchorMin: {x: 0, y: 0}
161162
m_AnchorMax: {x: 0, y: 0}
162-
m_AnchoredPosition: {x: 1000, y: 135}
163+
m_AnchoredPosition: {x: 1000, y: 75}
163164
m_SizeDelta: {x: 2000, y: 120}
164165
m_Pivot: {x: 0.5, y: 0.5}
165166
--- !u!114 &18497396
@@ -509,6 +510,7 @@ RectTransform:
509510
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
510511
m_LocalPosition: {x: 0, y: 0, z: 0}
511512
m_LocalScale: {x: 1, y: 1, z: 1}
513+
m_ConstrainProportionsScale: 0
512514
m_Children: []
513515
m_Father: {fileID: 18497395}
514516
m_RootOrder: 0
@@ -586,6 +588,7 @@ Transform:
586588
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
587589
m_LocalPosition: {x: 0, y: 0.618, z: 2.226}
588590
m_LocalScale: {x: 1, y: 1, z: 1}
591+
m_ConstrainProportionsScale: 0
589592
m_Children: []
590593
m_Father: {fileID: 0}
591594
m_RootOrder: 4
@@ -618,6 +621,7 @@ RectTransform:
618621
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
619622
m_LocalPosition: {x: 0, y: 0, z: 0}
620623
m_LocalScale: {x: 1, y: 1, z: 1}
624+
m_ConstrainProportionsScale: 0
621625
m_Children: []
622626
m_Father: {fileID: 1561711923}
623627
m_RootOrder: 0
@@ -691,6 +695,7 @@ RectTransform:
691695
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
692696
m_LocalPosition: {x: 0, y: 0, z: 0}
693697
m_LocalScale: {x: 1, y: 1, z: 1}
698+
m_ConstrainProportionsScale: 0
694699
m_Children:
695700
- {fileID: 1623327190}
696701
m_Father: {fileID: 1897936060}
@@ -734,6 +739,7 @@ RectTransform:
734739
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
735740
m_LocalPosition: {x: 0, y: 0, z: 0}
736741
m_LocalScale: {x: 1, y: 1, z: 1}
742+
m_ConstrainProportionsScale: 0
737743
m_Children: []
738744
m_Father: {fileID: 1713029778}
739745
m_RootOrder: 1
@@ -783,7 +789,12 @@ MonoBehaviour:
783789
Press
784790
X to switch to World Lock Pose.
785791
786-
Press Y to switch to Head Lock Pose.'
792+
Press Y to switch to Head Lock Pose.
793+
794+
Press
795+
GripR to create passthrough.
796+
797+
Press GripL to destroy passthrough.'
787798
--- !u!222 &563979743
788799
CanvasRenderer:
789800
m_ObjectHideFlags: 0
@@ -825,6 +836,7 @@ RectTransform:
825836
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
826837
m_LocalPosition: {x: 0, y: 0, z: 0}
827838
m_LocalScale: {x: 1, y: 1, z: 1}
839+
m_ConstrainProportionsScale: 0
828840
m_Children: []
829841
m_Father: {fileID: 18497395}
830842
m_RootOrder: 2
@@ -903,6 +915,7 @@ Transform:
903915
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
904916
m_LocalPosition: {x: 0, y: 0, z: 0}
905917
m_LocalScale: {x: 1, y: 1, z: 1}
918+
m_ConstrainProportionsScale: 0
906919
m_Children: []
907920
m_Father: {fileID: 0}
908921
m_RootOrder: 3
@@ -1119,6 +1132,7 @@ Transform:
11191132
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
11201133
m_LocalPosition: {x: 0, y: 0, z: 0}
11211134
m_LocalScale: {x: 1, y: 1, z: 1}
1135+
m_ConstrainProportionsScale: 0
11221136
m_Children: []
11231137
m_Father: {fileID: 0}
11241138
m_RootOrder: 6
@@ -1208,6 +1222,7 @@ RectTransform:
12081222
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
12091223
m_LocalPosition: {x: 0, y: 0, z: 0}
12101224
m_LocalScale: {x: 1, y: 1, z: 1}
1225+
m_ConstrainProportionsScale: 0
12111226
m_Children: []
12121227
m_Father: {fileID: 1897936060}
12131228
m_RootOrder: 0
@@ -1281,6 +1296,7 @@ RectTransform:
12811296
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
12821297
m_LocalPosition: {x: 0, y: 0, z: 0}
12831298
m_LocalScale: {x: 1, y: 1, z: 1}
1299+
m_ConstrainProportionsScale: 0
12841300
m_Children:
12851301
- {fileID: 255383794}
12861302
m_Father: {fileID: 1897936060}
@@ -1319,6 +1335,7 @@ RectTransform:
13191335
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
13201336
m_LocalPosition: {x: 0, y: 0, z: 0}
13211337
m_LocalScale: {x: 1, y: 1, z: 1}
1338+
m_ConstrainProportionsScale: 0
13221339
m_Children: []
13231340
m_Father: {fileID: 461691196}
13241341
m_RootOrder: 0
@@ -1476,6 +1493,7 @@ RectTransform:
14761493
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
14771494
m_LocalPosition: {x: 0, y: 0, z: 3.05}
14781495
m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
1496+
m_ConstrainProportionsScale: 0
14791497
m_Children:
14801498
- {fileID: 1792614228}
14811499
- {fileID: 563979741}
@@ -1516,6 +1534,7 @@ RectTransform:
15161534
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
15171535
m_LocalPosition: {x: 0, y: 0, z: 0}
15181536
m_LocalScale: {x: 1, y: 1, z: 1}
1537+
m_ConstrainProportionsScale: 0
15191538
m_Children: []
15201539
m_Father: {fileID: 1713029778}
15211540
m_RootOrder: 0
@@ -1590,6 +1609,7 @@ RectTransform:
15901609
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
15911610
m_LocalPosition: {x: 0, y: 0, z: 0}
15921611
m_LocalScale: {x: 5, y: 5, z: 5}
1612+
m_ConstrainProportionsScale: 0
15931613
m_Children:
15941614
- {fileID: 1315847422}
15951615
- {fileID: 1561711923}
@@ -1696,6 +1716,7 @@ MonoBehaviour:
16961716
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
16971717
m_Name:
16981718
m_EditorClassIdentifier:
1719+
m_SendPointerHoverToParent: 1
16991720
m_MoveRepeatDelay: 0.5
17001721
m_MoveRepeatRate: 0.1
17011722
m_XRTrackingOrigin: {fileID: 486770172}
@@ -1712,6 +1733,7 @@ MonoBehaviour:
17121733
m_TrackedDeviceOrientationAction: {fileID: -8081773802841398021, guid: 699f4d2073ed2e34ea7f7944795b868c, type: 3}
17131734
m_DeselectOnBackgroundClick: 1
17141735
m_PointerBehavior: 0
1736+
m_CursorLockBehavior: 0
17151737
--- !u!114 &1934135425
17161738
MonoBehaviour:
17171739
m_ObjectHideFlags: 0
@@ -1737,6 +1759,7 @@ Transform:
17371759
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
17381760
m_LocalPosition: {x: 0, y: 0, z: 0}
17391761
m_LocalScale: {x: 1, y: 1, z: 1}
1762+
m_ConstrainProportionsScale: 0
17401763
m_Children: []
17411764
m_Father: {fileID: 0}
17421765
m_RootOrder: 2

com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Planar.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ public class PassthroughSample_Planar : MonoBehaviour
1616

1717
private void Update()
1818
{
19-
if (activePassthroughID == 0)
20-
{
21-
StartPassthrough();
22-
}
19+
2320

2421
if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.B)) //Set Passthrough as Overlay
2522
{
@@ -29,6 +26,21 @@ private void Update()
2926
{
3027
SetPassthroughToUnderlay();
3128
}
29+
if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripR))
30+
{
31+
if (activePassthroughID == 0)
32+
{
33+
StartPassthrough();
34+
}
35+
}
36+
if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripL))
37+
{
38+
if(activePassthroughID != 0)
39+
{
40+
CompositionLayerPassthroughAPI.DestroyPassthrough(activePassthroughID);
41+
activePassthroughID = 0;
42+
}
43+
}
3244
}
3345

3446
public void SetPassthroughToOverlay()

com.htc.upm.vive.openxr/Samples~/Samples/Samples/Passthrough/Scripts/PassthroughSample_Projection.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,22 @@ private void Update()
5555
if (activePassthroughID != 0) SetPassthroughMesh();
5656
}
5757

58-
if (passthroughMesh != null && passthroughMeshTransform != null)
58+
if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripR))
5959
{
60-
if (activePassthroughID == 0)
60+
if (passthroughMesh != null && passthroughMeshTransform != null)
6161
{
62-
StartPassthrough();
62+
if (activePassthroughID == 0)
63+
{
64+
StartPassthrough();
65+
}
66+
}
67+
}
68+
if (VRSInputManager.instance.GetButtonDown(VRSButtonReference.GripL))
69+
{
70+
if (activePassthroughID != 0)
71+
{
72+
CompositionLayerPassthroughAPI.DestroyPassthrough(activePassthroughID);
73+
activePassthroughID = 0;
6374
}
6475
}
6576
}

0 commit comments

Comments
 (0)