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 (for example, 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; /// /// Generates a hash suitable for use with containers like `HashSet` and `Dictionary`. /// /// A hash code generated from this object's fields. 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; } } /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. 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); } /// /// Tests for equality. /// /// The `object` to compare against. /// `True` if is of type and /// also returns `true`; otherwise `false`. public override bool Equals(object obj) => (obj is XRPointCloud) && Equals((XRPointCloud)obj); /// /// Tests for equality. Same as . /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// `True` if is equal to , otherwise `false`. public static bool operator==(XRPointCloud lhs, XRPointCloud rhs) => lhs.Equals(rhs); /// /// Tests for inequality. Same as `!`. /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// `True` if is not equal to , otherwise `false`. public static bool operator!=(XRPointCloud lhs, XRPointCloud rhs) => !lhs.Equals(rhs); TrackableId m_TrackableId; Pose m_Pose; TrackingState m_TrackingState; IntPtr m_NativePtr; } }