version 2.4.0

This commit is contained in:
Sean Lu(呂祥榮)
2024-07-03 14:58:53 +08:00
parent 7f2a459592
commit 3dd72f5f56
162 changed files with 23632 additions and 27154 deletions

View File

@@ -96,6 +96,17 @@ namespace VIVE.OpenXR.CompositionLayer
[SerializeField]
public bool isDynamicLayer = false;
[SerializeField]
public bool isExternalSurface = false;
[Tooltip("Width of external surface in pixels.")]
[SerializeField]
public uint externalSurfaceWidth = 1280;
[Tooltip("Height of external surface in pixels.")]
[SerializeField]
public uint externalSurfaceHeight = 720;
[SerializeField]
public bool applyColorScaleBias = false;
@@ -187,6 +198,58 @@ namespace VIVE.OpenXR.CompositionLayer
return true;
}
if (isExternalSurface)
{
CompositionLayerRenderThreadSyncObject SetupExternalAndroidSurfaceSyncObjects = new CompositionLayerRenderThreadSyncObject(
(taskQueue) =>
{
lock (taskQueue)
{
CompositionLayerRenderThreadTask task = (CompositionLayerRenderThreadTask)taskQueue.Dequeue();
//Enumerate Swapchain formats
compositionLayerFeature = OpenXRSettings.Instance.GetFeature<ViveCompositionLayer>();
uint imageCount;
GraphicsAPI graphicsAPI = GraphicsAPI.GLES3;
switch (SystemInfo.graphicsDeviceType)
{
case UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3:
graphicsAPI = GraphicsAPI.GLES3;
break;
case UnityEngine.Rendering.GraphicsDeviceType.Vulkan:
graphicsAPI = GraphicsAPI.Vulkan;
break;
default:
ERROR("Unsupported Graphics API, aborting init process.");
return;
}
layerID = compositionLayerFeature.CompositionLayer_Init(externalSurfaceWidth, externalSurfaceHeight, graphicsAPI, isDynamicLayer, isProtectedSurface, out imageCount, true);
if (layerID != 0)
{
DEBUG("Init completed, ID: " + layerID);
layerTextures = new LayerTextures(imageCount);
InitStatus = true;
}
taskQueue.Release(task);
}
});
CompositionLayerRenderThreadTask.IssueObtainSwapchainEvent(SetupExternalAndroidSurfaceSyncObjects);
texture = new Texture2D((int)externalSurfaceWidth, (int)externalSurfaceHeight, TextureFormat.RGBA32, false, isLinear);
DEBUG("CompositionLayerInit Ext Surf");
return true;
}
if (texture == null)
{
ERROR("CompositionLayerInit: Source Texture not found, abort init.");
@@ -262,6 +325,22 @@ namespace VIVE.OpenXR.CompositionLayer
{
if (!isInitializationComplete || !isSynchronized) return false;
if (isExternalSurface)
{
//Set Texture Layout
offset.x = 0;
offset.y = (int)externalSurfaceHeight;
extent.width = (int)externalSurfaceWidth;
extent.height = (int)-externalSurfaceHeight;
rect.offset = offset;
rect.extent = extent;
layerTextures.textureLayout = rect;
return true; //No need to process texture queues
}
if (texture != null) //check for texture size change
{
if (TextureParamsChanged())
@@ -805,6 +884,14 @@ namespace VIVE.OpenXR.CompositionLayer
}
}
public IntPtr GetExternalSurfaceObj()
{
IntPtr value = compositionLayerFeature.Compositionlayer_GetExternalSurfaceObj2(layerID);
//DEBUG("GetExternalSurfaceObj layerID " + layerID + " SurfaceObj " + value);
return value;
}
public bool RenderAsLayer()
{
if (placeholderGenerated && compositionLayerPlaceholderPrefabGO != null)

View File

@@ -1,5 +1,6 @@
// Copyright HTC Corporation All Rights Reserved.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
@@ -26,7 +27,13 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
return true;
}
#if UNITY_STANDALONE
private static Dictionary<int, XrCompositionLayerPassthroughHTC> passthrough2Layer = new Dictionary<int, XrCompositionLayerPassthroughHTC>();
private static Dictionary<int, IntPtr> passthrough2LayerPtr = new Dictionary<int, IntPtr>();
private static Dictionary<int, bool> passthrough2IsUnderLay= new Dictionary<int, bool>();
private static Dictionary<int, XrPassthroughMeshTransformInfoHTC> passthrough2meshTransform = new Dictionary<int, XrPassthroughMeshTransformInfoHTC>();
private static Dictionary<int, IntPtr> passthrough2meshTransformInfoPtr = new Dictionary<int, IntPtr>();
#endif
#region Public APIs
/// <summary>
@@ -62,9 +69,41 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("HTC_Passthrough feature instance not found.");
return passthroughID;
}
#if UNITY_ANDROID
passthroughID = passthroughFeature.HTCPassthrough_CreatePassthrough(layerType, PassthroughLayerForm.Planar, onDestroyPassthroughSessionHandler, compositionDepth);
#endif
#if UNITY_STANDALONE
XrPassthroughHTC passthrough = 0;
XrPassthroughCreateInfoHTC createInfo = new XrPassthroughCreateInfoHTC(
XrStructureType.XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC,
new IntPtr(6), //Enter IntPtr(0) for backward compatibility (using createPassthrough to enable the passthrough feature), or enter IntPtr(6) to enable the passthrough feature based on the layer submitted to endframe.
XrPassthroughFormHTC.XR_PASSTHROUGH_FORM_PLANAR_HTC
);
XrResult res = XR_HTC_passthrough.xrCreatePassthroughHTC(createInfo, out passthrough);
if(res == XrResult.XR_SUCCESS)
{
ulong passthrough_ulong = passthrough;
passthroughID = (int)passthrough_ulong;
XrPassthroughColorHTC passthroughColor = new XrPassthroughColorHTC(
in_type: XrStructureType.XR_TYPE_PASSTHROUGH_COLOR_HTC,
in_next: IntPtr.Zero,
in_alpha: alpha);
XrCompositionLayerPassthroughHTC compositionLayerPassthrough = new XrCompositionLayerPassthroughHTC(
in_type: XrStructureType.XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_HTC,
in_next: IntPtr.Zero,
in_layerFlags: ViveCompositionLayerHelper.XR_COMPOSITION_LAYER_UNPREMULTIPLIED_ALPHA_BIT,
in_space: 0,
in_passthrough: passthrough,
in_color: passthroughColor);
passthrough2Layer.Add(passthroughID, compositionLayerPassthrough);
IntPtr layerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XrCompositionLayerPassthroughHTC)));
passthrough2LayerPtr.Add(passthroughID, layerPtr);
if (layerType == LayerType.Underlay)
passthrough2IsUnderLay.Add(passthroughID, true);
if (layerType == LayerType.Overlay)
passthrough2IsUnderLay.Add(passthroughID, false);
}
#endif
if (passthroughID == 0)
{
ERROR("Failed to create projected pasthrough");
@@ -146,9 +185,57 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("Mesh data invalid.");
return passthroughID;
}
#if UNITY_STANDALONE
XrPassthroughHTC passthrough = 0;
XrPassthroughCreateInfoHTC createInfo = new XrPassthroughCreateInfoHTC(
XrStructureType.XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC,
new IntPtr(6), //Enter IntPtr(0) for backward compatibility (using createPassthrough to enable the passthrough feature), or enter IntPtr(6) to enable the passthrough feature based on the layer submitted to endframe.
XrPassthroughFormHTC.XR_PASSTHROUGH_FORM_PROJECTED_HTC
);
XrResult res = XR_HTC_passthrough.xrCreatePassthroughHTC(createInfo, out passthrough);
if (res == XrResult.XR_SUCCESS)
{
ulong passthrough_ulong = passthrough;
passthroughID = (int)passthrough_ulong;
XrPassthroughMeshTransformInfoHTC PassthroughMeshTransformInfo = new XrPassthroughMeshTransformInfoHTC(
in_type: XrStructureType.XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC,
in_next: IntPtr.Zero,
in_vertexCount: 0,
in_vertices: new XrVector3f[0],
in_indexCount: 0,
in_indices: new UInt32[0],
in_baseSpace: XR_HTC_passthrough.Interop.GetTrackingSpace(),
in_time: XR_HTC_passthrough.Interop.GetFrameState().predictedDisplayTime,
in_pose: new XrPosef(),
in_scale: new XrVector3f()
);
IntPtr meshTransformInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XrPassthroughMeshTransformInfoHTC)));
Marshal.StructureToPtr(PassthroughMeshTransformInfo, meshTransformInfoPtr, false);
XrPassthroughColorHTC passthroughColor = new XrPassthroughColorHTC(
in_type: XrStructureType.XR_TYPE_PASSTHROUGH_COLOR_HTC,
in_next: IntPtr.Zero,
in_alpha: alpha);
XrCompositionLayerPassthroughHTC compositionLayerPassthrough = new XrCompositionLayerPassthroughHTC(
in_type: XrStructureType.XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_HTC,
in_next: meshTransformInfoPtr,
in_layerFlags: ViveCompositionLayerHelper.XR_COMPOSITION_LAYER_UNPREMULTIPLIED_ALPHA_BIT,
in_space: 0,
in_passthrough: passthrough,
in_color: passthroughColor);
passthrough2meshTransform.Add(passthroughID, PassthroughMeshTransformInfo);
passthrough2meshTransformInfoPtr.Add(passthroughID, meshTransformInfoPtr);
passthrough2Layer.Add(passthroughID, compositionLayerPassthrough);
IntPtr layerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XrCompositionLayerPassthroughHTC)));
passthrough2LayerPtr.Add(passthroughID, layerPtr);
if (layerType == LayerType.Underlay)
passthrough2IsUnderLay.Add(passthroughID, true);
if (layerType == LayerType.Overlay)
passthrough2IsUnderLay.Add(passthroughID, false);
}
#endif
#if UNITY_ANDROID
passthroughID = passthroughFeature.HTCPassthrough_CreatePassthrough(layerType, PassthroughLayerForm.Projected, onDestroyPassthroughSessionHandler, compositionDepth);
#endif
if (passthroughID == 0)
{
ERROR("Failed to create projected pasthrough");
@@ -207,9 +294,57 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("HTC_Passthrough feature instance not found.");
return passthroughID;
}
#if UNITY_STANDALONE
XrPassthroughHTC passthrough = 0;
XrPassthroughCreateInfoHTC createInfo = new XrPassthroughCreateInfoHTC(
XrStructureType.XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC,
new IntPtr(6), //Enter IntPtr(0) for backward compatibility (using createPassthrough to enable the passthrough feature), or enter IntPtr(6) to enable the passthrough feature based on the layer submitted to endframe.
XrPassthroughFormHTC.XR_PASSTHROUGH_FORM_PROJECTED_HTC
);
XrResult res = XR_HTC_passthrough.xrCreatePassthroughHTC(createInfo, out passthrough);
if (res == XrResult.XR_SUCCESS)
{
ulong passthrough_ulong = passthrough;
passthroughID = (int)passthrough_ulong;
XrPassthroughMeshTransformInfoHTC PassthroughMeshTransformInfo = new XrPassthroughMeshTransformInfoHTC(
in_type: XrStructureType.XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC,
in_next: IntPtr.Zero,
in_vertexCount: 0,
in_vertices: new XrVector3f[0],
in_indexCount: 0,
in_indices: new UInt32[0],
in_baseSpace: XR_HTC_passthrough.Interop.GetTrackingSpace(),
in_time: XR_HTC_passthrough.Interop.GetFrameState().predictedDisplayTime,
in_pose: new XrPosef(),
in_scale: new XrVector3f()
);
IntPtr meshTransformInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XrPassthroughMeshTransformInfoHTC)));
Marshal.StructureToPtr(PassthroughMeshTransformInfo, meshTransformInfoPtr, false);
XrPassthroughColorHTC passthroughColor = new XrPassthroughColorHTC(
in_type: XrStructureType.XR_TYPE_PASSTHROUGH_COLOR_HTC,
in_next: IntPtr.Zero,
in_alpha: alpha);
XrCompositionLayerPassthroughHTC compositionLayerPassthrough = new XrCompositionLayerPassthroughHTC(
in_type: XrStructureType.XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_HTC,
in_next: meshTransformInfoPtr,
in_layerFlags: ViveCompositionLayerHelper.XR_COMPOSITION_LAYER_UNPREMULTIPLIED_ALPHA_BIT,
in_space: 0,
in_passthrough: passthrough,
in_color: passthroughColor);
passthrough2meshTransform.Add(passthroughID, PassthroughMeshTransformInfo);
passthrough2meshTransformInfoPtr.Add(passthroughID, meshTransformInfoPtr);
passthrough2Layer.Add(passthroughID, compositionLayerPassthrough);
IntPtr layerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XrCompositionLayerPassthroughHTC)));
passthrough2LayerPtr.Add(passthroughID, layerPtr);
if (layerType == LayerType.Underlay)
passthrough2IsUnderLay.Add(passthroughID, true);
if (layerType == LayerType.Overlay)
passthrough2IsUnderLay.Add(passthroughID, false);
}
#endif
#if UNITY_ANDROID
passthroughID = passthroughFeature.HTCPassthrough_CreatePassthrough(layerType, PassthroughLayerForm.Projected, onDestroyPassthroughSessionHandler);
#endif
if (passthroughID == 0)
{
ERROR("Failed to create projected pasthrough");
@@ -221,6 +356,25 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
return passthroughID;
}
#if UNITY_STANDALONE
private static void SubmitLayer()
{
foreach(var passthrough in passthrough2IsUnderLay.Keys)
{
//Get and submit layer list
XR_HTC_passthrough.Interop.GetOriginEndFrameLayerList(out List<IntPtr> layerList);//GetOriginEndFrameLayers
if (layerList.Count != 0)
{
Marshal.StructureToPtr(passthrough2Layer[passthrough], passthrough2LayerPtr[passthrough], false);
if (passthrough2IsUnderLay[passthrough])
layerList.Insert(0, passthrough2LayerPtr[passthrough]);
else
layerList.Insert(1, passthrough2LayerPtr[passthrough]);
XR_HTC_passthrough.Interop.SubmitLayers(layerList);
}
}
}
#endif
/// <summary>
/// For destroying a passthrough created previously.
@@ -245,8 +399,20 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
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);
passthrough2IsUnderLay.Remove(passthroughID);
Marshal.FreeHGlobal(passthrough2meshTransformInfoPtr[passthroughID]);
passthrough2meshTransformInfoPtr.Remove(passthroughID);
passthrough2meshTransform.Remove(passthroughID);
return true;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_DestroyPassthrough(passthroughID);
#endif
}
/// <summary>
@@ -277,7 +443,7 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("HTC_Passthrough feature instance not found.");
return false;
}
#if UNITY_ANDROID
if (autoClamp)
{
return passthroughFeature.HTCPassthrough_SetAlpha(passthroughID, Mathf.Clamp01(alpha));
@@ -292,6 +458,19 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
return passthroughFeature.HTCPassthrough_SetAlpha(passthroughID, alpha);
}
#endif
#if UNITY_STANDALONE
if (passthrough2Layer.ContainsKey(passthroughID))
{
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.color.alpha = alpha;
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
}
/// <summary>
@@ -340,10 +519,29 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
{
indexBufferUint[i] = (uint)indexBuffer[i];
}
#if UNITY_STANDALONE
if (passthrough2meshTransformInfoPtr.ContainsKey(passthroughID))
{
XrPassthroughMeshTransformInfoHTC MeshTransformInfo = passthrough2meshTransform[passthroughID];
MeshTransformInfo.vertexCount = (uint)vertexBuffer.Length;
MeshTransformInfo.vertices = vertexBufferXrVector;
MeshTransformInfo.indexCount = (uint)indexBuffer.Length;
MeshTransformInfo.indices = indexBufferUint;
passthrough2meshTransform[passthroughID] = MeshTransformInfo;
Marshal.StructureToPtr(MeshTransformInfo, passthrough2meshTransformInfoPtr[passthroughID], false);
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.next = passthrough2meshTransformInfoPtr[passthroughID];
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
//Note: Ignore Clock-Wise definition of index buffer for now as passthrough extension does not have back-face culling
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetMesh(passthroughID, (uint)vertexBuffer.Length, vertexBufferXrVector, (uint)indexBuffer.Length, indexBufferUint); ;
#endif
}
/// <summary>
@@ -402,8 +600,26 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
meshXrPose.orientation = OpenXRHelper.ToOpenXRQuaternion(trackingSpaceMeshRotation, convertFromUnityToOpenXR);
XrVector3f meshXrScale = OpenXRHelper.ToOpenXRVector(meshScale, false);
#if UNITY_STANDALONE
if (passthrough2meshTransformInfoPtr.ContainsKey(passthroughID))
{
XrPassthroughMeshTransformInfoHTC MeshTransformInfo = passthrough2meshTransform[passthroughID];
MeshTransformInfo.pose = meshXrPose;
MeshTransformInfo.scale = meshXrScale;
passthrough2meshTransform[passthroughID] = MeshTransformInfo;
Marshal.StructureToPtr(MeshTransformInfo, passthrough2meshTransformInfoPtr[passthroughID], false);
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.next = passthrough2meshTransformInfoPtr[passthroughID];
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetMeshTransform(passthroughID, passthroughFeature.GetXrSpaceFromSpaceType(spaceType), meshXrPose, meshXrScale);
#endif
}
/// <summary>
@@ -429,8 +645,20 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("HTC_Passthrough feature instance not found.");
return false;
}
#if UNITY_STANDALONE
if (passthrough2IsUnderLay.ContainsKey(passthroughID))
{
passthrough2IsUnderLay[passthroughID] = layerType == LayerType.Underlay ? true : false;
SubmitLayer();
return true;
}
else
return false;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetLayerType(passthroughID, layerType, compositionDepth);
#endif
}
/// <summary>
@@ -452,8 +680,25 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("HTC_Passthrough feature instance not found.");
return false;
}
#if UNITY_STANDALONE
if (passthrough2meshTransformInfoPtr.ContainsKey(passthroughID))
{
XrPassthroughMeshTransformInfoHTC MeshTransformInfo = passthrough2meshTransform[passthroughID];
MeshTransformInfo.baseSpace = passthroughFeature.GetXrSpaceFromSpaceType(spaceType);
passthrough2meshTransform[passthroughID] = MeshTransformInfo;
Marshal.StructureToPtr(MeshTransformInfo, passthrough2meshTransformInfoPtr[passthroughID], false);
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.next = passthrough2meshTransformInfoPtr[passthroughID];
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetMeshTransformSpace(passthroughID, passthroughFeature.GetXrSpaceFromSpaceType(spaceType));
#endif
}
/// <summary>
@@ -495,8 +740,27 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
trackingSpaceMeshPosition = trackingSpaceLayerPoseTRS.GetColumn(3); //4th Column of TRS Matrix is the position
}
#if UNITY_STANDALONE
if (passthrough2meshTransformInfoPtr.ContainsKey(passthroughID))
{
XrPassthroughMeshTransformInfoHTC MeshTransformInfo = passthrough2meshTransform[passthroughID];
XrPosef meshXrPose = MeshTransformInfo.pose;
meshXrPose.position = OpenXRHelper.ToOpenXRVector(trackingSpaceMeshPosition, convertFromUnityToOpenXR); ;
MeshTransformInfo.pose = meshXrPose;
passthrough2meshTransform[passthroughID] = MeshTransformInfo;
Marshal.StructureToPtr(MeshTransformInfo, passthrough2meshTransformInfoPtr[passthroughID], false);
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.next = passthrough2meshTransformInfoPtr[passthroughID];
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetMeshTransformPosition(passthroughID, OpenXRHelper.ToOpenXRVector(trackingSpaceMeshPosition, convertFromUnityToOpenXR));
#endif
}
/// <summary>
@@ -538,8 +802,27 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
trackingSpaceMeshRotation = Quaternion.LookRotation(trackingSpaceLayerPoseTRS.GetColumn(2), trackingSpaceLayerPoseTRS.GetColumn(1));
}
#if UNITY_STANDALONE
if (passthrough2meshTransformInfoPtr.ContainsKey(passthroughID))
{
XrPassthroughMeshTransformInfoHTC MeshTransformInfo = passthrough2meshTransform[passthroughID];
XrPosef meshXrPose = MeshTransformInfo.pose;
meshXrPose.orientation = OpenXRHelper.ToOpenXRQuaternion(trackingSpaceMeshRotation, convertFromUnityToOpenXR);
MeshTransformInfo.pose = meshXrPose;
passthrough2meshTransform[passthroughID] = MeshTransformInfo;
Marshal.StructureToPtr(MeshTransformInfo, passthrough2meshTransformInfoPtr[passthroughID], false);
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.next = passthrough2meshTransformInfoPtr[passthroughID];
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetMeshTransformOrientation(passthroughID, OpenXRHelper.ToOpenXRQuaternion(trackingSpaceMeshRotation, convertFromUnityToOpenXR));
#endif
}
/// <summary>
@@ -561,8 +844,26 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
ERROR("HTC_Passthrough feature instance not found.");
return false;
}
#if UNITY_STANDALONE
if (passthrough2meshTransformInfoPtr.ContainsKey(passthroughID))
{
XrPassthroughMeshTransformInfoHTC MeshTransformInfo = passthrough2meshTransform[passthroughID];
MeshTransformInfo.scale = OpenXRHelper.ToOpenXRVector(meshScale, false);
passthrough2meshTransform[passthroughID] = MeshTransformInfo;
Marshal.StructureToPtr(MeshTransformInfo, passthrough2meshTransformInfoPtr[passthroughID], false);
XrCompositionLayerPassthroughHTC layer = passthrough2Layer[passthroughID];
layer.next = passthrough2meshTransformInfoPtr[passthroughID];
passthrough2Layer[passthroughID] = layer;
SubmitLayer();
return true;
}
else
return false;
#endif
#if UNITY_ANDROID
return passthroughFeature.HTCPassthrough_SetMeshTransformScale(passthroughID, OpenXRHelper.ToOpenXRVector(meshScale, false));
#endif
}
/// <summary>
@@ -581,6 +882,6 @@ namespace VIVE.OpenXR.CompositionLayer.Passthrough
return passthroughFeature.PassthroughIDList;
}
#endregion
#endregion
}
}