using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { /// /// Represents the session relative data for the . /// s are usually created by . /// [StructLayout(LayoutKind.Sequential)] public unsafe struct XRPointCloud : ITrackable, IEquatable { /// /// Gets a default-initialized . This may be /// different from the zero-initialized version, e.g., the /// is Pose.identity instead of zero-initialized. /// public static XRPointCloud defaultValue => s_Default; static readonly XRPointCloud s_Default = new XRPointCloud { m_TrackableId = TrackableId.invalidId, m_Pose = Pose.identity, }; /// /// Constructs a new . This is a container /// for the session-relative data. These are typically created by /// . /// /// The associated with the point cloud. /// The Pose associated with the point cloud. /// The associated with the point cloud. /// The native pointer associated with the point cloud. public XRPointCloud( TrackableId trackableId, Pose pose, TrackingState trackingState, IntPtr nativePtr) { m_TrackableId = trackableId; m_Pose = pose; m_TrackingState = trackingState; m_NativePtr = nativePtr; } /// /// Get the associated with this point cloud. /// public TrackableId trackableId => m_TrackableId; /// /// Get the Pose associated with this point cloud. /// /// /// Point cloud points are relative to this pose. /// public Pose pose => m_Pose; /// /// Get the associated with this point cloud. /// public TrackingState trackingState => m_TrackingState; /// /// Get the native pointer associated with this point cloud. /// /// /// The data this pointer points to is implementation defined. /// public IntPtr nativePtr => m_NativePtr; public override int GetHashCode() { unchecked { var hash = m_TrackableId.GetHashCode(); hash = hash * 486187739 + m_Pose.GetHashCode(); hash = hash * 486187739 + ((int)m_TrackingState).GetHashCode(); hash = hash * 486187739 + m_NativePtr.GetHashCode(); return hash; } } public bool Equals(XRPointCloud other) { return (m_TrackableId == other.m_TrackableId) && (m_Pose.Equals(other.pose)) && (m_TrackingState == other.m_TrackingState) && (m_NativePtr == other.m_NativePtr); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; return Equals((XRPointCloud)obj); } public static bool operator==(XRPointCloud lhs, XRPointCloud rhs) => lhs.Equals(rhs); public static bool operator!=(XRPointCloud lhs, XRPointCloud rhs) => !lhs.Equals(rhs); TrackableId m_TrackableId; Pose m_Pose; TrackingState m_TrackingState; IntPtr m_NativePtr; } }