using System; namespace UnityEngine.XR.ARSubsystems { /// /// Containter for the human body joint data. /// public struct XRHumanBodyJoint : IEquatable { /// /// The index for the joint in the skeleton hierachy. /// /// /// The index for the joint in the skeleton hierachy. /// /// /// All indices will be non-negative. /// public int index => m_Index; int m_Index; /// /// The index for the parent joint in the skeleton hierachy. /// /// /// The index for the parent joint in the skeleton hierachy. /// /// /// A negative parent index means the joint has no parent in the hierachy. /// public int parentIndex => m_ParentIndex; int m_ParentIndex; /// /// The scale relative to the parent joint. /// /// /// The scale relative to the parent joint. /// public Vector3 localScale => m_LocalScale; Vector3 m_LocalScale; /// /// The pose relative to the parent joint. /// /// /// The pose relative to the parent joint. /// public Pose localPose => m_LocalPose; Pose m_LocalPose; /// /// The scale relative to the human body origin. /// /// /// The scale relative to the human body origin. /// public Vector3 anchorScale => m_AnchorScale; Vector3 m_AnchorScale; /// /// The pose relative to the human body origin. /// /// /// The pose relative to the human body origin. /// public Pose anchorPose => m_AnchorPose; Pose m_AnchorPose; /// /// Whether the joint is tracked. /// /// /// true if the joint is tracked. Otherwise, false. /// public bool tracked => (m_Tracked != 0); int m_Tracked; /// /// Construct the human body joint. /// /// The index for the joint in the skeleton. /// The index for the parent joint in the skeleton. /// The scale relative to the parent joint. /// The pose relative to the parent joint. /// The scale relative to the human body origin. /// The pose relative to the human body origin. /// Whether the joint is tracked. public XRHumanBodyJoint(int index, int parentIndex, Vector3 localScale, Pose localPose, Vector3 anchorScale, Pose anchorPose, bool tracked) { m_Index = index; m_ParentIndex = parentIndex; m_LocalScale = localScale; m_LocalPose = localPose; m_AnchorScale = anchorScale; m_AnchorPose = anchorPose; m_Tracked = tracked ? 1 : 0; } /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. public bool Equals(XRHumanBodyJoint other) { return (m_Index.Equals(other.m_Index) && m_ParentIndex.Equals(other.m_ParentIndex) && m_LocalScale.Equals(other.m_LocalScale) && m_LocalPose.Equals(other.m_LocalPose) && m_AnchorScale.Equals(other.m_AnchorScale) && m_AnchorPose.Equals(other.m_AnchorPose) && m_Tracked.Equals(other.m_Tracked)); } /// /// Tests for equality. /// /// The `object` to compare against. /// `True` if is of type and /// also returns `true`; otherwise `false`. public override bool Equals(System.Object obj) { return ((obj is XRHumanBodyJoint) && Equals((XRHumanBodyJoint)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 ==(XRHumanBodyJoint lhs, XRHumanBodyJoint 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 !=(XRHumanBodyJoint lhs, XRHumanBodyJoint rhs) => !lhs.Equals(rhs); /// /// 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() { int hashCode = 486187739; unchecked { hashCode = (hashCode * 486187739) + m_Index.GetHashCode(); hashCode = (hashCode * 486187739) + m_ParentIndex.GetHashCode(); hashCode = (hashCode * 486187739) + m_LocalScale.GetHashCode(); hashCode = (hashCode * 486187739) + m_LocalPose.GetHashCode(); hashCode = (hashCode * 486187739) + m_AnchorScale.GetHashCode(); hashCode = (hashCode * 486187739) + m_AnchorPose.GetHashCode(); hashCode = (hashCode * 486187739) + m_Tracked.GetHashCode(); } return hashCode; } /// /// Generates a string representation of this . Floating point /// values using the ["F5"](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings) /// format specifier. /// /// A string representation of this . public override string ToString() => ToString("F5"); /// /// Generates a string representation of this . /// /// A format specifier used for the floating point fields. /// A string representation of this . public string ToString(string format) { return String.Format("joint [{0}] -> [{1}] localScale:{2} localPose:{3} anchorScale:{4} anchorPose:{5} tracked:{6}", m_Index, m_ParentIndex, m_LocalScale.ToString(format), m_LocalPose.ToString(format), m_AnchorScale.ToString(format), m_AnchorPose.ToString(format), tracked.ToString()); } } }