Brak opisu
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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  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.Diagnostics;
  12. using Unity.IL2CPP.CompilerServices;
  13. #pragma warning disable 0660, 0661
  14. namespace Unity.Mathematics
  15. {
  16. /// <summary>A 2 component vector of ints.</summary>
  17. [DebuggerTypeProxy(typeof(int2.DebuggerProxy))]
  18. [System.Serializable]
  19. [Il2CppEagerStaticClassConstruction]
  20. public partial struct int2 : System.IEquatable<int2>, IFormattable
  21. {
  22. /// <summary>x component of the vector.</summary>
  23. public int x;
  24. /// <summary>y component of the vector.</summary>
  25. public int y;
  26. /// <summary>int2 zero value.</summary>
  27. public static readonly int2 zero;
  28. /// <summary>Constructs a int2 vector from two int values.</summary>
  29. /// <param name="x">The constructed vector's x component will be set to this value.</param>
  30. /// <param name="y">The constructed vector's y component will be set to this value.</param>
  31. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  32. public int2(int x, int y)
  33. {
  34. this.x = x;
  35. this.y = y;
  36. }
  37. /// <summary>Constructs a int2 vector from an int2 vector.</summary>
  38. /// <param name="xy">The constructed vector's xy components will be set to this value.</param>
  39. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  40. public int2(int2 xy)
  41. {
  42. this.x = xy.x;
  43. this.y = xy.y;
  44. }
  45. /// <summary>Constructs a int2 vector from a single int value by assigning it to every component.</summary>
  46. /// <param name="v">int to convert to int2</param>
  47. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  48. public int2(int v)
  49. {
  50. this.x = v;
  51. this.y = v;
  52. }
  53. /// <summary>Constructs a int2 vector from a single bool value by converting it to int and assigning it to every component.</summary>
  54. /// <param name="v">bool to convert to int2</param>
  55. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  56. public int2(bool v)
  57. {
  58. this.x = v ? 1 : 0;
  59. this.y = v ? 1 : 0;
  60. }
  61. /// <summary>Constructs a int2 vector from a bool2 vector by componentwise conversion.</summary>
  62. /// <param name="v">bool2 to convert to int2</param>
  63. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  64. public int2(bool2 v)
  65. {
  66. this.x = v.x ? 1 : 0;
  67. this.y = v.y ? 1 : 0;
  68. }
  69. /// <summary>Constructs a int2 vector from a single uint value by converting it to int and assigning it to every component.</summary>
  70. /// <param name="v">uint to convert to int2</param>
  71. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  72. public int2(uint v)
  73. {
  74. this.x = (int)v;
  75. this.y = (int)v;
  76. }
  77. /// <summary>Constructs a int2 vector from a uint2 vector by componentwise conversion.</summary>
  78. /// <param name="v">uint2 to convert to int2</param>
  79. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  80. public int2(uint2 v)
  81. {
  82. this.x = (int)v.x;
  83. this.y = (int)v.y;
  84. }
  85. /// <summary>Constructs a int2 vector from a single float value by converting it to int and assigning it to every component.</summary>
  86. /// <param name="v">float to convert to int2</param>
  87. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  88. public int2(float v)
  89. {
  90. this.x = (int)v;
  91. this.y = (int)v;
  92. }
  93. /// <summary>Constructs a int2 vector from a float2 vector by componentwise conversion.</summary>
  94. /// <param name="v">float2 to convert to int2</param>
  95. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  96. public int2(float2 v)
  97. {
  98. this.x = (int)v.x;
  99. this.y = (int)v.y;
  100. }
  101. /// <summary>Constructs a int2 vector from a single double value by converting it to int and assigning it to every component.</summary>
  102. /// <param name="v">double to convert to int2</param>
  103. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  104. public int2(double v)
  105. {
  106. this.x = (int)v;
  107. this.y = (int)v;
  108. }
  109. /// <summary>Constructs a int2 vector from a double2 vector by componentwise conversion.</summary>
  110. /// <param name="v">double2 to convert to int2</param>
  111. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  112. public int2(double2 v)
  113. {
  114. this.x = (int)v.x;
  115. this.y = (int)v.y;
  116. }
  117. /// <summary>Implicitly converts a single int value to a int2 vector by assigning it to every component.</summary>
  118. /// <param name="v">int to convert to int2</param>
  119. /// <returns>Converted value.</returns>
  120. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  121. public static implicit operator int2(int v) { return new int2(v); }
  122. /// <summary>Explicitly converts a single bool value to a int2 vector by converting it to int and assigning it to every component.</summary>
  123. /// <param name="v">bool to convert to int2</param>
  124. /// <returns>Converted value.</returns>
  125. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  126. public static explicit operator int2(bool v) { return new int2(v); }
  127. /// <summary>Explicitly converts a bool2 vector to a int2 vector by componentwise conversion.</summary>
  128. /// <param name="v">bool2 to convert to int2</param>
  129. /// <returns>Converted value.</returns>
  130. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  131. public static explicit operator int2(bool2 v) { return new int2(v); }
  132. /// <summary>Explicitly converts a single uint value to a int2 vector by converting it to int and assigning it to every component.</summary>
  133. /// <param name="v">uint to convert to int2</param>
  134. /// <returns>Converted value.</returns>
  135. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  136. public static explicit operator int2(uint v) { return new int2(v); }
  137. /// <summary>Explicitly converts a uint2 vector to a int2 vector by componentwise conversion.</summary>
  138. /// <param name="v">uint2 to convert to int2</param>
  139. /// <returns>Converted value.</returns>
  140. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  141. public static explicit operator int2(uint2 v) { return new int2(v); }
  142. /// <summary>Explicitly converts a single float value to a int2 vector by converting it to int and assigning it to every component.</summary>
  143. /// <param name="v">float to convert to int2</param>
  144. /// <returns>Converted value.</returns>
  145. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  146. public static explicit operator int2(float v) { return new int2(v); }
  147. /// <summary>Explicitly converts a float2 vector to a int2 vector by componentwise conversion.</summary>
  148. /// <param name="v">float2 to convert to int2</param>
  149. /// <returns>Converted value.</returns>
  150. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  151. public static explicit operator int2(float2 v) { return new int2(v); }
  152. /// <summary>Explicitly converts a single double value to a int2 vector by converting it to int and assigning it to every component.</summary>
  153. /// <param name="v">double to convert to int2</param>
  154. /// <returns>Converted value.</returns>
  155. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  156. public static explicit operator int2(double v) { return new int2(v); }
  157. /// <summary>Explicitly converts a double2 vector to a int2 vector by componentwise conversion.</summary>
  158. /// <param name="v">double2 to convert to int2</param>
  159. /// <returns>Converted value.</returns>
  160. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  161. public static explicit operator int2(double2 v) { return new int2(v); }
  162. /// <summary>Returns the result of a componentwise multiplication operation on two int2 vectors.</summary>
  163. /// <param name="lhs">Left hand side int2 to use to compute componentwise multiplication.</param>
  164. /// <param name="rhs">Right hand side int2 to use to compute componentwise multiplication.</param>
  165. /// <returns>int2 result of the componentwise multiplication.</returns>
  166. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  167. public static int2 operator * (int2 lhs, int2 rhs) { return new int2 (lhs.x * rhs.x, lhs.y * rhs.y); }
  168. /// <summary>Returns the result of a componentwise multiplication operation on an int2 vector and an int value.</summary>
  169. /// <param name="lhs">Left hand side int2 to use to compute componentwise multiplication.</param>
  170. /// <param name="rhs">Right hand side int to use to compute componentwise multiplication.</param>
  171. /// <returns>int2 result of the componentwise multiplication.</returns>
  172. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  173. public static int2 operator * (int2 lhs, int rhs) { return new int2 (lhs.x * rhs, lhs.y * rhs); }
  174. /// <summary>Returns the result of a componentwise multiplication operation on an int value and an int2 vector.</summary>
  175. /// <param name="lhs">Left hand side int to use to compute componentwise multiplication.</param>
  176. /// <param name="rhs">Right hand side int2 to use to compute componentwise multiplication.</param>
  177. /// <returns>int2 result of the componentwise multiplication.</returns>
  178. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  179. public static int2 operator * (int lhs, int2 rhs) { return new int2 (lhs * rhs.x, lhs * rhs.y); }
  180. /// <summary>Returns the result of a componentwise addition operation on two int2 vectors.</summary>
  181. /// <param name="lhs">Left hand side int2 to use to compute componentwise addition.</param>
  182. /// <param name="rhs">Right hand side int2 to use to compute componentwise addition.</param>
  183. /// <returns>int2 result of the componentwise addition.</returns>
  184. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  185. public static int2 operator + (int2 lhs, int2 rhs) { return new int2 (lhs.x + rhs.x, lhs.y + rhs.y); }
  186. /// <summary>Returns the result of a componentwise addition operation on an int2 vector and an int value.</summary>
  187. /// <param name="lhs">Left hand side int2 to use to compute componentwise addition.</param>
  188. /// <param name="rhs">Right hand side int to use to compute componentwise addition.</param>
  189. /// <returns>int2 result of the componentwise addition.</returns>
  190. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  191. public static int2 operator + (int2 lhs, int rhs) { return new int2 (lhs.x + rhs, lhs.y + rhs); }
  192. /// <summary>Returns the result of a componentwise addition operation on an int value and an int2 vector.</summary>
  193. /// <param name="lhs">Left hand side int to use to compute componentwise addition.</param>
  194. /// <param name="rhs">Right hand side int2 to use to compute componentwise addition.</param>
  195. /// <returns>int2 result of the componentwise addition.</returns>
  196. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  197. public static int2 operator + (int lhs, int2 rhs) { return new int2 (lhs + rhs.x, lhs + rhs.y); }
  198. /// <summary>Returns the result of a componentwise subtraction operation on two int2 vectors.</summary>
  199. /// <param name="lhs">Left hand side int2 to use to compute componentwise subtraction.</param>
  200. /// <param name="rhs">Right hand side int2 to use to compute componentwise subtraction.</param>
  201. /// <returns>int2 result of the componentwise subtraction.</returns>
  202. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  203. public static int2 operator - (int2 lhs, int2 rhs) { return new int2 (lhs.x - rhs.x, lhs.y - rhs.y); }
  204. /// <summary>Returns the result of a componentwise subtraction operation on an int2 vector and an int value.</summary>
  205. /// <param name="lhs">Left hand side int2 to use to compute componentwise subtraction.</param>
  206. /// <param name="rhs">Right hand side int to use to compute componentwise subtraction.</param>
  207. /// <returns>int2 result of the componentwise subtraction.</returns>
  208. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  209. public static int2 operator - (int2 lhs, int rhs) { return new int2 (lhs.x - rhs, lhs.y - rhs); }
  210. /// <summary>Returns the result of a componentwise subtraction operation on an int value and an int2 vector.</summary>
  211. /// <param name="lhs">Left hand side int to use to compute componentwise subtraction.</param>
  212. /// <param name="rhs">Right hand side int2 to use to compute componentwise subtraction.</param>
  213. /// <returns>int2 result of the componentwise subtraction.</returns>
  214. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  215. public static int2 operator - (int lhs, int2 rhs) { return new int2 (lhs - rhs.x, lhs - rhs.y); }
  216. /// <summary>Returns the result of a componentwise division operation on two int2 vectors.</summary>
  217. /// <param name="lhs">Left hand side int2 to use to compute componentwise division.</param>
  218. /// <param name="rhs">Right hand side int2 to use to compute componentwise division.</param>
  219. /// <returns>int2 result of the componentwise division.</returns>
  220. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  221. public static int2 operator / (int2 lhs, int2 rhs) { return new int2 (lhs.x / rhs.x, lhs.y / rhs.y); }
  222. /// <summary>Returns the result of a componentwise division operation on an int2 vector and an int value.</summary>
  223. /// <param name="lhs">Left hand side int2 to use to compute componentwise division.</param>
  224. /// <param name="rhs">Right hand side int to use to compute componentwise division.</param>
  225. /// <returns>int2 result of the componentwise division.</returns>
  226. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  227. public static int2 operator / (int2 lhs, int rhs) { return new int2 (lhs.x / rhs, lhs.y / rhs); }
  228. /// <summary>Returns the result of a componentwise division operation on an int value and an int2 vector.</summary>
  229. /// <param name="lhs">Left hand side int to use to compute componentwise division.</param>
  230. /// <param name="rhs">Right hand side int2 to use to compute componentwise division.</param>
  231. /// <returns>int2 result of the componentwise division.</returns>
  232. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  233. public static int2 operator / (int lhs, int2 rhs) { return new int2 (lhs / rhs.x, lhs / rhs.y); }
  234. /// <summary>Returns the result of a componentwise modulus operation on two int2 vectors.</summary>
  235. /// <param name="lhs">Left hand side int2 to use to compute componentwise modulus.</param>
  236. /// <param name="rhs">Right hand side int2 to use to compute componentwise modulus.</param>
  237. /// <returns>int2 result of the componentwise modulus.</returns>
  238. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  239. public static int2 operator % (int2 lhs, int2 rhs) { return new int2 (lhs.x % rhs.x, lhs.y % rhs.y); }
  240. /// <summary>Returns the result of a componentwise modulus operation on an int2 vector and an int value.</summary>
  241. /// <param name="lhs">Left hand side int2 to use to compute componentwise modulus.</param>
  242. /// <param name="rhs">Right hand side int to use to compute componentwise modulus.</param>
  243. /// <returns>int2 result of the componentwise modulus.</returns>
  244. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  245. public static int2 operator % (int2 lhs, int rhs) { return new int2 (lhs.x % rhs, lhs.y % rhs); }
  246. /// <summary>Returns the result of a componentwise modulus operation on an int value and an int2 vector.</summary>
  247. /// <param name="lhs">Left hand side int to use to compute componentwise modulus.</param>
  248. /// <param name="rhs">Right hand side int2 to use to compute componentwise modulus.</param>
  249. /// <returns>int2 result of the componentwise modulus.</returns>
  250. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  251. public static int2 operator % (int lhs, int2 rhs) { return new int2 (lhs % rhs.x, lhs % rhs.y); }
  252. /// <summary>Returns the result of a componentwise increment operation on an int2 vector.</summary>
  253. /// <param name="val">Value to use when computing the componentwise increment.</param>
  254. /// <returns>int2 result of the componentwise increment.</returns>
  255. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  256. public static int2 operator ++ (int2 val) { return new int2 (++val.x, ++val.y); }
  257. /// <summary>Returns the result of a componentwise decrement operation on an int2 vector.</summary>
  258. /// <param name="val">Value to use when computing the componentwise decrement.</param>
  259. /// <returns>int2 result of the componentwise decrement.</returns>
  260. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  261. public static int2 operator -- (int2 val) { return new int2 (--val.x, --val.y); }
  262. /// <summary>Returns the result of a componentwise less than operation on two int2 vectors.</summary>
  263. /// <param name="lhs">Left hand side int2 to use to compute componentwise less than.</param>
  264. /// <param name="rhs">Right hand side int2 to use to compute componentwise less than.</param>
  265. /// <returns>bool2 result of the componentwise less than.</returns>
  266. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  267. public static bool2 operator < (int2 lhs, int2 rhs) { return new bool2 (lhs.x < rhs.x, lhs.y < rhs.y); }
  268. /// <summary>Returns the result of a componentwise less than operation on an int2 vector and an int value.</summary>
  269. /// <param name="lhs">Left hand side int2 to use to compute componentwise less than.</param>
  270. /// <param name="rhs">Right hand side int to use to compute componentwise less than.</param>
  271. /// <returns>bool2 result of the componentwise less than.</returns>
  272. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  273. public static bool2 operator < (int2 lhs, int rhs) { return new bool2 (lhs.x < rhs, lhs.y < rhs); }
  274. /// <summary>Returns the result of a componentwise less than operation on an int value and an int2 vector.</summary>
  275. /// <param name="lhs">Left hand side int to use to compute componentwise less than.</param>
  276. /// <param name="rhs">Right hand side int2 to use to compute componentwise less than.</param>
  277. /// <returns>bool2 result of the componentwise less than.</returns>
  278. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  279. public static bool2 operator < (int lhs, int2 rhs) { return new bool2 (lhs < rhs.x, lhs < rhs.y); }
  280. /// <summary>Returns the result of a componentwise less or equal operation on two int2 vectors.</summary>
  281. /// <param name="lhs">Left hand side int2 to use to compute componentwise less or equal.</param>
  282. /// <param name="rhs">Right hand side int2 to use to compute componentwise less or equal.</param>
  283. /// <returns>bool2 result of the componentwise less or equal.</returns>
  284. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  285. public static bool2 operator <= (int2 lhs, int2 rhs) { return new bool2 (lhs.x <= rhs.x, lhs.y <= rhs.y); }
  286. /// <summary>Returns the result of a componentwise less or equal operation on an int2 vector and an int value.</summary>
  287. /// <param name="lhs">Left hand side int2 to use to compute componentwise less or equal.</param>
  288. /// <param name="rhs">Right hand side int to use to compute componentwise less or equal.</param>
  289. /// <returns>bool2 result of the componentwise less or equal.</returns>
  290. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  291. public static bool2 operator <= (int2 lhs, int rhs) { return new bool2 (lhs.x <= rhs, lhs.y <= rhs); }
  292. /// <summary>Returns the result of a componentwise less or equal operation on an int value and an int2 vector.</summary>
  293. /// <param name="lhs">Left hand side int to use to compute componentwise less or equal.</param>
  294. /// <param name="rhs">Right hand side int2 to use to compute componentwise less or equal.</param>
  295. /// <returns>bool2 result of the componentwise less or equal.</returns>
  296. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  297. public static bool2 operator <= (int lhs, int2 rhs) { return new bool2 (lhs <= rhs.x, lhs <= rhs.y); }
  298. /// <summary>Returns the result of a componentwise greater than operation on two int2 vectors.</summary>
  299. /// <param name="lhs">Left hand side int2 to use to compute componentwise greater than.</param>
  300. /// <param name="rhs">Right hand side int2 to use to compute componentwise greater than.</param>
  301. /// <returns>bool2 result of the componentwise greater than.</returns>
  302. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  303. public static bool2 operator > (int2 lhs, int2 rhs) { return new bool2 (lhs.x > rhs.x, lhs.y > rhs.y); }
  304. /// <summary>Returns the result of a componentwise greater than operation on an int2 vector and an int value.</summary>
  305. /// <param name="lhs">Left hand side int2 to use to compute componentwise greater than.</param>
  306. /// <param name="rhs">Right hand side int to use to compute componentwise greater than.</param>
  307. /// <returns>bool2 result of the componentwise greater than.</returns>
  308. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  309. public static bool2 operator > (int2 lhs, int rhs) { return new bool2 (lhs.x > rhs, lhs.y > rhs); }
  310. /// <summary>Returns the result of a componentwise greater than operation on an int value and an int2 vector.</summary>
  311. /// <param name="lhs">Left hand side int to use to compute componentwise greater than.</param>
  312. /// <param name="rhs">Right hand side int2 to use to compute componentwise greater than.</param>
  313. /// <returns>bool2 result of the componentwise greater than.</returns>
  314. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  315. public static bool2 operator > (int lhs, int2 rhs) { return new bool2 (lhs > rhs.x, lhs > rhs.y); }
  316. /// <summary>Returns the result of a componentwise greater or equal operation on two int2 vectors.</summary>
  317. /// <param name="lhs">Left hand side int2 to use to compute componentwise greater or equal.</param>
  318. /// <param name="rhs">Right hand side int2 to use to compute componentwise greater or equal.</param>
  319. /// <returns>bool2 result of the componentwise greater or equal.</returns>
  320. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  321. public static bool2 operator >= (int2 lhs, int2 rhs) { return new bool2 (lhs.x >= rhs.x, lhs.y >= rhs.y); }
  322. /// <summary>Returns the result of a componentwise greater or equal operation on an int2 vector and an int value.</summary>
  323. /// <param name="lhs">Left hand side int2 to use to compute componentwise greater or equal.</param>
  324. /// <param name="rhs">Right hand side int to use to compute componentwise greater or equal.</param>
  325. /// <returns>bool2 result of the componentwise greater or equal.</returns>
  326. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  327. public static bool2 operator >= (int2 lhs, int rhs) { return new bool2 (lhs.x >= rhs, lhs.y >= rhs); }
  328. /// <summary>Returns the result of a componentwise greater or equal operation on an int value and an int2 vector.</summary>
  329. /// <param name="lhs">Left hand side int to use to compute componentwise greater or equal.</param>
  330. /// <param name="rhs">Right hand side int2 to use to compute componentwise greater or equal.</param>
  331. /// <returns>bool2 result of the componentwise greater or equal.</returns>
  332. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  333. public static bool2 operator >= (int lhs, int2 rhs) { return new bool2 (lhs >= rhs.x, lhs >= rhs.y); }
  334. /// <summary>Returns the result of a componentwise unary minus operation on an int2 vector.</summary>
  335. /// <param name="val">Value to use when computing the componentwise unary minus.</param>
  336. /// <returns>int2 result of the componentwise unary minus.</returns>
  337. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  338. public static int2 operator - (int2 val) { return new int2 (-val.x, -val.y); }
  339. /// <summary>Returns the result of a componentwise unary plus operation on an int2 vector.</summary>
  340. /// <param name="val">Value to use when computing the componentwise unary plus.</param>
  341. /// <returns>int2 result of the componentwise unary plus.</returns>
  342. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  343. public static int2 operator + (int2 val) { return new int2 (+val.x, +val.y); }
  344. /// <summary>Returns the result of a componentwise left shift operation on an int2 vector by a number of bits specified by a single int.</summary>
  345. /// <param name="x">The vector to left shift.</param>
  346. /// <param name="n">The number of bits to left shift.</param>
  347. /// <returns>The result of the componentwise left shift.</returns>
  348. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  349. public static int2 operator << (int2 x, int n) { return new int2 (x.x << n, x.y << n); }
  350. /// <summary>Returns the result of a componentwise right shift operation on an int2 vector by a number of bits specified by a single int.</summary>
  351. /// <param name="x">The vector to right shift.</param>
  352. /// <param name="n">The number of bits to right shift.</param>
  353. /// <returns>The result of the componentwise right shift.</returns>
  354. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  355. public static int2 operator >> (int2 x, int n) { return new int2 (x.x >> n, x.y >> n); }
  356. /// <summary>Returns the result of a componentwise equality operation on two int2 vectors.</summary>
  357. /// <param name="lhs">Left hand side int2 to use to compute componentwise equality.</param>
  358. /// <param name="rhs">Right hand side int2 to use to compute componentwise equality.</param>
  359. /// <returns>bool2 result of the componentwise equality.</returns>
  360. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  361. public static bool2 operator == (int2 lhs, int2 rhs) { return new bool2 (lhs.x == rhs.x, lhs.y == rhs.y); }
  362. /// <summary>Returns the result of a componentwise equality operation on an int2 vector and an int value.</summary>
  363. /// <param name="lhs">Left hand side int2 to use to compute componentwise equality.</param>
  364. /// <param name="rhs">Right hand side int to use to compute componentwise equality.</param>
  365. /// <returns>bool2 result of the componentwise equality.</returns>
  366. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  367. public static bool2 operator == (int2 lhs, int rhs) { return new bool2 (lhs.x == rhs, lhs.y == rhs); }
  368. /// <summary>Returns the result of a componentwise equality operation on an int value and an int2 vector.</summary>
  369. /// <param name="lhs">Left hand side int to use to compute componentwise equality.</param>
  370. /// <param name="rhs">Right hand side int2 to use to compute componentwise equality.</param>
  371. /// <returns>bool2 result of the componentwise equality.</returns>
  372. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  373. public static bool2 operator == (int lhs, int2 rhs) { return new bool2 (lhs == rhs.x, lhs == rhs.y); }
  374. /// <summary>Returns the result of a componentwise not equal operation on two int2 vectors.</summary>
  375. /// <param name="lhs">Left hand side int2 to use to compute componentwise not equal.</param>
  376. /// <param name="rhs">Right hand side int2 to use to compute componentwise not equal.</param>
  377. /// <returns>bool2 result of the componentwise not equal.</returns>
  378. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  379. public static bool2 operator != (int2 lhs, int2 rhs) { return new bool2 (lhs.x != rhs.x, lhs.y != rhs.y); }
  380. /// <summary>Returns the result of a componentwise not equal operation on an int2 vector and an int value.</summary>
  381. /// <param name="lhs">Left hand side int2 to use to compute componentwise not equal.</param>
  382. /// <param name="rhs">Right hand side int to use to compute componentwise not equal.</param>
  383. /// <returns>bool2 result of the componentwise not equal.</returns>
  384. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  385. public static bool2 operator != (int2 lhs, int rhs) { return new bool2 (lhs.x != rhs, lhs.y != rhs); }
  386. /// <summary>Returns the result of a componentwise not equal operation on an int value and an int2 vector.</summary>
  387. /// <param name="lhs">Left hand side int to use to compute componentwise not equal.</param>
  388. /// <param name="rhs">Right hand side int2 to use to compute componentwise not equal.</param>
  389. /// <returns>bool2 result of the componentwise not equal.</returns>
  390. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  391. public static bool2 operator != (int lhs, int2 rhs) { return new bool2 (lhs != rhs.x, lhs != rhs.y); }
  392. /// <summary>Returns the result of a componentwise bitwise not operation on an int2 vector.</summary>
  393. /// <param name="val">Value to use when computing the componentwise bitwise not.</param>
  394. /// <returns>int2 result of the componentwise bitwise not.</returns>
  395. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  396. public static int2 operator ~ (int2 val) { return new int2 (~val.x, ~val.y); }
  397. /// <summary>Returns the result of a componentwise bitwise and operation on two int2 vectors.</summary>
  398. /// <param name="lhs">Left hand side int2 to use to compute componentwise bitwise and.</param>
  399. /// <param name="rhs">Right hand side int2 to use to compute componentwise bitwise and.</param>
  400. /// <returns>int2 result of the componentwise bitwise and.</returns>
  401. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  402. public static int2 operator & (int2 lhs, int2 rhs) { return new int2 (lhs.x & rhs.x, lhs.y & rhs.y); }
  403. /// <summary>Returns the result of a componentwise bitwise and operation on an int2 vector and an int value.</summary>
  404. /// <param name="lhs">Left hand side int2 to use to compute componentwise bitwise and.</param>
  405. /// <param name="rhs">Right hand side int to use to compute componentwise bitwise and.</param>
  406. /// <returns>int2 result of the componentwise bitwise and.</returns>
  407. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  408. public static int2 operator & (int2 lhs, int rhs) { return new int2 (lhs.x & rhs, lhs.y & rhs); }
  409. /// <summary>Returns the result of a componentwise bitwise and operation on an int value and an int2 vector.</summary>
  410. /// <param name="lhs">Left hand side int to use to compute componentwise bitwise and.</param>
  411. /// <param name="rhs">Right hand side int2 to use to compute componentwise bitwise and.</param>
  412. /// <returns>int2 result of the componentwise bitwise and.</returns>
  413. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  414. public static int2 operator & (int lhs, int2 rhs) { return new int2 (lhs & rhs.x, lhs & rhs.y); }
  415. /// <summary>Returns the result of a componentwise bitwise or operation on two int2 vectors.</summary>
  416. /// <param name="lhs">Left hand side int2 to use to compute componentwise bitwise or.</param>
  417. /// <param name="rhs">Right hand side int2 to use to compute componentwise bitwise or.</param>
  418. /// <returns>int2 result of the componentwise bitwise or.</returns>
  419. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  420. public static int2 operator | (int2 lhs, int2 rhs) { return new int2 (lhs.x | rhs.x, lhs.y | rhs.y); }
  421. /// <summary>Returns the result of a componentwise bitwise or operation on an int2 vector and an int value.</summary>
  422. /// <param name="lhs">Left hand side int2 to use to compute componentwise bitwise or.</param>
  423. /// <param name="rhs">Right hand side int to use to compute componentwise bitwise or.</param>
  424. /// <returns>int2 result of the componentwise bitwise or.</returns>
  425. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  426. public static int2 operator | (int2 lhs, int rhs) { return new int2 (lhs.x | rhs, lhs.y | rhs); }
  427. /// <summary>Returns the result of a componentwise bitwise or operation on an int value and an int2 vector.</summary>
  428. /// <param name="lhs">Left hand side int to use to compute componentwise bitwise or.</param>
  429. /// <param name="rhs">Right hand side int2 to use to compute componentwise bitwise or.</param>
  430. /// <returns>int2 result of the componentwise bitwise or.</returns>
  431. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  432. public static int2 operator | (int lhs, int2 rhs) { return new int2 (lhs | rhs.x, lhs | rhs.y); }
  433. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on two int2 vectors.</summary>
  434. /// <param name="lhs">Left hand side int2 to use to compute componentwise bitwise exclusive or.</param>
  435. /// <param name="rhs">Right hand side int2 to use to compute componentwise bitwise exclusive or.</param>
  436. /// <returns>int2 result of the componentwise bitwise exclusive or.</returns>
  437. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  438. public static int2 operator ^ (int2 lhs, int2 rhs) { return new int2 (lhs.x ^ rhs.x, lhs.y ^ rhs.y); }
  439. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on an int2 vector and an int value.</summary>
  440. /// <param name="lhs">Left hand side int2 to use to compute componentwise bitwise exclusive or.</param>
  441. /// <param name="rhs">Right hand side int to use to compute componentwise bitwise exclusive or.</param>
  442. /// <returns>int2 result of the componentwise bitwise exclusive or.</returns>
  443. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  444. public static int2 operator ^ (int2 lhs, int rhs) { return new int2 (lhs.x ^ rhs, lhs.y ^ rhs); }
  445. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on an int value and an int2 vector.</summary>
  446. /// <param name="lhs">Left hand side int to use to compute componentwise bitwise exclusive or.</param>
  447. /// <param name="rhs">Right hand side int2 to use to compute componentwise bitwise exclusive or.</param>
  448. /// <returns>int2 result of the componentwise bitwise exclusive or.</returns>
  449. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  450. public static int2 operator ^ (int lhs, int2 rhs) { return new int2 (lhs ^ rhs.x, lhs ^ rhs.y); }
  451. /// <summary>Swizzles the vector.</summary>
  452. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  453. public int4 xxxx
  454. {
  455. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  456. get { return new int4(x, x, x, x); }
  457. }
  458. /// <summary>Swizzles the vector.</summary>
  459. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  460. public int4 xxxy
  461. {
  462. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  463. get { return new int4(x, x, x, y); }
  464. }
  465. /// <summary>Swizzles the vector.</summary>
  466. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  467. public int4 xxyx
  468. {
  469. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  470. get { return new int4(x, x, y, x); }
  471. }
  472. /// <summary>Swizzles the vector.</summary>
  473. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  474. public int4 xxyy
  475. {
  476. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  477. get { return new int4(x, x, y, y); }
  478. }
  479. /// <summary>Swizzles the vector.</summary>
  480. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  481. public int4 xyxx
  482. {
  483. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  484. get { return new int4(x, y, x, x); }
  485. }
  486. /// <summary>Swizzles the vector.</summary>
  487. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  488. public int4 xyxy
  489. {
  490. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  491. get { return new int4(x, y, x, y); }
  492. }
  493. /// <summary>Swizzles the vector.</summary>
  494. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  495. public int4 xyyx
  496. {
  497. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  498. get { return new int4(x, y, y, x); }
  499. }
  500. /// <summary>Swizzles the vector.</summary>
  501. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  502. public int4 xyyy
  503. {
  504. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  505. get { return new int4(x, y, y, y); }
  506. }
  507. /// <summary>Swizzles the vector.</summary>
  508. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  509. public int4 yxxx
  510. {
  511. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  512. get { return new int4(y, x, x, x); }
  513. }
  514. /// <summary>Swizzles the vector.</summary>
  515. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  516. public int4 yxxy
  517. {
  518. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  519. get { return new int4(y, x, x, y); }
  520. }
  521. /// <summary>Swizzles the vector.</summary>
  522. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  523. public int4 yxyx
  524. {
  525. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  526. get { return new int4(y, x, y, x); }
  527. }
  528. /// <summary>Swizzles the vector.</summary>
  529. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  530. public int4 yxyy
  531. {
  532. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  533. get { return new int4(y, x, y, y); }
  534. }
  535. /// <summary>Swizzles the vector.</summary>
  536. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  537. public int4 yyxx
  538. {
  539. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  540. get { return new int4(y, y, x, x); }
  541. }
  542. /// <summary>Swizzles the vector.</summary>
  543. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  544. public int4 yyxy
  545. {
  546. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  547. get { return new int4(y, y, x, y); }
  548. }
  549. /// <summary>Swizzles the vector.</summary>
  550. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  551. public int4 yyyx
  552. {
  553. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  554. get { return new int4(y, y, y, x); }
  555. }
  556. /// <summary>Swizzles the vector.</summary>
  557. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  558. public int4 yyyy
  559. {
  560. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  561. get { return new int4(y, y, y, y); }
  562. }
  563. /// <summary>Swizzles the vector.</summary>
  564. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  565. public int3 xxx
  566. {
  567. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  568. get { return new int3(x, x, x); }
  569. }
  570. /// <summary>Swizzles the vector.</summary>
  571. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  572. public int3 xxy
  573. {
  574. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  575. get { return new int3(x, x, y); }
  576. }
  577. /// <summary>Swizzles the vector.</summary>
  578. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  579. public int3 xyx
  580. {
  581. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  582. get { return new int3(x, y, x); }
  583. }
  584. /// <summary>Swizzles the vector.</summary>
  585. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  586. public int3 xyy
  587. {
  588. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  589. get { return new int3(x, y, y); }
  590. }
  591. /// <summary>Swizzles the vector.</summary>
  592. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  593. public int3 yxx
  594. {
  595. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  596. get { return new int3(y, x, x); }
  597. }
  598. /// <summary>Swizzles the vector.</summary>
  599. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  600. public int3 yxy
  601. {
  602. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  603. get { return new int3(y, x, y); }
  604. }
  605. /// <summary>Swizzles the vector.</summary>
  606. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  607. public int3 yyx
  608. {
  609. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  610. get { return new int3(y, y, x); }
  611. }
  612. /// <summary>Swizzles the vector.</summary>
  613. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  614. public int3 yyy
  615. {
  616. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  617. get { return new int3(y, y, y); }
  618. }
  619. /// <summary>Swizzles the vector.</summary>
  620. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  621. public int2 xx
  622. {
  623. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  624. get { return new int2(x, x); }
  625. }
  626. /// <summary>Swizzles the vector.</summary>
  627. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  628. public int2 xy
  629. {
  630. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  631. get { return new int2(x, y); }
  632. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  633. set { x = value.x; y = value.y; }
  634. }
  635. /// <summary>Swizzles the vector.</summary>
  636. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  637. public int2 yx
  638. {
  639. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  640. get { return new int2(y, x); }
  641. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  642. set { y = value.x; x = value.y; }
  643. }
  644. /// <summary>Swizzles the vector.</summary>
  645. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  646. public int2 yy
  647. {
  648. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  649. get { return new int2(y, y); }
  650. }
  651. /// <summary>Returns the int element at a specified index.</summary>
  652. unsafe public int this[int index]
  653. {
  654. get
  655. {
  656. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  657. if ((uint)index >= 2)
  658. throw new System.ArgumentException("index must be between[0...1]");
  659. #endif
  660. fixed (int2* array = &this) { return ((int*)array)[index]; }
  661. }
  662. set
  663. {
  664. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  665. if ((uint)index >= 2)
  666. throw new System.ArgumentException("index must be between[0...1]");
  667. #endif
  668. fixed (int* array = &x) { array[index] = value; }
  669. }
  670. }
  671. /// <summary>Returns true if the int2 is equal to a given int2, false otherwise.</summary>
  672. /// <param name="rhs">Right hand side argument to compare equality with.</param>
  673. /// <returns>The result of the equality comparison.</returns>
  674. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  675. public bool Equals(int2 rhs) { return x == rhs.x && y == rhs.y; }
  676. /// <summary>Returns true if the int2 is equal to a given int2, false otherwise.</summary>
  677. /// <param name="o">Right hand side argument to compare equality with.</param>
  678. /// <returns>The result of the equality comparison.</returns>
  679. public override bool Equals(object o) { return o is int2 converted && Equals(converted); }
  680. /// <summary>Returns a hash code for the int2.</summary>
  681. /// <returns>The computed hash code.</returns>
  682. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  683. public override int GetHashCode() { return (int)math.hash(this); }
  684. /// <summary>Returns a string representation of the int2.</summary>
  685. /// <returns>String representation of the value.</returns>
  686. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  687. public override string ToString()
  688. {
  689. return string.Format("int2({0}, {1})", x, y);
  690. }
  691. /// <summary>Returns a string representation of the int2 using a specified format and culture-specific format information.</summary>
  692. /// <param name="format">Format string to use during string formatting.</param>
  693. /// <param name="formatProvider">Format provider to use during string formatting.</param>
  694. /// <returns>String representation of the value.</returns>
  695. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  696. public string ToString(string format, IFormatProvider formatProvider)
  697. {
  698. return string.Format("int2({0}, {1})", x.ToString(format, formatProvider), y.ToString(format, formatProvider));
  699. }
  700. internal sealed class DebuggerProxy
  701. {
  702. public int x;
  703. public int y;
  704. public DebuggerProxy(int2 v)
  705. {
  706. x = v.x;
  707. y = v.y;
  708. }
  709. }
  710. }
  711. public static partial class math
  712. {
  713. /// <summary>Returns a int2 vector constructed from two int values.</summary>
  714. /// <param name="x">The constructed vector's x component will be set to this value.</param>
  715. /// <param name="y">The constructed vector's y component will be set to this value.</param>
  716. /// <returns>int2 constructed from arguments.</returns>
  717. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  718. public static int2 int2(int x, int y) { return new int2(x, y); }
  719. /// <summary>Returns a int2 vector constructed from an int2 vector.</summary>
  720. /// <param name="xy">The constructed vector's xy components will be set to this value.</param>
  721. /// <returns>int2 constructed from arguments.</returns>
  722. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  723. public static int2 int2(int2 xy) { return new int2(xy); }
  724. /// <summary>Returns a int2 vector constructed from a single int value by assigning it to every component.</summary>
  725. /// <param name="v">int to convert to int2</param>
  726. /// <returns>Converted value.</returns>
  727. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  728. public static int2 int2(int v) { return new int2(v); }
  729. /// <summary>Returns a int2 vector constructed from a single bool value by converting it to int and assigning it to every component.</summary>
  730. /// <param name="v">bool to convert to int2</param>
  731. /// <returns>Converted value.</returns>
  732. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  733. public static int2 int2(bool v) { return new int2(v); }
  734. /// <summary>Return a int2 vector constructed from a bool2 vector by componentwise conversion.</summary>
  735. /// <param name="v">bool2 to convert to int2</param>
  736. /// <returns>Converted value.</returns>
  737. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  738. public static int2 int2(bool2 v) { return new int2(v); }
  739. /// <summary>Returns a int2 vector constructed from a single uint value by converting it to int and assigning it to every component.</summary>
  740. /// <param name="v">uint to convert to int2</param>
  741. /// <returns>Converted value.</returns>
  742. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  743. public static int2 int2(uint v) { return new int2(v); }
  744. /// <summary>Return a int2 vector constructed from a uint2 vector by componentwise conversion.</summary>
  745. /// <param name="v">uint2 to convert to int2</param>
  746. /// <returns>Converted value.</returns>
  747. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  748. public static int2 int2(uint2 v) { return new int2(v); }
  749. /// <summary>Returns a int2 vector constructed from a single float value by converting it to int and assigning it to every component.</summary>
  750. /// <param name="v">float to convert to int2</param>
  751. /// <returns>Converted value.</returns>
  752. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  753. public static int2 int2(float v) { return new int2(v); }
  754. /// <summary>Return a int2 vector constructed from a float2 vector by componentwise conversion.</summary>
  755. /// <param name="v">float2 to convert to int2</param>
  756. /// <returns>Converted value.</returns>
  757. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  758. public static int2 int2(float2 v) { return new int2(v); }
  759. /// <summary>Returns a int2 vector constructed from a single double value by converting it to int and assigning it to every component.</summary>
  760. /// <param name="v">double to convert to int2</param>
  761. /// <returns>Converted value.</returns>
  762. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  763. public static int2 int2(double v) { return new int2(v); }
  764. /// <summary>Return a int2 vector constructed from a double2 vector by componentwise conversion.</summary>
  765. /// <param name="v">double2 to convert to int2</param>
  766. /// <returns>Converted value.</returns>
  767. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  768. public static int2 int2(double2 v) { return new int2(v); }
  769. /// <summary>Returns a uint hash code of a int2 vector.</summary>
  770. /// <param name="v">Vector value to hash.</param>
  771. /// <returns>uint hash of the argument.</returns>
  772. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  773. public static uint hash(int2 v)
  774. {
  775. return csum(asuint(v) * uint2(0x83B58237u, 0x833E3E29u)) + 0xA9D919BFu;
  776. }
  777. /// <summary>
  778. /// Returns a uint2 vector hash code of a int2 vector.
  779. /// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
  780. /// that are only reduced to a narrow uint hash at the very end instead of at every step.
  781. /// </summary>
  782. /// <param name="v">Vector value to hash.</param>
  783. /// <returns>uint2 hash of the argument.</returns>
  784. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  785. public static uint2 hashwide(int2 v)
  786. {
  787. return (asuint(v) * uint2(0xC3EC1D97u, 0xB8B208C7u)) + 0x5D3ED947u;
  788. }
  789. /// <summary>Returns the result of specified shuffling of the components from two int2 vectors into an int value.</summary>
  790. /// <param name="left">int2 to use as the left argument of the shuffle operation.</param>
  791. /// <param name="right">int2 to use as the right argument of the shuffle operation.</param>
  792. /// <param name="x">The ShuffleComponent to use when setting the resulting int.</param>
  793. /// <returns>int result of the shuffle operation.</returns>
  794. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  795. public static int shuffle(int2 left, int2 right, ShuffleComponent x)
  796. {
  797. return select_shuffle_component(left, right, x);
  798. }
  799. /// <summary>Returns the result of specified shuffling of the components from two int2 vectors into an int2 vector.</summary>
  800. /// <param name="left">int2 to use as the left argument of the shuffle operation.</param>
  801. /// <param name="right">int2 to use as the right argument of the shuffle operation.</param>
  802. /// <param name="x">The ShuffleComponent to use when setting the resulting int2 x component.</param>
  803. /// <param name="y">The ShuffleComponent to use when setting the resulting int2 y component.</param>
  804. /// <returns>int2 result of the shuffle operation.</returns>
  805. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  806. public static int2 shuffle(int2 left, int2 right, ShuffleComponent x, ShuffleComponent y)
  807. {
  808. return int2(
  809. select_shuffle_component(left, right, x),
  810. select_shuffle_component(left, right, y));
  811. }
  812. /// <summary>Returns the result of specified shuffling of the components from two int2 vectors into an int3 vector.</summary>
  813. /// <param name="left">int2 to use as the left argument of the shuffle operation.</param>
  814. /// <param name="right">int2 to use as the right argument of the shuffle operation.</param>
  815. /// <param name="x">The ShuffleComponent to use when setting the resulting int3 x component.</param>
  816. /// <param name="y">The ShuffleComponent to use when setting the resulting int3 y component.</param>
  817. /// <param name="z">The ShuffleComponent to use when setting the resulting int3 z component.</param>
  818. /// <returns>int3 result of the shuffle operation.</returns>
  819. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  820. public static int3 shuffle(int2 left, int2 right, ShuffleComponent x, ShuffleComponent y, ShuffleComponent z)
  821. {
  822. return int3(
  823. select_shuffle_component(left, right, x),
  824. select_shuffle_component(left, right, y),
  825. select_shuffle_component(left, right, z));
  826. }
  827. /// <summary>Returns the result of specified shuffling of the components from two int2 vectors into an int4 vector.</summary>
  828. /// <param name="left">int2 to use as the left argument of the shuffle operation.</param>
  829. /// <param name="right">int2 to use as the right argument of the shuffle operation.</param>
  830. /// <param name="x">The ShuffleComponent to use when setting the resulting int4 x component.</param>
  831. /// <param name="y">The ShuffleComponent to use when setting the resulting int4 y component.</param>
  832. /// <param name="z">The ShuffleComponent to use when setting the resulting int4 z component.</param>
  833. /// <param name="w">The ShuffleComponent to use when setting the resulting int4 w component.</param>
  834. /// <returns>int4 result of the shuffle operation.</returns>
  835. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  836. public static int4 shuffle(int2 left, int2 right, ShuffleComponent x, ShuffleComponent y, ShuffleComponent z, ShuffleComponent w)
  837. {
  838. return int4(
  839. select_shuffle_component(left, right, x),
  840. select_shuffle_component(left, right, y),
  841. select_shuffle_component(left, right, z),
  842. select_shuffle_component(left, right, w));
  843. }
  844. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  845. internal static int select_shuffle_component(int2 a, int2 b, ShuffleComponent component)
  846. {
  847. switch(component)
  848. {
  849. case ShuffleComponent.LeftX:
  850. return a.x;
  851. case ShuffleComponent.LeftY:
  852. return a.y;
  853. case ShuffleComponent.RightX:
  854. return b.x;
  855. case ShuffleComponent.RightY:
  856. return b.y;
  857. default:
  858. throw new System.ArgumentException("Invalid shuffle component: " + component);
  859. }
  860. }
  861. }
  862. }