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.

180 lines
6.1 KiB

4 years ago
  1. using System;
  2. namespace UnityEngine.XR.ARSubsystems
  3. {
  4. /// <summary>
  5. /// The descriptor of the <see cref="XRDepthSubsystem"/> that shows which depth detectiomn features are available on that XRSubsystem.
  6. /// </summary>
  7. /// <remarks>
  8. /// You use the <c>Create<c> factory method along with <see cref="DepthSubsystemParams"/> struct to construct and
  9. /// register one of these from each depth data provider.
  10. /// </remarks>
  11. /// <seealso cref="XRDepthSubsystem"/>
  12. public class XRDepthSubsystemDescriptor : SubsystemDescriptor<XRDepthSubsystem>
  13. {
  14. /// <summary>
  15. /// Describes the capabilities of an <see cref="XRDepthSubsystem"/>.
  16. /// </summary>
  17. [Flags]
  18. public enum Capabilities
  19. {
  20. None = 0,
  21. FeaturePoints = 1 << 0,
  22. Confidence = 1 << 1,
  23. UniqueIds = 1 << 2
  24. }
  25. /// <summary>
  26. /// This struct is an initializer for the creation of a <see cref="XRDepthSubsystemDescriptor"/>.
  27. /// </summary>
  28. /// <remarks>
  29. /// Depth data provider should create during <c>InitializeOnLoad<c> a descriptor using
  30. /// the params here to specify which of the XRDepthSubsystem features it supports.
  31. /// </remarks>
  32. public struct Cinfo : IEquatable<Cinfo>
  33. {
  34. /// <summary>
  35. /// The string identifier for a specific implementation.
  36. /// </summary>
  37. public string id;
  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 implementationType;
  42. /// <summary>
  43. /// Whether the subsystem supports feature points
  44. /// </summary>
  45. public bool supportsFeaturePoints
  46. {
  47. get { return (capabilities & Capabilities.FeaturePoints) != 0; }
  48. set
  49. {
  50. if (value)
  51. {
  52. capabilities |= Capabilities.FeaturePoints;
  53. }
  54. else
  55. {
  56. capabilities &= ~Capabilities.FeaturePoints;
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// Whether the subsystem supports per feature point confidence values.
  62. /// </summary>
  63. public bool supportsConfidence
  64. {
  65. get { return (capabilities & Capabilities.Confidence) != 0; }
  66. set
  67. {
  68. if (value)
  69. {
  70. capabilities |= Capabilities.Confidence;
  71. }
  72. else
  73. {
  74. capabilities &= ~Capabilities.Confidence;
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// Whether the subsystem supports per-feature point identifiers.
  80. /// </summary>
  81. public bool supportsUniqueIds
  82. {
  83. get { return (capabilities & Capabilities.UniqueIds) != 0; }
  84. set
  85. {
  86. if (value)
  87. {
  88. capabilities |= Capabilities.UniqueIds;
  89. }
  90. else
  91. {
  92. capabilities &= ~Capabilities.UniqueIds;
  93. }
  94. }
  95. }
  96. /// <summary>
  97. /// The capabilities of the subsystem implementation.
  98. /// </summary>
  99. Capabilities capabilities { get; set; }
  100. //IEquatable boilerplate
  101. public bool Equals(Cinfo other)
  102. {
  103. return capabilities == other.capabilities && id.Equals(other.id) && implementationType == other.implementationType;
  104. }
  105. public override bool Equals(object obj)
  106. {
  107. if (!(obj is Cinfo))
  108. {
  109. return false;
  110. }
  111. return Equals((Cinfo)obj);
  112. }
  113. public override int GetHashCode()
  114. {
  115. unchecked
  116. {
  117. var hashCode = id.GetHashCode();
  118. hashCode = (hashCode * 486187739) + implementationType.GetHashCode();
  119. hashCode = (hashCode * 486187739) + ((int)capabilities).GetHashCode();
  120. return hashCode;
  121. }
  122. }
  123. public static bool operator ==(Cinfo lhs, Cinfo rhs)
  124. {
  125. return lhs.Equals(rhs);
  126. }
  127. public static bool operator !=(Cinfo lhs, Cinfo rhs)
  128. {
  129. return !lhs.Equals(rhs);
  130. }
  131. }
  132. XRDepthSubsystemDescriptor(Cinfo descriptorParams)
  133. {
  134. id = descriptorParams.id;
  135. subsystemImplementationType = descriptorParams.implementationType;
  136. supportsFeaturePoints = descriptorParams.supportsFeaturePoints;
  137. supportsUniqueIds = descriptorParams.supportsUniqueIds;
  138. supportsConfidence = descriptorParams.supportsConfidence;
  139. }
  140. /// <summary>
  141. /// Whether the implementation supports feature points.
  142. /// </summary>
  143. public bool supportsFeaturePoints { get; private set; }
  144. /// <summary>
  145. /// Whether the implementation supports per feature point identifiers.
  146. /// </summary>
  147. public bool supportsUniqueIds { get; private set; }
  148. /// <summary>
  149. /// Whether the implementation supports per feature point confidence values.
  150. /// </summary>
  151. public bool supportsConfidence { get; private set; }
  152. /// <summary>
  153. /// Registers a subsystem implementation with the <c>SubsystemManager</c>.
  154. /// </summary>
  155. /// <param name="descriptorParams"></param>
  156. public static void RegisterDescriptor(Cinfo descriptorParams)
  157. {
  158. var descriptor = new XRDepthSubsystemDescriptor(descriptorParams);
  159. SubsystemRegistration.CreateDescriptor(descriptor);
  160. }
  161. }
  162. }