-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [4.2.0-exp-env-depth.1] - 2023-10-06 ### Added - Environment Depth APIs to allow for real world depth to be sampled from a depth texture ### Known Issues - `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime - `Unity.XR.Oculus.Stats.AppMetrics` entries return `0` on all Oculus runtimes - For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/
- Loading branch information
Unity Technologies
committed
Oct 6, 2023
1 parent
8fcd3b2
commit bacfa9f
Showing
11 changed files
with
234 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using UnityEngine; | ||
using System; | ||
using UnityEngine.Android; | ||
|
||
namespace Unity.XR.Oculus | ||
{ | ||
public static partial class Utils | ||
{ | ||
public struct EnvironmentDepthFrameDesc | ||
{ | ||
public bool isValid; | ||
public double createTime; | ||
public double predictedDisplayTime; | ||
public int swapchainIndex; | ||
public Vector3 createPoseLocation; | ||
public Vector4 createPoseRotation; | ||
public float fovLeftAngle; | ||
public float fovRightAngle; | ||
public float fovTopAngle; | ||
public float fovDownAngle; | ||
public float nearZ; | ||
public float farZ; | ||
public float minDepth; | ||
public float maxDepth; | ||
} | ||
|
||
public struct EnvironmentDepthCreateParams | ||
{ | ||
public bool removeHands; | ||
} | ||
|
||
private static EnvironmentDepthCreateParams s_EnvironmentDepthCreateParams; | ||
|
||
static void ScenePermissionGrantedCallback(string permissionName) | ||
{ | ||
if (permissionName == "com.oculus.permission.USE_SCENE") | ||
{ | ||
NativeMethods.SetupEnvironmentDepth(s_EnvironmentDepthCreateParams); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if the user has allowed the USE_SCENE permission | ||
/// </summary> | ||
public static bool IsScenePermissionGranted() | ||
{ | ||
#if UNITY_ANDROID && !UNITY_EDITOR | ||
return Permission.HasUserAuthorizedPermission("com.oculus.permission.USE_SCENE"); | ||
#else | ||
return true; | ||
#endif | ||
} | ||
|
||
public static void SetupEnvironmentDepth(EnvironmentDepthCreateParams createParams) | ||
{ | ||
if (IsScenePermissionGranted()) | ||
{ | ||
NativeMethods.SetupEnvironmentDepth(createParams); | ||
} | ||
else | ||
{ | ||
s_EnvironmentDepthCreateParams = createParams; | ||
var permissionCallbacks = new PermissionCallbacks(); | ||
permissionCallbacks.PermissionGranted += ScenePermissionGrantedCallback; | ||
Permission.RequestUserPermission("com.oculus.permission.USE_SCENE", permissionCallbacks); | ||
} | ||
} | ||
|
||
public static void SetEnvironmentDepthRendering(bool isEnabled) | ||
{ | ||
if (IsScenePermissionGranted()) | ||
{ | ||
NativeMethods.SetEnvironmentDepthRendering(isEnabled); | ||
} | ||
else | ||
{ | ||
Debug.LogError("Failed to set environment depth rendering because permission was not given."); | ||
} | ||
} | ||
|
||
public static void ShutdownEnvironmentDepth() | ||
{ | ||
NativeMethods.ShutdownEnvironmentDepth(); | ||
} | ||
|
||
public static bool GetEnvironmentDepthTextureId(ref uint id) | ||
{ | ||
return NativeMethods.GetEnvironmentDepthTextureId(ref id); | ||
} | ||
|
||
public static EnvironmentDepthFrameDesc GetEnvironmentDepthFrameDesc(int eye) | ||
{ | ||
return NativeMethods.GetEnvironmentDepthFrameDesc(eye); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters