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.

142 lines
5.7 KiB

4 years ago
  1. using System;
  2. namespace UnityEngine.XR.ARSubsystems
  3. {
  4. /// <summary>
  5. /// Describes the capabilities of an <see cref="XRPlaneSubsystem"/>.
  6. /// </summary>
  7. public class XRPlaneSubsystemDescriptor : SubsystemDescriptor<XRPlaneSubsystem>
  8. {
  9. /// <summary>
  10. /// <c>true</c> if the subsystem supports horizontal plane detection.
  11. /// </summary>
  12. public bool supportsHorizontalPlaneDetection { get; private set; }
  13. /// <summary>
  14. /// <c>true</c> if the subsystem supports vertical plane detection.
  15. /// </summary>
  16. public bool supportsVerticalPlaneDetection { get; private set; }
  17. /// <summary>
  18. /// <c>true</c> if the subsystem supports arbitrarily angled plane detection.
  19. /// </summary>
  20. public bool supportsArbitraryPlaneDetection { get; private set; }
  21. /// <summary>
  22. /// <c>true</c> if the subsystem supports boundary vertices for its planes.
  23. /// </summary>
  24. public bool supportsBoundaryVertices { get; private set; }
  25. /// <summary>
  26. /// <c>true</c> if the current subsystem supports plane classification. Otherwise, <c>false</c>.
  27. /// </summary>
  28. public bool supportsClassification { get; private set; }
  29. /// <summary>
  30. /// Constructor info used to register a descriptor.
  31. /// </summary>
  32. public struct Cinfo : IEquatable<Cinfo>
  33. {
  34. /// <summary>
  35. /// The string identifier for a specific implementation.
  36. /// </summary>
  37. public string id { get; set; }
  38. /// <summary>
  39. /// The concrete <c>Type</c> which will be instantiated if <c>Create</c> is called on this subsystem descriptor.
  40. /// </summary>
  41. public Type subsystemImplementationType { get; set; }
  42. /// <summary>
  43. /// <c>true</c> if the subsystem supports horizontal plane detection.
  44. /// </summary>
  45. public bool supportsHorizontalPlaneDetection { get; set; }
  46. /// <summary>
  47. /// <c>true</c> if the subsystem supports vertical plane detection.
  48. /// </summary>
  49. public bool supportsVerticalPlaneDetection { get; set; }
  50. /// <summary>
  51. /// <c>true</c> if the subsystem supports arbitrarily angled plane detection.
  52. /// </summary>
  53. public bool supportsArbitraryPlaneDetection { get; set; }
  54. /// <summary>
  55. /// <c>true</c> if the subsystem supports boundary vertices for its planes.
  56. /// </summary>
  57. public bool supportsBoundaryVertices { get; set; }
  58. /// <summary>
  59. /// <c>true</c> if the subsystem supports boundary vertices for its planes.
  60. /// </summary>
  61. public bool supportsClassification { get; set; }
  62. public bool Equals(Cinfo other)
  63. {
  64. return
  65. id.Equals(other.id) &&
  66. (subsystemImplementationType == other.subsystemImplementationType) &&
  67. (supportsHorizontalPlaneDetection == other.supportsHorizontalPlaneDetection) &&
  68. (supportsVerticalPlaneDetection == other.supportsVerticalPlaneDetection) &&
  69. (supportsArbitraryPlaneDetection == other.supportsArbitraryPlaneDetection) &&
  70. (supportsClassification == other.supportsClassification) &&
  71. (supportsBoundaryVertices == other.supportsBoundaryVertices);
  72. }
  73. public override bool Equals(object obj)
  74. {
  75. if (!(obj is Cinfo))
  76. return false;
  77. return Equals((Cinfo)obj);
  78. }
  79. public override int GetHashCode()
  80. {
  81. unchecked
  82. {
  83. var hashCode = id.GetHashCode();
  84. hashCode = (hashCode * 486187739) + subsystemImplementationType.GetHashCode();
  85. hashCode = (hashCode * 486187739) + supportsHorizontalPlaneDetection.GetHashCode();
  86. hashCode = (hashCode * 486187739) + supportsVerticalPlaneDetection.GetHashCode();
  87. hashCode = (hashCode * 486187739) + supportsArbitraryPlaneDetection.GetHashCode();
  88. hashCode = (hashCode * 486187739) + supportsBoundaryVertices.GetHashCode();
  89. hashCode = (hashCode * 486187739) + supportsClassification.GetHashCode();
  90. return hashCode;
  91. }
  92. }
  93. public static bool operator ==(Cinfo lhs, Cinfo rhs)
  94. {
  95. return lhs.Equals(rhs);
  96. }
  97. public static bool operator !=(Cinfo lhs, Cinfo rhs)
  98. {
  99. return !lhs.Equals(rhs);
  100. }
  101. }
  102. /// <summary>
  103. /// Creates a new subsystem descriptor and registers it with the <c>SubsystemManager</c>.
  104. /// </summary>
  105. /// <param name="cinfo">Construction info for the descriptor.</param>
  106. public static void Create(Cinfo cinfo)
  107. {
  108. var descriptor = new XRPlaneSubsystemDescriptor(cinfo);
  109. SubsystemRegistration.CreateDescriptor(descriptor);
  110. }
  111. XRPlaneSubsystemDescriptor(Cinfo cinfo)
  112. {
  113. id = cinfo.id;
  114. subsystemImplementationType = cinfo.subsystemImplementationType;
  115. supportsHorizontalPlaneDetection = cinfo.supportsHorizontalPlaneDetection;
  116. supportsVerticalPlaneDetection = cinfo.supportsVerticalPlaneDetection;
  117. supportsArbitraryPlaneDetection = cinfo.supportsArbitraryPlaneDetection;
  118. supportsBoundaryVertices = cinfo.supportsBoundaryVertices;
  119. supportsClassification = cinfo.supportsClassification;
  120. }
  121. }
  122. }