1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-12-19 04:15:53 +01:00
MaiDXR/Assets/Oculus/VR/Scripts/OVRSpace.cs

86 lines
3.4 KiB
C#
Raw Normal View History

2022-08-20 21:35:57 +02:00
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
/// <summary>
/// Represents a "space" in the Oculus Runtime.
/// </summary>
public readonly struct OVRSpace : IEquatable<OVRSpace>
{
/// <summary>
/// A runtime handle associated with this <see cref="OVRSpace"/>. This could change between subsequent sessions
/// or apps.
/// </summary>
public ulong Handle { get; }
/// <summary>
/// Retrieve the universally unique identifier (UUID) associated with this <see cref="OVRSpace"/>.
/// </summary>
/// <remarks>
/// Every space that can be persisted will have a UUID associated with it. UUIDs are consistent across different
/// sessions and apps.
///
/// The UUID of a space does not change over time, but not all spaces are guaranteed to have a UUID.
/// </remarks>
/// <param name="uuid">If successful, the uuid associated with this <see cref="OVRSpace"/>, otherwise, `Guid.Empty`.
/// </param>
/// <returns>Returns `true` if the uuid could be retrieved, otherwise `false`.</returns>
public bool TryGetUuid(out Guid uuid) => OVRPlugin.GetSpaceUuid(Handle, out uuid);
/// <summary>
/// Indicates whether this <see cref="OVRSpace"/> represents a valid space (vs a default constructed
/// <see cref="OVRSpace"/>).
/// </summary>
public bool Valid => Handle != 0;
/// <summary>
/// Constructs an <see cref="OVRSpace"/> object from an existing runtime handle and UUID.
/// </summary>
/// <remarks>
/// This constructor does not create a new space. An <see cref="OVRSpace"/> is a wrapper for low-level functionality
/// in the Oculus Runtime. To create a new spatial anchor, use <see cref="OVRSpatialAnchor"/>.
/// </remarks>
/// <param name="handle">The runtime handle associated with the space.</param>
public OVRSpace(ulong handle) => Handle = handle;
/// <summary>
/// Generates a string representation of this <see cref="OVRSpace"/> of the form
/// "0xYYYYYYYY"
/// where "Y" are the hexadecimal digits of the <see cref="Handle"/>.
/// </summary>
/// <returns>Returns a string representation of this <see cref="OVRSpace"/>.</returns>
public override string ToString() => $"0x{Handle:x8}";
public bool Equals(OVRSpace other) => Handle == other.Handle;
public override bool Equals(object obj) => obj is OVRSpace other && Equals(other);
public override int GetHashCode() => Handle.GetHashCode();
public static bool operator== (OVRSpace lhs, OVRSpace rhs) => lhs.Handle == rhs.Handle;
public static bool operator!= (OVRSpace lhs, OVRSpace rhs) => lhs.Handle != rhs.Handle;
public static implicit operator OVRSpace(ulong handle) => new OVRSpace(handle);
public static implicit operator ulong(OVRSpace space) => space.Handle;
}