No Description
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.

rigid_transform.cs 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using Unity.IL2CPP.CompilerServices;
  4. using static Unity.Mathematics.math;
  5. namespace Unity.Mathematics
  6. {
  7. /// <summary>
  8. /// A rigid transformation type.
  9. /// </summary>
  10. [Il2CppEagerStaticClassConstruction]
  11. [Serializable]
  12. public struct RigidTransform
  13. {
  14. /// <summary>
  15. /// The rotation part of the rigid transformation.
  16. /// </summary>
  17. public quaternion rot;
  18. /// <summary>
  19. /// The translation part of the rigid transformation.
  20. /// </summary>
  21. public float3 pos;
  22. /// <summary>A RigidTransform representing the identity transform.</summary>
  23. public static readonly RigidTransform identity = new RigidTransform(new quaternion(0.0f, 0.0f, 0.0f, 1.0f), new float3(0.0f, 0.0f, 0.0f));
  24. /// <summary>Constructs a RigidTransform from a rotation represented by a unit quaternion and a translation represented by a float3 vector.</summary>
  25. /// <param name="rotation">The quaternion rotation.</param>
  26. /// <param name="translation">The translation vector.</param>
  27. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  28. public RigidTransform(quaternion rotation, float3 translation)
  29. {
  30. this.rot = rotation;
  31. this.pos = translation;
  32. }
  33. /// <summary>Constructs a RigidTransform from a rotation represented by a float3x3 matrix and a translation represented by a float3 vector.</summary>
  34. /// <param name="rotation">The float3x3 rotation matrix.</param>
  35. /// <param name="translation">The translation vector.</param>
  36. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  37. public RigidTransform(float3x3 rotation, float3 translation)
  38. {
  39. this.rot = new quaternion(rotation);
  40. this.pos = translation;
  41. }
  42. /// <summary>Constructs a RigidTransform from a float4x4. Assumes the matrix is orthonormal.</summary>
  43. /// <param name="transform">The float4x4 transformation matrix, must be orthonormal.</param>
  44. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  45. public RigidTransform(float4x4 transform)
  46. {
  47. this.rot = new quaternion(transform);
  48. this.pos = transform.c3.xyz;
  49. }
  50. /// <summary>
  51. /// Returns a RigidTransform representing a rotation around a unit axis by an angle in radians.
  52. /// The rotation direction is clockwise when looking along the rotation axis towards the origin.
  53. /// </summary>
  54. /// <param name="axis">The axis of rotation.</param>
  55. /// <param name="angle">The rotation angle in radians.</param>
  56. /// <returns>The RigidTransform from a rotation axis and angle of rotation.</returns>
  57. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  58. public static RigidTransform AxisAngle(float3 axis, float angle) { return new RigidTransform(quaternion.AxisAngle(axis, angle), float3.zero); }
  59. /// <summary>
  60. /// Returns a RigidTransform constructed by first performing a rotation around the x-axis, then the y-axis and finally the z-axis.
  61. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  62. /// </summary>
  63. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  64. /// <returns>The RigidTransform of the Euler angle transformation in x-y-z order.</returns>
  65. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  66. public static RigidTransform EulerXYZ(float3 xyz) { return new RigidTransform(quaternion.EulerXYZ(xyz), float3.zero); }
  67. /// <summary>
  68. /// Returns a RigidTransform constructed by first performing a rotation around the x-axis, then the z-axis and finally the y-axis.
  69. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  70. /// </summary>
  71. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  72. /// <returns>The RigidTransform of the Euler angle transformation in x-z-y order.</returns>
  73. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  74. public static RigidTransform EulerXZY(float3 xyz) { return new RigidTransform(quaternion.EulerXZY(xyz), float3.zero); }
  75. /// <summary>
  76. /// Returns a RigidTransform constructed by first performing a rotation around the y-axis, then the x-axis and finally the z-axis.
  77. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  78. /// </summary>
  79. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  80. /// <returns>The RigidTransform of the Euler angle transformation in y-x-z order.</returns>
  81. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  82. public static RigidTransform EulerYXZ(float3 xyz) { return new RigidTransform(quaternion.EulerYXZ(xyz), float3.zero); }
  83. /// <summary>
  84. /// Returns a RigidTransform constructed by first performing a rotation around the y-axis, then the z-axis and finally the x-axis.
  85. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  86. /// </summary>
  87. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  88. /// <returns>The RigidTransform of the Euler angle transformation in y-z-x order.</returns>
  89. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  90. public static RigidTransform EulerYZX(float3 xyz) { return new RigidTransform(quaternion.EulerYZX(xyz), float3.zero); }
  91. /// <summary>
  92. /// Returns a RigidTransform constructed by first performing a rotation around the z-axis, then the x-axis and finally the y-axis.
  93. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  94. /// This is the default order rotation order in Unity.
  95. /// </summary>
  96. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  97. /// <returns>The RigidTransform of the Euler angle transformation in z-x-y order.</returns>
  98. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  99. public static RigidTransform EulerZXY(float3 xyz) { return new RigidTransform(quaternion.EulerZXY(xyz), float3.zero); }
  100. /// <summary>
  101. /// Returns a RigidTransform constructed by first performing a rotation around the z-axis, then the y-axis and finally the x-axis.
  102. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  103. /// </summary>
  104. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  105. /// <returns>The RigidTransform of the Euler angle transformation in z-y-x order.</returns>
  106. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  107. public static RigidTransform EulerZYX(float3 xyz) { return new RigidTransform(quaternion.EulerZYX(xyz), float3.zero); }
  108. /// <summary>
  109. /// Returns a RigidTransform constructed by first performing a rotation around the x-axis, then the y-axis and finally the z-axis.
  110. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  111. /// </summary>
  112. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  113. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  114. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  115. /// <returns>The RigidTransform of the Euler angle transformation in x-y-z order.</returns>
  116. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  117. public static RigidTransform EulerXYZ(float x, float y, float z) { return EulerXYZ(float3(x, y, z)); }
  118. /// <summary>
  119. /// Returns a RigidTransform constructed by first performing a rotation around the x-axis, then the z-axis and finally the y-axis.
  120. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  121. /// </summary>
  122. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  123. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  124. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  125. /// <returns>The RigidTransform of the Euler angle transformation in x-z-y order.</returns>
  126. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  127. public static RigidTransform EulerXZY(float x, float y, float z) { return EulerXZY(float3(x, y, z)); }
  128. /// <summary>
  129. /// Returns a RigidTransform constructed by first performing a rotation around the y-axis, then the x-axis and finally the z-axis.
  130. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  131. /// </summary>
  132. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  133. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  134. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  135. /// <returns>The RigidTransform of the Euler angle transformation in y-x-z order.</returns>
  136. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  137. public static RigidTransform EulerYXZ(float x, float y, float z) { return EulerYXZ(float3(x, y, z)); }
  138. /// <summary>
  139. /// Returns a RigidTransform constructed by first performing a rotation around the y-axis, then the z-axis and finally the x-axis.
  140. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  141. /// </summary>
  142. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  143. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  144. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  145. /// <returns>The RigidTransform of the Euler angle transformation in y-z-x order.</returns>
  146. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  147. public static RigidTransform EulerYZX(float x, float y, float z) { return EulerYZX(float3(x, y, z)); }
  148. /// <summary>
  149. /// Returns a RigidTransform constructed by first performing a rotation around the z-axis, then the x-axis and finally the y-axis.
  150. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  151. /// This is the default order rotation order in Unity.
  152. /// </summary>
  153. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  154. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  155. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  156. /// <returns>The RigidTransform of the Euler angle transformation in z-x-y order.</returns>
  157. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  158. public static RigidTransform EulerZXY(float x, float y, float z) { return EulerZXY(float3(x, y, z)); }
  159. /// <summary>
  160. /// Returns a RigidTransform constructed by first performing a rotation around the z-axis, then the y-axis and finally the x-axis.
  161. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  162. /// </summary>
  163. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  164. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  165. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  166. /// <returns>The RigidTransform of the Euler angle transformation in z-y-x order.</returns>
  167. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  168. public static RigidTransform EulerZYX(float x, float y, float z) { return EulerZYX(float3(x, y, z)); }
  169. /// <summary>
  170. /// Returns a RigidTransform constructed by first performing 3 rotations around the principal axes in a given order.
  171. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  172. /// When the rotation order is known at compile time, it is recommended for performance reasons to use specific
  173. /// Euler rotation constructors such as EulerZXY(...).
  174. /// </summary>
  175. /// <param name="xyz">A float3 vector containing the rotation angles around the x-, y- and z-axis measures in radians.</param>
  176. /// <param name="order">The order in which the rotations are applied.</param>
  177. /// <returns>The RigidTransform of the Euler angle transformation in the given rotation order.</returns>
  178. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  179. public static RigidTransform Euler(float3 xyz, RotationOrder order = RotationOrder.ZXY)
  180. {
  181. switch (order)
  182. {
  183. case RotationOrder.XYZ:
  184. return EulerXYZ(xyz);
  185. case RotationOrder.XZY:
  186. return EulerXZY(xyz);
  187. case RotationOrder.YXZ:
  188. return EulerYXZ(xyz);
  189. case RotationOrder.YZX:
  190. return EulerYZX(xyz);
  191. case RotationOrder.ZXY:
  192. return EulerZXY(xyz);
  193. case RotationOrder.ZYX:
  194. return EulerZYX(xyz);
  195. default:
  196. return RigidTransform.identity;
  197. }
  198. }
  199. /// <summary>
  200. /// Returns a RigidTransform constructed by first performing 3 rotations around the principal axes in a given order.
  201. /// All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.
  202. /// When the rotation order is known at compile time, it is recommended for performance reasons to use specific
  203. /// Euler rotation constructors such as EulerZXY(...).
  204. /// </summary>
  205. /// <param name="x">The rotation angle around the x-axis in radians.</param>
  206. /// <param name="y">The rotation angle around the y-axis in radians.</param>
  207. /// <param name="z">The rotation angle around the z-axis in radians.</param>
  208. /// <param name="order">The order in which the rotations are applied.</param>
  209. /// <returns>The RigidTransform of the Euler angle transformation in the given rotation order.</returns>
  210. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  211. public static RigidTransform Euler(float x, float y, float z, RotationOrder order = RotationOrder.Default)
  212. {
  213. return Euler(float3(x, y, z), order);
  214. }
  215. /// <summary>Returns a RigidTransform that rotates around the x-axis by a given number of radians.</summary>
  216. /// <param name="angle">The clockwise rotation angle when looking along the x-axis towards the origin in radians.</param>
  217. /// <returns>The RigidTransform of rotating around the x-axis by the given angle.</returns>
  218. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  219. public static RigidTransform RotateX(float angle)
  220. {
  221. return new RigidTransform(quaternion.RotateX(angle), float3.zero);
  222. }
  223. /// <summary>Returns a RigidTransform that rotates around the y-axis by a given number of radians.</summary>
  224. /// <param name="angle">The clockwise rotation angle when looking along the y-axis towards the origin in radians.</param>
  225. /// <returns>The RigidTransform of rotating around the y-axis by the given angle.</returns>
  226. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  227. public static RigidTransform RotateY(float angle)
  228. {
  229. return new RigidTransform(quaternion.RotateY(angle), float3.zero);
  230. }
  231. /// <summary>Returns a RigidTransform that rotates around the z-axis by a given number of radians.</summary>
  232. /// <param name="angle">The clockwise rotation angle when looking along the z-axis towards the origin in radians.</param>
  233. /// <returns>The RigidTransform of rotating around the z-axis by the given angle.</returns>
  234. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  235. public static RigidTransform RotateZ(float angle)
  236. {
  237. return new RigidTransform(quaternion.RotateZ(angle), float3.zero);
  238. }
  239. /// <summary>Returns a RigidTransform that translates by an amount specified by a float3 vector.</summary>
  240. /// <param name="vector">The translation vector.</param>
  241. /// <returns>The RigidTransform that translates by the given translation vector.</returns>
  242. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  243. public static RigidTransform Translate(float3 vector)
  244. {
  245. return new RigidTransform(quaternion.identity, vector);
  246. }
  247. /// <summary>Returns true if the RigidTransform is equal to a given RigidTransform, false otherwise.</summary>
  248. /// <param name="x">The RigidTransform to compare with.</param>
  249. /// <returns>True if the RigidTransform is equal to the input, false otherwise.</returns>
  250. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  251. public bool Equals(RigidTransform x) { return rot.Equals(x.rot) && pos.Equals(x.pos); }
  252. /// <summary>Returns true if the RigidTransform is equal to a given RigidTransform, false otherwise.</summary>
  253. /// <param name="x">The object to compare with.</param>
  254. /// <returns>True if the RigidTransform is equal to the input, false otherwise.</returns>
  255. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  256. public override bool Equals(object x) { return x is RigidTransform converted && Equals(converted); }
  257. /// <summary>Returns a hash code for the RigidTransform.</summary>
  258. /// <returns>The hash code of the RigidTransform.</returns>
  259. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  260. public override int GetHashCode() { return (int)math.hash(this); }
  261. /// <summary>Returns a string representation of the RigidTransform.</summary>
  262. /// <returns>The string representation of the RigidTransform.</returns>
  263. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  264. public override string ToString()
  265. {
  266. return string.Format("RigidTransform(({0}f, {1}f, {2}f, {3}f), ({4}f, {5}f, {6}f))",
  267. rot.value.x, rot.value.y, rot.value.z, rot.value.w, pos.x, pos.y, pos.z);
  268. }
  269. /// <summary>Returns a string representation of the RigidTransform using a specified format and culture-specific format information.</summary>
  270. /// <param name="format">The format string.</param>
  271. /// <param name="formatProvider">The format provider to use during formatting.</param>
  272. /// <returns>The formatted string representation of the RigidTransform.</returns>
  273. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  274. public string ToString(string format, IFormatProvider formatProvider)
  275. {
  276. return string.Format("float4x4(({0}f, {1}f, {2}f, {3}f), ({4}f, {5}f, {6}f))",
  277. rot.value.x.ToString(format, formatProvider),
  278. rot.value.y.ToString(format, formatProvider),
  279. rot.value.z.ToString(format, formatProvider),
  280. rot.value.w.ToString(format, formatProvider),
  281. pos.x.ToString(format, formatProvider),
  282. pos.y.ToString(format, formatProvider),
  283. pos.z.ToString(format, formatProvider));
  284. }
  285. }
  286. public static partial class math
  287. {
  288. /// <summary>Returns a RigidTransform constructed from a rotation represented by a unit quaternion and a translation represented by a float3 vector.</summary>
  289. /// <param name="rot">The quaternion rotation.</param>
  290. /// <param name="pos">The translation vector.</param>
  291. /// <returns>The RigidTransform of the given rotation quaternion and translation vector.</returns>
  292. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  293. public static RigidTransform RigidTransform(quaternion rot, float3 pos) { return new RigidTransform(rot, pos); }
  294. /// <summary>Returns a RigidTransform constructed from a rotation represented by a float3x3 rotation matrix and a translation represented by a float3 vector.</summary>
  295. /// <param name="rotation">The float3x3 rotation matrix.</param>
  296. /// <param name="translation">The translation vector.</param>
  297. /// <returns>The RigidTransform of the given rotation matrix and translation vector.</returns>
  298. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  299. public static RigidTransform RigidTransform(float3x3 rotation, float3 translation) { return new RigidTransform(rotation, translation); }
  300. /// <summary>Returns a RigidTransform constructed from a rotation represented by a float3x3 matrix and a translation represented by a float3 vector.</summary>
  301. /// <param name="transform">The float4x4 transformation matrix.</param>
  302. /// <returns>The RigidTransform of the given float4x4 transformation matrix.</returns>
  303. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  304. public static RigidTransform RigidTransform(float4x4 transform) { return new RigidTransform(transform); }
  305. /// <summary>Returns the inverse of a RigidTransform.</summary>
  306. /// <param name="t">The RigidTransform to invert.</param>
  307. /// <returns>The inverse RigidTransform.</returns>
  308. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  309. public static RigidTransform inverse(RigidTransform t)
  310. {
  311. quaternion invRotation = inverse(t.rot);
  312. float3 invTranslation = mul(invRotation, -t.pos);
  313. return new RigidTransform(invRotation, invTranslation);
  314. }
  315. /// <summary>Returns the result of transforming the RigidTransform b by the RigidTransform a.</summary>
  316. /// <param name="a">The RigidTransform on the left.</param>
  317. /// <param name="b">The RigidTransform on the right.</param>
  318. /// <returns>The RigidTransform of a transforming b.</returns>
  319. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  320. public static RigidTransform mul(RigidTransform a, RigidTransform b)
  321. {
  322. return new RigidTransform(mul(a.rot, b.rot), mul(a.rot, b.pos) + a.pos);
  323. }
  324. /// <summary>Returns the result of transforming a float4 homogeneous coordinate by a RigidTransform.</summary>
  325. /// <param name="a">The RigidTransform.</param>
  326. /// <param name="pos">The position to be transformed.</param>
  327. /// <returns>The transformed position.</returns>
  328. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  329. public static float4 mul(RigidTransform a, float4 pos)
  330. {
  331. return float4(mul(a.rot, pos.xyz) + a.pos * pos.w, pos.w);
  332. }
  333. /// <summary>Returns the result of rotating a float3 vector by a RigidTransform.</summary>
  334. /// <param name="a">The RigidTransform.</param>
  335. /// <param name="dir">The direction vector to rotate.</param>
  336. /// <returns>The rotated direction vector.</returns>
  337. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  338. public static float3 rotate(RigidTransform a, float3 dir)
  339. {
  340. return mul(a.rot, dir);
  341. }
  342. /// <summary>Returns the result of transforming a float3 point by a RigidTransform.</summary>
  343. /// <param name="a">The RigidTransform.</param>
  344. /// <param name="pos">The position to transform.</param>
  345. /// <returns>The transformed position.</returns>
  346. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  347. public static float3 transform(RigidTransform a, float3 pos)
  348. {
  349. return mul(a.rot, pos) + a.pos;
  350. }
  351. /// <summary>Returns a uint hash code of a RigidTransform.</summary>
  352. /// <param name="t">The RigidTransform to hash.</param>
  353. /// <returns>The hash code of the input RigidTransform</returns>
  354. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  355. public static uint hash(RigidTransform t)
  356. {
  357. return hash(t.rot) + 0xC5C5394Bu * hash(t.pos);
  358. }
  359. /// <summary>
  360. /// Returns a uint4 vector hash code of a RigidTransform.
  361. /// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
  362. /// that are only reduced to a narrow uint hash at the very end instead of at every step.
  363. /// </summary>
  364. /// <param name="t">The RigidTransform to hash.</param>
  365. /// <returns>The uint4 wide hash code.</returns>
  366. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  367. public static uint4 hashwide(RigidTransform t)
  368. {
  369. return hashwide(t.rot) + 0xC5C5394Bu * hashwide(t.pos).xyzz;
  370. }
  371. }
  372. }