Sin descripción
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. //
  5. // Changes to this file may cause incorrect behavior and will be lost if
  6. // the code is regenerated. To update the generation of this file, modify and re-run Unity.Mathematics.CodeGen.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9. using System;
  10. using System.Runtime.CompilerServices;
  11. using System.Runtime.InteropServices;
  12. using System.Diagnostics;
  13. using Unity.IL2CPP.CompilerServices;
  14. #pragma warning disable 0660, 0661
  15. namespace Unity.Mathematics
  16. {
  17. /// <summary>A 2 component vector of bools.</summary>
  18. [DebuggerTypeProxy(typeof(bool2.DebuggerProxy))]
  19. [System.Serializable]
  20. [Il2CppEagerStaticClassConstruction]
  21. public partial struct bool2 : System.IEquatable<bool2>
  22. {
  23. /// <summary>x component of the vector.</summary>
  24. [MarshalAs(UnmanagedType.U1)]
  25. public bool x;
  26. /// <summary>y component of the vector.</summary>
  27. [MarshalAs(UnmanagedType.U1)]
  28. public bool y;
  29. /// <summary>Constructs a bool2 vector from two bool values.</summary>
  30. /// <param name="x">The constructed vector's x component will be set to this value.</param>
  31. /// <param name="y">The constructed vector's y component will be set to this value.</param>
  32. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  33. public bool2(bool x, bool y)
  34. {
  35. this.x = x;
  36. this.y = y;
  37. }
  38. /// <summary>Constructs a bool2 vector from a bool2 vector.</summary>
  39. /// <param name="xy">The constructed vector's xy components will be set to this value.</param>
  40. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  41. public bool2(bool2 xy)
  42. {
  43. this.x = xy.x;
  44. this.y = xy.y;
  45. }
  46. /// <summary>Constructs a bool2 vector from a single bool value by assigning it to every component.</summary>
  47. /// <param name="v">bool to convert to bool2</param>
  48. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  49. public bool2(bool v)
  50. {
  51. this.x = v;
  52. this.y = v;
  53. }
  54. /// <summary>Implicitly converts a single bool value to a bool2 vector by assigning it to every component.</summary>
  55. /// <param name="v">bool to convert to bool2</param>
  56. /// <returns>Converted value.</returns>
  57. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  58. public static implicit operator bool2(bool v) { return new bool2(v); }
  59. /// <summary>Returns the result of a componentwise equality operation on two bool2 vectors.</summary>
  60. /// <param name="lhs">Left hand side bool2 to use to compute componentwise equality.</param>
  61. /// <param name="rhs">Right hand side bool2 to use to compute componentwise equality.</param>
  62. /// <returns>bool2 result of the componentwise equality.</returns>
  63. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  64. public static bool2 operator == (bool2 lhs, bool2 rhs) { return new bool2 (lhs.x == rhs.x, lhs.y == rhs.y); }
  65. /// <summary>Returns the result of a componentwise equality operation on a bool2 vector and a bool value.</summary>
  66. /// <param name="lhs">Left hand side bool2 to use to compute componentwise equality.</param>
  67. /// <param name="rhs">Right hand side bool to use to compute componentwise equality.</param>
  68. /// <returns>bool2 result of the componentwise equality.</returns>
  69. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  70. public static bool2 operator == (bool2 lhs, bool rhs) { return new bool2 (lhs.x == rhs, lhs.y == rhs); }
  71. /// <summary>Returns the result of a componentwise equality operation on a bool value and a bool2 vector.</summary>
  72. /// <param name="lhs">Left hand side bool to use to compute componentwise equality.</param>
  73. /// <param name="rhs">Right hand side bool2 to use to compute componentwise equality.</param>
  74. /// <returns>bool2 result of the componentwise equality.</returns>
  75. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  76. public static bool2 operator == (bool lhs, bool2 rhs) { return new bool2 (lhs == rhs.x, lhs == rhs.y); }
  77. /// <summary>Returns the result of a componentwise not equal operation on two bool2 vectors.</summary>
  78. /// <param name="lhs">Left hand side bool2 to use to compute componentwise not equal.</param>
  79. /// <param name="rhs">Right hand side bool2 to use to compute componentwise not equal.</param>
  80. /// <returns>bool2 result of the componentwise not equal.</returns>
  81. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  82. public static bool2 operator != (bool2 lhs, bool2 rhs) { return new bool2 (lhs.x != rhs.x, lhs.y != rhs.y); }
  83. /// <summary>Returns the result of a componentwise not equal operation on a bool2 vector and a bool value.</summary>
  84. /// <param name="lhs">Left hand side bool2 to use to compute componentwise not equal.</param>
  85. /// <param name="rhs">Right hand side bool to use to compute componentwise not equal.</param>
  86. /// <returns>bool2 result of the componentwise not equal.</returns>
  87. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  88. public static bool2 operator != (bool2 lhs, bool rhs) { return new bool2 (lhs.x != rhs, lhs.y != rhs); }
  89. /// <summary>Returns the result of a componentwise not equal operation on a bool value and a bool2 vector.</summary>
  90. /// <param name="lhs">Left hand side bool to use to compute componentwise not equal.</param>
  91. /// <param name="rhs">Right hand side bool2 to use to compute componentwise not equal.</param>
  92. /// <returns>bool2 result of the componentwise not equal.</returns>
  93. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  94. public static bool2 operator != (bool lhs, bool2 rhs) { return new bool2 (lhs != rhs.x, lhs != rhs.y); }
  95. /// <summary>Returns the result of a componentwise not operation on a bool2 vector.</summary>
  96. /// <param name="val">Value to use when computing the componentwise not.</param>
  97. /// <returns>bool2 result of the componentwise not.</returns>
  98. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  99. public static bool2 operator ! (bool2 val) { return new bool2 (!val.x, !val.y); }
  100. /// <summary>Returns the result of a componentwise bitwise and operation on two bool2 vectors.</summary>
  101. /// <param name="lhs">Left hand side bool2 to use to compute componentwise bitwise and.</param>
  102. /// <param name="rhs">Right hand side bool2 to use to compute componentwise bitwise and.</param>
  103. /// <returns>bool2 result of the componentwise bitwise and.</returns>
  104. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  105. public static bool2 operator & (bool2 lhs, bool2 rhs) { return new bool2 (lhs.x & rhs.x, lhs.y & rhs.y); }
  106. /// <summary>Returns the result of a componentwise bitwise and operation on a bool2 vector and a bool value.</summary>
  107. /// <param name="lhs">Left hand side bool2 to use to compute componentwise bitwise and.</param>
  108. /// <param name="rhs">Right hand side bool to use to compute componentwise bitwise and.</param>
  109. /// <returns>bool2 result of the componentwise bitwise and.</returns>
  110. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  111. public static bool2 operator & (bool2 lhs, bool rhs) { return new bool2 (lhs.x & rhs, lhs.y & rhs); }
  112. /// <summary>Returns the result of a componentwise bitwise and operation on a bool value and a bool2 vector.</summary>
  113. /// <param name="lhs">Left hand side bool to use to compute componentwise bitwise and.</param>
  114. /// <param name="rhs">Right hand side bool2 to use to compute componentwise bitwise and.</param>
  115. /// <returns>bool2 result of the componentwise bitwise and.</returns>
  116. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  117. public static bool2 operator & (bool lhs, bool2 rhs) { return new bool2 (lhs & rhs.x, lhs & rhs.y); }
  118. /// <summary>Returns the result of a componentwise bitwise or operation on two bool2 vectors.</summary>
  119. /// <param name="lhs">Left hand side bool2 to use to compute componentwise bitwise or.</param>
  120. /// <param name="rhs">Right hand side bool2 to use to compute componentwise bitwise or.</param>
  121. /// <returns>bool2 result of the componentwise bitwise or.</returns>
  122. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  123. public static bool2 operator | (bool2 lhs, bool2 rhs) { return new bool2 (lhs.x | rhs.x, lhs.y | rhs.y); }
  124. /// <summary>Returns the result of a componentwise bitwise or operation on a bool2 vector and a bool value.</summary>
  125. /// <param name="lhs">Left hand side bool2 to use to compute componentwise bitwise or.</param>
  126. /// <param name="rhs">Right hand side bool to use to compute componentwise bitwise or.</param>
  127. /// <returns>bool2 result of the componentwise bitwise or.</returns>
  128. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  129. public static bool2 operator | (bool2 lhs, bool rhs) { return new bool2 (lhs.x | rhs, lhs.y | rhs); }
  130. /// <summary>Returns the result of a componentwise bitwise or operation on a bool value and a bool2 vector.</summary>
  131. /// <param name="lhs">Left hand side bool to use to compute componentwise bitwise or.</param>
  132. /// <param name="rhs">Right hand side bool2 to use to compute componentwise bitwise or.</param>
  133. /// <returns>bool2 result of the componentwise bitwise or.</returns>
  134. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  135. public static bool2 operator | (bool lhs, bool2 rhs) { return new bool2 (lhs | rhs.x, lhs | rhs.y); }
  136. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on two bool2 vectors.</summary>
  137. /// <param name="lhs">Left hand side bool2 to use to compute componentwise bitwise exclusive or.</param>
  138. /// <param name="rhs">Right hand side bool2 to use to compute componentwise bitwise exclusive or.</param>
  139. /// <returns>bool2 result of the componentwise bitwise exclusive or.</returns>
  140. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  141. public static bool2 operator ^ (bool2 lhs, bool2 rhs) { return new bool2 (lhs.x ^ rhs.x, lhs.y ^ rhs.y); }
  142. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on a bool2 vector and a bool value.</summary>
  143. /// <param name="lhs">Left hand side bool2 to use to compute componentwise bitwise exclusive or.</param>
  144. /// <param name="rhs">Right hand side bool to use to compute componentwise bitwise exclusive or.</param>
  145. /// <returns>bool2 result of the componentwise bitwise exclusive or.</returns>
  146. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  147. public static bool2 operator ^ (bool2 lhs, bool rhs) { return new bool2 (lhs.x ^ rhs, lhs.y ^ rhs); }
  148. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on a bool value and a bool2 vector.</summary>
  149. /// <param name="lhs">Left hand side bool to use to compute componentwise bitwise exclusive or.</param>
  150. /// <param name="rhs">Right hand side bool2 to use to compute componentwise bitwise exclusive or.</param>
  151. /// <returns>bool2 result of the componentwise bitwise exclusive or.</returns>
  152. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  153. public static bool2 operator ^ (bool lhs, bool2 rhs) { return new bool2 (lhs ^ rhs.x, lhs ^ rhs.y); }
  154. /// <summary>Swizzles the vector.</summary>
  155. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  156. public bool4 xxxx
  157. {
  158. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  159. get { return new bool4(x, x, x, x); }
  160. }
  161. /// <summary>Swizzles the vector.</summary>
  162. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  163. public bool4 xxxy
  164. {
  165. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  166. get { return new bool4(x, x, x, y); }
  167. }
  168. /// <summary>Swizzles the vector.</summary>
  169. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  170. public bool4 xxyx
  171. {
  172. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  173. get { return new bool4(x, x, y, x); }
  174. }
  175. /// <summary>Swizzles the vector.</summary>
  176. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  177. public bool4 xxyy
  178. {
  179. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  180. get { return new bool4(x, x, y, y); }
  181. }
  182. /// <summary>Swizzles the vector.</summary>
  183. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  184. public bool4 xyxx
  185. {
  186. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  187. get { return new bool4(x, y, x, x); }
  188. }
  189. /// <summary>Swizzles the vector.</summary>
  190. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  191. public bool4 xyxy
  192. {
  193. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  194. get { return new bool4(x, y, x, y); }
  195. }
  196. /// <summary>Swizzles the vector.</summary>
  197. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  198. public bool4 xyyx
  199. {
  200. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  201. get { return new bool4(x, y, y, x); }
  202. }
  203. /// <summary>Swizzles the vector.</summary>
  204. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  205. public bool4 xyyy
  206. {
  207. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  208. get { return new bool4(x, y, y, y); }
  209. }
  210. /// <summary>Swizzles the vector.</summary>
  211. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  212. public bool4 yxxx
  213. {
  214. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  215. get { return new bool4(y, x, x, x); }
  216. }
  217. /// <summary>Swizzles the vector.</summary>
  218. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  219. public bool4 yxxy
  220. {
  221. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  222. get { return new bool4(y, x, x, y); }
  223. }
  224. /// <summary>Swizzles the vector.</summary>
  225. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  226. public bool4 yxyx
  227. {
  228. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  229. get { return new bool4(y, x, y, x); }
  230. }
  231. /// <summary>Swizzles the vector.</summary>
  232. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  233. public bool4 yxyy
  234. {
  235. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  236. get { return new bool4(y, x, y, y); }
  237. }
  238. /// <summary>Swizzles the vector.</summary>
  239. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  240. public bool4 yyxx
  241. {
  242. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  243. get { return new bool4(y, y, x, x); }
  244. }
  245. /// <summary>Swizzles the vector.</summary>
  246. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  247. public bool4 yyxy
  248. {
  249. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  250. get { return new bool4(y, y, x, y); }
  251. }
  252. /// <summary>Swizzles the vector.</summary>
  253. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  254. public bool4 yyyx
  255. {
  256. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  257. get { return new bool4(y, y, y, x); }
  258. }
  259. /// <summary>Swizzles the vector.</summary>
  260. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  261. public bool4 yyyy
  262. {
  263. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  264. get { return new bool4(y, y, y, y); }
  265. }
  266. /// <summary>Swizzles the vector.</summary>
  267. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  268. public bool3 xxx
  269. {
  270. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  271. get { return new bool3(x, x, x); }
  272. }
  273. /// <summary>Swizzles the vector.</summary>
  274. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  275. public bool3 xxy
  276. {
  277. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  278. get { return new bool3(x, x, y); }
  279. }
  280. /// <summary>Swizzles the vector.</summary>
  281. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  282. public bool3 xyx
  283. {
  284. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  285. get { return new bool3(x, y, x); }
  286. }
  287. /// <summary>Swizzles the vector.</summary>
  288. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  289. public bool3 xyy
  290. {
  291. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  292. get { return new bool3(x, y, y); }
  293. }
  294. /// <summary>Swizzles the vector.</summary>
  295. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  296. public bool3 yxx
  297. {
  298. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  299. get { return new bool3(y, x, x); }
  300. }
  301. /// <summary>Swizzles the vector.</summary>
  302. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  303. public bool3 yxy
  304. {
  305. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  306. get { return new bool3(y, x, y); }
  307. }
  308. /// <summary>Swizzles the vector.</summary>
  309. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  310. public bool3 yyx
  311. {
  312. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  313. get { return new bool3(y, y, x); }
  314. }
  315. /// <summary>Swizzles the vector.</summary>
  316. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  317. public bool3 yyy
  318. {
  319. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  320. get { return new bool3(y, y, y); }
  321. }
  322. /// <summary>Swizzles the vector.</summary>
  323. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  324. public bool2 xx
  325. {
  326. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  327. get { return new bool2(x, x); }
  328. }
  329. /// <summary>Swizzles the vector.</summary>
  330. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  331. public bool2 xy
  332. {
  333. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  334. get { return new bool2(x, y); }
  335. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  336. set { x = value.x; y = value.y; }
  337. }
  338. /// <summary>Swizzles the vector.</summary>
  339. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  340. public bool2 yx
  341. {
  342. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  343. get { return new bool2(y, x); }
  344. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  345. set { y = value.x; x = value.y; }
  346. }
  347. /// <summary>Swizzles the vector.</summary>
  348. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  349. public bool2 yy
  350. {
  351. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  352. get { return new bool2(y, y); }
  353. }
  354. /// <summary>Returns the bool element at a specified index.</summary>
  355. unsafe public bool this[int index]
  356. {
  357. get
  358. {
  359. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  360. if ((uint)index >= 2)
  361. throw new System.ArgumentException("index must be between[0...1]");
  362. #endif
  363. fixed (bool2* array = &this) { return ((bool*)array)[index]; }
  364. }
  365. set
  366. {
  367. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  368. if ((uint)index >= 2)
  369. throw new System.ArgumentException("index must be between[0...1]");
  370. #endif
  371. fixed (bool* array = &x) { array[index] = value; }
  372. }
  373. }
  374. /// <summary>Returns true if the bool2 is equal to a given bool2, false otherwise.</summary>
  375. /// <param name="rhs">Right hand side argument to compare equality with.</param>
  376. /// <returns>The result of the equality comparison.</returns>
  377. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  378. public bool Equals(bool2 rhs) { return x == rhs.x && y == rhs.y; }
  379. /// <summary>Returns true if the bool2 is equal to a given bool2, false otherwise.</summary>
  380. /// <param name="o">Right hand side argument to compare equality with.</param>
  381. /// <returns>The result of the equality comparison.</returns>
  382. public override bool Equals(object o) { return o is bool2 converted && Equals(converted); }
  383. /// <summary>Returns a hash code for the bool2.</summary>
  384. /// <returns>The computed hash code.</returns>
  385. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  386. public override int GetHashCode() { return (int)math.hash(this); }
  387. /// <summary>Returns a string representation of the bool2.</summary>
  388. /// <returns>String representation of the value.</returns>
  389. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  390. public override string ToString()
  391. {
  392. return string.Format("bool2({0}, {1})", x, y);
  393. }
  394. internal sealed class DebuggerProxy
  395. {
  396. public bool x;
  397. public bool y;
  398. public DebuggerProxy(bool2 v)
  399. {
  400. x = v.x;
  401. y = v.y;
  402. }
  403. }
  404. }
  405. public static partial class math
  406. {
  407. /// <summary>Returns a bool2 vector constructed from two bool values.</summary>
  408. /// <param name="x">The constructed vector's x component will be set to this value.</param>
  409. /// <param name="y">The constructed vector's y component will be set to this value.</param>
  410. /// <returns>bool2 constructed from arguments.</returns>
  411. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  412. public static bool2 bool2(bool x, bool y) { return new bool2(x, y); }
  413. /// <summary>Returns a bool2 vector constructed from a bool2 vector.</summary>
  414. /// <param name="xy">The constructed vector's xy components will be set to this value.</param>
  415. /// <returns>bool2 constructed from arguments.</returns>
  416. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  417. public static bool2 bool2(bool2 xy) { return new bool2(xy); }
  418. /// <summary>Returns a bool2 vector constructed from a single bool value by assigning it to every component.</summary>
  419. /// <param name="v">bool to convert to bool2</param>
  420. /// <returns>Converted value.</returns>
  421. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  422. public static bool2 bool2(bool v) { return new bool2(v); }
  423. /// <summary>Returns a uint hash code of a bool2 vector.</summary>
  424. /// <param name="v">Vector value to hash.</param>
  425. /// <returns>uint hash of the argument.</returns>
  426. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  427. public static uint hash(bool2 v)
  428. {
  429. return csum(select(uint2(0x90A285BBu, 0x5D19E1D5u), uint2(0xFAAF07DDu, 0x625C45BDu), v));
  430. }
  431. /// <summary>
  432. /// Returns a uint2 vector hash code of a bool2 vector.
  433. /// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
  434. /// that are only reduced to a narrow uint hash at the very end instead of at every step.
  435. /// </summary>
  436. /// <param name="v">Vector value to hash.</param>
  437. /// <returns>uint2 hash of the argument.</returns>
  438. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  439. public static uint2 hashwide(bool2 v)
  440. {
  441. return (select(uint2(0xC9F27FCBu, 0x6D2523B1u), uint2(0x6E2BF6A9u, 0xCC74B3B7u), v));
  442. }
  443. /// <summary>Returns the result of specified shuffling of the components from two bool2 vectors into a bool value.</summary>
  444. /// <param name="left">bool2 to use as the left argument of the shuffle operation.</param>
  445. /// <param name="right">bool2 to use as the right argument of the shuffle operation.</param>
  446. /// <param name="x">The ShuffleComponent to use when setting the resulting bool.</param>
  447. /// <returns>bool result of the shuffle operation.</returns>
  448. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  449. public static bool shuffle(bool2 left, bool2 right, ShuffleComponent x)
  450. {
  451. return select_shuffle_component(left, right, x);
  452. }
  453. /// <summary>Returns the result of specified shuffling of the components from two bool2 vectors into a bool2 vector.</summary>
  454. /// <param name="left">bool2 to use as the left argument of the shuffle operation.</param>
  455. /// <param name="right">bool2 to use as the right argument of the shuffle operation.</param>
  456. /// <param name="x">The ShuffleComponent to use when setting the resulting bool2 x component.</param>
  457. /// <param name="y">The ShuffleComponent to use when setting the resulting bool2 y component.</param>
  458. /// <returns>bool2 result of the shuffle operation.</returns>
  459. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  460. public static bool2 shuffle(bool2 left, bool2 right, ShuffleComponent x, ShuffleComponent y)
  461. {
  462. return bool2(
  463. select_shuffle_component(left, right, x),
  464. select_shuffle_component(left, right, y));
  465. }
  466. /// <summary>Returns the result of specified shuffling of the components from two bool2 vectors into a bool3 vector.</summary>
  467. /// <param name="left">bool2 to use as the left argument of the shuffle operation.</param>
  468. /// <param name="right">bool2 to use as the right argument of the shuffle operation.</param>
  469. /// <param name="x">The ShuffleComponent to use when setting the resulting bool3 x component.</param>
  470. /// <param name="y">The ShuffleComponent to use when setting the resulting bool3 y component.</param>
  471. /// <param name="z">The ShuffleComponent to use when setting the resulting bool3 z component.</param>
  472. /// <returns>bool3 result of the shuffle operation.</returns>
  473. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  474. public static bool3 shuffle(bool2 left, bool2 right, ShuffleComponent x, ShuffleComponent y, ShuffleComponent z)
  475. {
  476. return bool3(
  477. select_shuffle_component(left, right, x),
  478. select_shuffle_component(left, right, y),
  479. select_shuffle_component(left, right, z));
  480. }
  481. /// <summary>Returns the result of specified shuffling of the components from two bool2 vectors into a bool4 vector.</summary>
  482. /// <param name="left">bool2 to use as the left argument of the shuffle operation.</param>
  483. /// <param name="right">bool2 to use as the right argument of the shuffle operation.</param>
  484. /// <param name="x">The ShuffleComponent to use when setting the resulting bool4 x component.</param>
  485. /// <param name="y">The ShuffleComponent to use when setting the resulting bool4 y component.</param>
  486. /// <param name="z">The ShuffleComponent to use when setting the resulting bool4 z component.</param>
  487. /// <param name="w">The ShuffleComponent to use when setting the resulting bool4 w component.</param>
  488. /// <returns>bool4 result of the shuffle operation.</returns>
  489. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  490. public static bool4 shuffle(bool2 left, bool2 right, ShuffleComponent x, ShuffleComponent y, ShuffleComponent z, ShuffleComponent w)
  491. {
  492. return bool4(
  493. select_shuffle_component(left, right, x),
  494. select_shuffle_component(left, right, y),
  495. select_shuffle_component(left, right, z),
  496. select_shuffle_component(left, right, w));
  497. }
  498. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  499. internal static bool select_shuffle_component(bool2 a, bool2 b, ShuffleComponent component)
  500. {
  501. switch(component)
  502. {
  503. case ShuffleComponent.LeftX:
  504. return a.x;
  505. case ShuffleComponent.LeftY:
  506. return a.y;
  507. case ShuffleComponent.RightX:
  508. return b.x;
  509. case ShuffleComponent.RightY:
  510. return b.y;
  511. default:
  512. throw new System.ArgumentException("Invalid shuffle component: " + component);
  513. }
  514. }
  515. }
  516. }