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.

96 lines
3.5 KiB

4 years ago
  1. using System;
  2. using Unity.Collections;
  3. namespace UnityEngine.XR.ARSubsystems
  4. {
  5. /// <summary>
  6. /// Represents the data (arrays of positions, confidence values, and identifiers) associated with a point cloud.
  7. /// </summary>
  8. public struct XRPointCloudData : IEquatable<XRPointCloudData>, IDisposable
  9. {
  10. /// <summary>
  11. /// Positions for each point in the point cloud. This array is parallel
  12. /// to <see cref="confidenceValues"/> and <see cref="identifiers"/>.
  13. /// Use <c>positions.IsCreated</c> to check for existence.
  14. /// </summary>
  15. public NativeArray<Vector3> positions
  16. {
  17. get => m_Positions;
  18. set => m_Positions = value;
  19. }
  20. NativeArray<Vector3> m_Positions;
  21. /// <summary>
  22. /// Confidence values for each point in the point cloud. This array is parallel
  23. /// to <see cref="positions"/> and <see cref="identifiers"/>.
  24. /// Use <c>confidenceValues.IsCreated</c> to check for existence.
  25. /// </summary>
  26. public NativeArray<float> confidenceValues
  27. {
  28. get => m_ConfidenceValues;
  29. set => m_ConfidenceValues = value;
  30. }
  31. NativeArray<float> m_ConfidenceValues;
  32. /// <summary>
  33. /// Identifiers for each point in the point cloud. This array is parallel
  34. /// to <see cref="positions"/> and <see cref="confidenceValues"/>.
  35. /// Use <c>identifiers.IsCreated</c> to check for existence.
  36. /// </summary>
  37. /// <remarks>
  38. /// Identifiers are unique to a particular session, which means you can use
  39. /// the identifier to match a particular point in the point cloud with a
  40. /// previously detected point.
  41. /// </remarks>
  42. public NativeArray<ulong> identifiers
  43. {
  44. get => m_Identifiers;
  45. set => m_Identifiers = value;
  46. }
  47. NativeArray<ulong> m_Identifiers;
  48. /// <summary>
  49. /// Disposes of the <c>NativeArray</c>s, checking for existence first.
  50. /// </summary>
  51. public void Dispose()
  52. {
  53. if (m_Positions.IsCreated)
  54. m_Positions.Dispose();
  55. if (m_ConfidenceValues.IsCreated)
  56. m_ConfidenceValues.Dispose();
  57. if (m_Identifiers.IsCreated)
  58. m_Identifiers.Dispose();
  59. }
  60. public override int GetHashCode()
  61. {
  62. unchecked
  63. {
  64. var hash = m_Positions.GetHashCode();
  65. hash = hash * 486187739 + m_ConfidenceValues.GetHashCode();
  66. hash = hash * 486187739 + m_Identifiers.GetHashCode();
  67. return hash;
  68. }
  69. }
  70. public override bool Equals(object obj) => obj is XRPointCloudData && Equals((XRPointCloudData)obj);
  71. public override string ToString()
  72. {
  73. return string.Format("XRPointCloudData: {0} positions {1} confidence values {2} identifiers",
  74. m_Positions.Length, m_ConfidenceValues.Length, m_Identifiers.Length);
  75. }
  76. public bool Equals(XRPointCloudData other)
  77. {
  78. return
  79. m_Positions.Equals(other.m_Positions) &&
  80. m_ConfidenceValues.Equals(other.m_ConfidenceValues) &&
  81. m_Identifiers.Equals(other.m_Identifiers);
  82. }
  83. public static bool operator ==(XRPointCloudData lhs, XRPointCloudData rhs) => lhs.Equals(rhs);
  84. public static bool operator !=(XRPointCloudData lhs, XRPointCloudData rhs) => !lhs.Equals(rhs);
  85. }
  86. }