using System;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Container for a human body pose 2D joint as part of a AR detected screen space skeleton.
///
public struct XRHumanBodyPose2DJoint : 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 that the joint has no parent in the hierachy.
///
public int parentIndex => m_ParentIndex;
int m_ParentIndex;
///
/// The position of the joint in 2D screenspace.
///
///
/// The position of the joint in 2D screenspace.
///
public Vector2 position => m_Position;
Vector2 m_Position;
///
/// Whether the joint is tracked.
///
///
/// true if the joint is tracked. Otherwise, false.
///
public bool tracked => (m_Tracked != 0);
int m_Tracked;
///
/// Constructs a XRHumanBodyPose2DJoint with the given parameters.
///
/// The index of the joint in the skeleton hierachy.
/// The index of the parent joint in the skeleton hierarchy.
/// The position of the joint in 2D screenspace.
/// Whether the joint is tracked.
public XRHumanBodyPose2DJoint(int index, int parentIndex, Vector2 position, bool tracked)
{
m_Index = index;
m_ParentIndex = parentIndex;
m_Position = position;
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(XRHumanBodyPose2DJoint other)
{
return (m_Index.Equals(other.m_Index) && m_ParentIndex.Equals(other.m_ParentIndex)
&& m_Position.Equals(other.m_Position) && 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 XRHumanBodyPose2DJoint) && Equals((XRHumanBodyPose2DJoint)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 ==(XRHumanBodyPose2DJoint lhs, XRHumanBodyPose2DJoint 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 !=(XRHumanBodyPose2DJoint lhs, XRHumanBodyPose2DJoint 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_Position.GetHashCode();
hashCode = (hashCode * 486187739) + m_Tracked.GetHashCode();
}
return hashCode;
}
///
/// Generates a string representation of this . Floating point
/// values use 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()
{
return 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}] {2}", m_Index, m_ParentIndex,
tracked ? m_Position.ToString(format) : "");
}
}
}