SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.0 KiB

4 years ago
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace UnityEngine.XR.ARSubsystems
  4. {
  5. /// <summary>
  6. /// Represents the session relative data for the <see cref="XRDepthSubsystem"/>.
  7. /// <see cref="XRPointCloud"/>s are usually created by <see cref="XRDepthSubsystem.GetChanges(Unity.Collections.Allocator)"/>.
  8. /// </summary>
  9. [StructLayout(LayoutKind.Sequential)]
  10. public unsafe struct XRPointCloud : ITrackable, IEquatable<XRPointCloud>
  11. {
  12. /// <summary>
  13. /// Gets a default-initialized <see cref="XRPointCloud"/>. This may be
  14. /// different from the zero-initialized version, e.g., the <see cref="pose"/>
  15. /// is <c>Pose.identity</c> instead of zero-initialized.
  16. /// </summary>
  17. public static XRPointCloud defaultValue => s_Default;
  18. static readonly XRPointCloud s_Default = new XRPointCloud
  19. {
  20. m_TrackableId = TrackableId.invalidId,
  21. m_Pose = Pose.identity,
  22. };
  23. /// <summary>
  24. /// Constructs a new <see cref="XRPointCloud"/>. This is a container
  25. /// for the session-relative data. These are typically created by
  26. /// <see cref="XRDepthSubsystem.GetChanges(Unity.Collections.Allocator)"/>.
  27. /// </summary>
  28. /// <param name="trackableId">The <see cref="TrackableId"/> associated with the point cloud.</param>
  29. /// <param name="pose">The <c>Pose</c> associated with the point cloud.</param>
  30. /// <param name="trackingState">The <see cref="TrackingState"/> associated with the point cloud.</param>
  31. /// <param name="nativePtr">The native pointer associated with the point cloud.</param>
  32. public XRPointCloud(
  33. TrackableId trackableId,
  34. Pose pose,
  35. TrackingState trackingState,
  36. IntPtr nativePtr)
  37. {
  38. m_TrackableId = trackableId;
  39. m_Pose = pose;
  40. m_TrackingState = trackingState;
  41. m_NativePtr = nativePtr;
  42. }
  43. /// <summary>
  44. /// Get the <see cref="TrackableId"/> associated with this point cloud.
  45. /// </summary>
  46. public TrackableId trackableId => m_TrackableId;
  47. /// <summary>
  48. /// Get the <c>Pose</c> associated with this point cloud.
  49. /// </summary>
  50. /// <remarks>
  51. /// Point cloud points are relative to this pose.
  52. /// </remarks>
  53. public Pose pose => m_Pose;
  54. /// <summary>
  55. /// Get the <see cref="TrackingState"/> associated with this point cloud.
  56. /// </summary>
  57. public TrackingState trackingState => m_TrackingState;
  58. /// <summary>
  59. /// Get the native pointer associated with this point cloud.
  60. /// </summary>
  61. /// <remarks>
  62. /// The data this pointer points to is implementation defined.
  63. /// </remarks>
  64. public IntPtr nativePtr => m_NativePtr;
  65. public override int GetHashCode()
  66. {
  67. unchecked
  68. {
  69. var hash = m_TrackableId.GetHashCode();
  70. hash = hash * 486187739 + m_Pose.GetHashCode();
  71. hash = hash * 486187739 + ((int)m_TrackingState).GetHashCode();
  72. hash = hash * 486187739 + m_NativePtr.GetHashCode();
  73. return hash;
  74. }
  75. }
  76. public bool Equals(XRPointCloud other)
  77. {
  78. return
  79. (m_TrackableId == other.m_TrackableId) &&
  80. (m_Pose.Equals(other.pose)) &&
  81. (m_TrackingState == other.m_TrackingState) &&
  82. (m_NativePtr == other.m_NativePtr);
  83. }
  84. public override bool Equals(object obj)
  85. {
  86. if (ReferenceEquals(null, obj))
  87. return false;
  88. return Equals((XRPointCloud)obj);
  89. }
  90. public static bool operator==(XRPointCloud lhs, XRPointCloud rhs) => lhs.Equals(rhs);
  91. public static bool operator!=(XRPointCloud lhs, XRPointCloud rhs) => !lhs.Equals(rhs);
  92. TrackableId m_TrackableId;
  93. Pose m_Pose;
  94. TrackingState m_TrackingState;
  95. IntPtr m_NativePtr;
  96. }
  97. }