using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { /// /// A struct that describes face data stored in the . /// [StructLayout(LayoutKind.Sequential)] public struct XRFace : ITrackable, IEquatable { // Fields to marshall/serialize from native code TrackableId m_TrackableId; Pose m_Pose; TrackingState m_TrackingState; IntPtr m_NativePtr; Pose m_LeftEyePose; Pose m_RightEyePose; Vector3 m_FixationPoint; /// /// Get a with reasonable default values. /// public static XRFace defaultValue => s_Default; static readonly XRFace s_Default = new XRFace { m_TrackableId = TrackableId.invalidId, m_Pose = Pose.identity, m_LeftEyePose = Pose.identity, m_RightEyePose = Pose.identity, }; /// /// The unique of the face as a trackable within the . /// /// /// With this, you can extract more data about this particular face from the . /// public TrackableId trackableId => m_TrackableId; /// /// The of the face describes its position and rotation in session space. /// public Pose pose => m_Pose; /// /// The tracking state associated with this . /// public TrackingState trackingState => m_TrackingState; /// /// A native pointer associated with this . /// /// /// The data pointed to by this pointer is implementation-defined. /// public IntPtr nativePtr => m_NativePtr; /// /// The pose of the left eye in relation to the face. /// public Pose leftEyePose => m_LeftEyePose; /// /// The pose of the right eye in relation to the face. /// public Pose rightEyePose => m_RightEyePose; /// /// The position where the eyes are fixated in relation to the face. /// public Vector3 fixationPoint => m_FixationPoint; /// /// 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 XRFace && Equals((XRFace)obj); /// /// 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 hashCode = trackableId.GetHashCode(); hashCode = (hashCode * 486187739) + pose.GetHashCode(); hashCode = (hashCode * 486187739) + ((int)trackingState).GetHashCode(); hashCode = (hashCode * 486187739) + nativePtr.GetHashCode(); hashCode = (hashCode * 486187739) + leftEyePose.GetHashCode(); hashCode = (hashCode * 486187739) + rightEyePose.GetHashCode(); hashCode = (hashCode * 486187739) + fixationPoint.GetHashCode(); return hashCode; } } /// /// 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==(XRFace lhs, XRFace 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!=(XRFace lhs, XRFace rhs) => !lhs.Equals(rhs); /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. public bool Equals(XRFace other) { return trackableId.Equals(other.trackableId) && pose.Equals(other.pose) && (trackingState == other.trackingState) && (nativePtr == other.nativePtr) && (leftEyePose.Equals(other.leftEyePose)) && (rightEyePose.Equals(other.rightEyePose)) && (fixationPoint.Equals(other.fixationPoint)); } }; }