FloatingArrays.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Numerics;
  5. using System.Collections;
  6. using System.Linq;
  7. namespace SharpGLTF.Memory
  8. {
  9. using BYTES = ArraySegment<Byte>;
  10. using ENCODING = Schema2.ComponentType;
  11. /// <summary>
  12. /// Wraps a <see cref="ArraySegment{Byte}"/> containing encoded floating point values
  13. /// </summary>
  14. struct FloatingAccessor
  15. {
  16. #region constructors
  17. public FloatingAccessor(BYTES data, int byteOffset, int itemsCount, int byteStride, int dimensions, ENCODING encoding, Boolean normalized)
  18. {
  19. this._Data = data.Slice(byteOffset);
  20. this._ItemCount = 0;
  21. this._Getter = null;
  22. this._Setter = null;
  23. var len = encoding.ByteLength();
  24. this._ByteStride = Math.Max(byteStride, len * dimensions);
  25. this._ValueStride = len;
  26. _ItemCount = _Data.Count / _ByteStride;
  27. if ((_Data.Count % _ByteStride) >= len * dimensions) ++_ItemCount;
  28. _ItemCount = Math.Min(itemsCount, _ItemCount);
  29. if (encoding == ENCODING.FLOAT)
  30. {
  31. this._Setter = this._SetValue<Single>;
  32. this._Getter = this._GetValue<Single>;
  33. }
  34. else
  35. {
  36. if (normalized)
  37. {
  38. switch (encoding)
  39. {
  40. case ENCODING.BYTE:
  41. {
  42. this._Setter = this._SetNormalizedS8;
  43. this._Getter = this._GetNormalizedS8;
  44. break;
  45. }
  46. case ENCODING.UNSIGNED_BYTE:
  47. {
  48. this._Setter = this._SetNormalizedU8;
  49. this._Getter = this._GetNormalizedU8;
  50. break;
  51. }
  52. case ENCODING.SHORT:
  53. {
  54. this._Setter = this._SetNormalizedS16;
  55. this._Getter = this._GetNormalizedS16;
  56. break;
  57. }
  58. case ENCODING.UNSIGNED_SHORT:
  59. {
  60. this._Setter = this._SetNormalizedU16;
  61. this._Getter = this._GetNormalizedU16;
  62. break;
  63. }
  64. default: throw new ArgumentException(nameof(encoding));
  65. }
  66. }
  67. else
  68. {
  69. switch (encoding)
  70. {
  71. case ENCODING.BYTE:
  72. {
  73. this._Setter = this._SetValueS8;
  74. this._Getter = this._GetValueS8;
  75. break;
  76. }
  77. case ENCODING.UNSIGNED_BYTE:
  78. {
  79. this._Setter = this._SetValueU8;
  80. this._Getter = this._GetValueU8;
  81. break;
  82. }
  83. case ENCODING.SHORT:
  84. {
  85. this._Setter = this._SetValueS16;
  86. this._Getter = this._GetValueS16;
  87. break;
  88. }
  89. case ENCODING.UNSIGNED_SHORT:
  90. {
  91. this._Setter = this._SetValueU16;
  92. this._Getter = this._GetValueU16;
  93. break;
  94. }
  95. case ENCODING.UNSIGNED_INT:
  96. {
  97. this._Setter = this._SetValueU32;
  98. this._Getter = this._GetValueU32;
  99. break;
  100. }
  101. case ENCODING.FLOAT:
  102. break;
  103. default: throw new ArgumentException(nameof(encoding));
  104. }
  105. }
  106. }
  107. }
  108. #endregion
  109. #region encoding / decoding
  110. private Single _GetValueU8(int byteOffset) { return _GetValue<Byte>(byteOffset); }
  111. private void _SetValueU8(int byteOffset, Single value) { _SetValue<Byte>(byteOffset, (Byte)value); }
  112. private Single _GetValueS8(int byteOffset) { return _GetValue<SByte>(byteOffset); }
  113. private void _SetValueS8(int byteOffset, Single value) { _SetValue<SByte>(byteOffset, (SByte)value); }
  114. private Single _GetValueU16(int byteOffset) { return _GetValue<UInt16>(byteOffset); }
  115. private void _SetValueU16(int byteOffset, Single value) { _SetValue<UInt16>(byteOffset, (UInt16)value); }
  116. private Single _GetValueS16(int byteOffset) { return _GetValue<Int16>(byteOffset); }
  117. private void _SetValueS16(int byteOffset, Single value) { _SetValue<Int16>(byteOffset, (Int16)value); }
  118. private Single _GetValueU32(int byteOffset) { return _GetValue<UInt32>(byteOffset); }
  119. private void _SetValueU32(int byteOffset, Single value) { _SetValue<UInt32>(byteOffset, (UInt32)value); }
  120. private Single _GetNormalizedU8(int byteOffset) { return _GetValueU8(byteOffset) / 255.0f; }
  121. private void _SetNormalizedU8(int byteOffset, Single value) { _SetValueU8(byteOffset, value * 255.0f); }
  122. private Single _GetNormalizedS8(int byteOffset) { return Math.Max(_GetValueS8(byteOffset) / 127.0f, -1); }
  123. private void _SetNormalizedS8(int byteOffset, Single value) { _SetValueS8(byteOffset, (Single)Math.Round(value * 127.0f)); }
  124. private Single _GetNormalizedU16(int byteOffset) { return _GetValueU16(byteOffset) / 65535.0f; }
  125. private void _SetNormalizedU16(int byteOffset, Single value) { _SetValueU16(byteOffset, value * 65535.0f); }
  126. private Single _GetNormalizedS16(int byteOffset) { return Math.Max(_GetValueS16(byteOffset) / 32767.0f, -1); }
  127. private void _SetNormalizedS16(int byteOffset, Single value) { _SetValueS16(byteOffset, (Single)Math.Round(value * 32767.0f)); }
  128. private T _GetValue<T>(int byteOffset)
  129. where T : unmanaged
  130. {
  131. return System.Runtime.InteropServices.MemoryMarshal.Read<T>(_Data.AsSpan(byteOffset));
  132. }
  133. private void _SetValue<T>(int byteOffset, T value)
  134. where T : unmanaged
  135. {
  136. System.Runtime.InteropServices.MemoryMarshal.Write<T>(_Data.AsSpan(byteOffset), ref value);
  137. }
  138. #endregion
  139. #region data
  140. delegate Single _GetterCallback(int byteOffset);
  141. delegate void _SetterCallback(int byteOffset, Single value);
  142. private readonly BYTES _Data;
  143. private readonly int _ByteStride;
  144. private readonly int _ValueStride;
  145. private readonly int _ItemCount;
  146. private readonly _GetterCallback _Getter;
  147. private readonly _SetterCallback _Setter;
  148. #endregion
  149. #region API
  150. public int ByteLength => _Data.Count;
  151. public int Count => _ItemCount;
  152. public Single this[int index]
  153. {
  154. get => _Getter(index * _ByteStride);
  155. set => _Setter(index * _ByteStride, value);
  156. }
  157. public Single this[int rowIndex, int subIndex]
  158. {
  159. get => _Getter((rowIndex * _ByteStride) + (subIndex * _ValueStride));
  160. set => _Setter((rowIndex * _ByteStride) + (subIndex * _ValueStride), value);
  161. }
  162. #endregion
  163. }
  164. /// <summary>
  165. /// Wraps an encoded byte array and exposes it as a collection of Single Scalar values
  166. /// </summary>
  167. [System.Diagnostics.DebuggerDisplay("Scalar Accessor {Count}")]
  168. public struct ScalarArray : IEncodedArray<Single>
  169. {
  170. #region constructors
  171. public ScalarArray(Byte[] data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  172. : this(new BYTES(data), 0, int.MaxValue, byteStride, encoding, normalized) { }
  173. public ScalarArray(BYTES data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  174. : this(data, 0, int.MaxValue, byteStride, encoding, normalized) { }
  175. public ScalarArray(BYTES data, int byteOffset, int count, int byteStride, ENCODING encoding, Boolean normalized)
  176. {
  177. _Accesor = new FloatingAccessor(data, byteOffset, count, byteStride, 1, encoding, normalized);
  178. }
  179. #endregion
  180. #region data
  181. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  182. private FloatingAccessor _Accesor;
  183. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
  184. private Single[] _DebugItems => this.ToArray();
  185. #endregion
  186. #region API
  187. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  188. public int Count => _Accesor.Count;
  189. public Single this[int index]
  190. {
  191. get => _Accesor[index, 0];
  192. set => _Accesor[index, 0] = value;
  193. }
  194. public void CopyTo(ArraySegment<Single> dst) { EncodedArrayUtils.Copy<Single>(this, dst); }
  195. public IEnumerator<Single> GetEnumerator() { return new EncodedArrayEnumerator<Single>(this); }
  196. IEnumerator IEnumerable.GetEnumerator() { return new EncodedArrayEnumerator<Single>(this); }
  197. public (Single, Single) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
  198. public IEncodedArray<Vector4> AsVector4() { return new _MapScalarToVector4(this); }
  199. #endregion
  200. }
  201. /// <summary>
  202. /// Wraps an encoded byte array and exposes it as a collection of Vector2 values
  203. /// </summary>
  204. [System.Diagnostics.DebuggerDisplay("Vector2 Accessor {Count}")]
  205. public struct Vector2Array : IEncodedArray<Vector2>
  206. {
  207. #region constructors
  208. public Vector2Array(Byte[] data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  209. : this(new BYTES(data), 0, int.MaxValue, byteStride, encoding, normalized) { }
  210. public Vector2Array(BYTES data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  211. : this(data, 0, int.MaxValue, byteStride, encoding, normalized) { }
  212. public Vector2Array(BYTES data, int byteOffset, int count, int byteStride, ENCODING encoding, Boolean normalized)
  213. {
  214. _Accesor = new FloatingAccessor(data, byteOffset, count, byteStride, 2, encoding, normalized);
  215. }
  216. #endregion
  217. #region data
  218. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  219. private FloatingAccessor _Accesor;
  220. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
  221. private Vector2[] _DebugItems => this.ToArray();
  222. #endregion
  223. #region API
  224. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  225. public int Count => _Accesor.Count;
  226. public Vector2 this[int index]
  227. {
  228. get
  229. {
  230. return new Vector2(_Accesor[index, 0], _Accesor[index, 1]);
  231. }
  232. set
  233. {
  234. _Accesor[index, 0] = value.X;
  235. _Accesor[index, 1] = value.Y;
  236. }
  237. }
  238. public void CopyTo(ArraySegment<Vector2> dst) { EncodedArrayUtils.Copy<Vector2>(this, dst); }
  239. public IEnumerator<Vector2> GetEnumerator() { return new EncodedArrayEnumerator<Vector2>(this); }
  240. IEnumerator IEnumerable.GetEnumerator() { return new EncodedArrayEnumerator<Vector2>(this); }
  241. public (Vector2, Vector2) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
  242. public IEncodedArray<Vector4> AsVector4() { return new _MapVector2ToVector4(this); }
  243. #endregion
  244. }
  245. /// <summary>
  246. /// Wraps an encoded byte array and exposes it as a collection of Vector3 values
  247. /// </summary>
  248. [System.Diagnostics.DebuggerDisplay("Vector3 Accessor {Count}")]
  249. public struct Vector3Array : IEncodedArray<Vector3>
  250. {
  251. #region constructors
  252. public Vector3Array(Byte[] data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  253. : this(new BYTES(data), 0, int.MaxValue, byteStride, encoding, normalized) { }
  254. public Vector3Array(BYTES data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  255. : this(data, 0, int.MaxValue, byteStride, encoding, normalized) { }
  256. public Vector3Array(BYTES data, int byteOffset, int count, int byteStride, ENCODING encoding, Boolean normalized)
  257. {
  258. _Accesor = new FloatingAccessor(data, byteOffset, count, byteStride, 3, encoding, normalized);
  259. }
  260. #endregion
  261. #region data
  262. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  263. private FloatingAccessor _Accesor;
  264. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
  265. private Vector3[] _DebugItems => this.ToArray();
  266. #endregion
  267. #region API
  268. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  269. public int Count => _Accesor.Count;
  270. public Vector3 this[int index]
  271. {
  272. get
  273. {
  274. return new Vector3(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2]);
  275. }
  276. set
  277. {
  278. _Accesor[index, 0] = value.X;
  279. _Accesor[index, 1] = value.Y;
  280. _Accesor[index, 2] = value.Z;
  281. }
  282. }
  283. public void CopyTo(ArraySegment<Vector3> dst) { EncodedArrayUtils.Copy<Vector3>(this, dst); }
  284. public IEnumerator<Vector3> GetEnumerator() { return new EncodedArrayEnumerator<Vector3>(this); }
  285. IEnumerator IEnumerable.GetEnumerator() { return new EncodedArrayEnumerator<Vector3>(this); }
  286. public (Vector3, Vector3) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
  287. public IEncodedArray<Vector4> AsVector4() { return new _MapVector3ToVector4(this); }
  288. #endregion
  289. }
  290. /// <summary>
  291. /// Wraps an encoded byte array and exposes it as a collection of Vector4 values
  292. /// </summary>
  293. [System.Diagnostics.DebuggerDisplay("Vector4 Accessor {Count}")]
  294. public struct Vector4Array : IEncodedArray<Vector4>
  295. {
  296. #region constructors
  297. public Vector4Array(Byte[] data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  298. : this(new BYTES(data), 0, int.MaxValue, byteStride, encoding, normalized) { }
  299. public Vector4Array(BYTES data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  300. : this(data, 0, int.MaxValue, byteStride, encoding, normalized) { }
  301. public Vector4Array(BYTES data, int byteOffset, int count, int byteStride, ENCODING encoding, Boolean normalized)
  302. {
  303. _Accesor = new FloatingAccessor(data, byteOffset, count, byteStride, 4, encoding, normalized);
  304. }
  305. #endregion
  306. #region data
  307. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  308. private FloatingAccessor _Accesor;
  309. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
  310. private Vector4[] _DebugItems => this.ToArray();
  311. #endregion
  312. #region API
  313. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  314. public int Count => _Accesor.Count;
  315. public Vector4 this[int index]
  316. {
  317. get
  318. {
  319. return new Vector4(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3]);
  320. }
  321. set
  322. {
  323. _Accesor[index, 0] = value.X;
  324. _Accesor[index, 1] = value.Y;
  325. _Accesor[index, 2] = value.Z;
  326. _Accesor[index, 3] = value.W;
  327. }
  328. }
  329. public void CopyTo(ArraySegment<Vector4> dst) { EncodedArrayUtils.Copy<Vector4>(this, dst); }
  330. public IEnumerator<Vector4> GetEnumerator() { return new EncodedArrayEnumerator<Vector4>(this); }
  331. IEnumerator IEnumerable.GetEnumerator() { return new EncodedArrayEnumerator<Vector4>(this); }
  332. public (Vector4, Vector4) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
  333. public IEncodedArray<Vector4> AsVector4() { return this; }
  334. #endregion
  335. }
  336. /// <summary>
  337. /// Wraps an encoded byte array and exposes it as a collection of Quaternion values
  338. /// </summary>
  339. [System.Diagnostics.DebuggerDisplay("Quaternion Accessor {Count}")]
  340. public struct QuaternionArray : IEncodedArray<Quaternion>
  341. {
  342. #region constructors
  343. public QuaternionArray(Byte[] data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  344. : this(new BYTES(data), 0, int.MaxValue, byteStride, encoding, normalized) { }
  345. public QuaternionArray(BYTES data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  346. : this(data, 0, int.MaxValue, byteStride, encoding, normalized) { }
  347. public QuaternionArray(BYTES data, int byteOffset, int count, int byteStride, ENCODING encoding, Boolean normalized)
  348. {
  349. _Accesor = new FloatingAccessor(data, byteOffset, count, byteStride, 4, encoding, normalized);
  350. }
  351. #endregion
  352. #region data
  353. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  354. private FloatingAccessor _Accesor;
  355. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
  356. private Quaternion[] _DebugItems => this.ToArray();
  357. #endregion
  358. #region API
  359. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  360. public int Count => _Accesor.Count;
  361. public Quaternion this[int index]
  362. {
  363. get
  364. {
  365. return new Quaternion(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3]);
  366. }
  367. set
  368. {
  369. _Accesor[index, 0] = value.X;
  370. _Accesor[index, 1] = value.Y;
  371. _Accesor[index, 2] = value.Z;
  372. _Accesor[index, 3] = value.W;
  373. }
  374. }
  375. public void CopyTo(ArraySegment<Quaternion> dst) { EncodedArrayUtils.Copy<Quaternion>(this, dst); }
  376. public IEnumerator<Quaternion> GetEnumerator() { return new EncodedArrayEnumerator<Quaternion>(this); }
  377. IEnumerator IEnumerable.GetEnumerator() { return new EncodedArrayEnumerator<Quaternion>(this); }
  378. public (Quaternion, Quaternion) GetBounds() { throw new NotImplementedException(); }
  379. public IEncodedArray<Vector4> AsVector4() { return new _MapQuaternionToVector4(this); }
  380. #endregion
  381. }
  382. /// <summary>
  383. /// Wraps an encoded byte array and exposes it as a collection of Matrix4x4 values
  384. /// </summary>
  385. [System.Diagnostics.DebuggerDisplay("MAtrix4x4 Accessor {Count}")]
  386. public struct Matrix4x4Array : IEncodedArray<Matrix4x4>
  387. {
  388. #region constructors
  389. public Matrix4x4Array(Byte[] data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  390. : this(new BYTES(data), 0, int.MaxValue, byteStride, encoding, normalized) { }
  391. public Matrix4x4Array(BYTES data, int byteStride = 0, ENCODING encoding = ENCODING.FLOAT, Boolean normalized = false)
  392. : this(data, 0, int.MaxValue, byteStride, encoding, normalized) { }
  393. public Matrix4x4Array(BYTES data, int byteOffset, int count, int byteStride, ENCODING encoding, Boolean normalized)
  394. {
  395. _Accesor = new FloatingAccessor(data, byteOffset, count, byteStride, 16, encoding, normalized);
  396. }
  397. #endregion
  398. #region data
  399. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  400. private FloatingAccessor _Accesor;
  401. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
  402. private Matrix4x4[] _DebugItems => this.ToArray();
  403. #endregion
  404. #region API
  405. [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
  406. public int Count => _Accesor.Count;
  407. public Matrix4x4 this[int index]
  408. {
  409. get
  410. {
  411. return new Matrix4x4
  412. (
  413. _Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3],
  414. _Accesor[index, 4], _Accesor[index, 5], _Accesor[index, 6], _Accesor[index, 7],
  415. _Accesor[index, 8], _Accesor[index, 9], _Accesor[index, 10], _Accesor[index, 11],
  416. _Accesor[index, 12], _Accesor[index, 13], _Accesor[index, 14], _Accesor[index, 15]
  417. );
  418. }
  419. set
  420. {
  421. _Accesor[index, 0] = value.M11;
  422. _Accesor[index, 1] = value.M12;
  423. _Accesor[index, 2] = value.M13;
  424. _Accesor[index, 3] = value.M14;
  425. _Accesor[index, 4] = value.M21;
  426. _Accesor[index, 5] = value.M22;
  427. _Accesor[index, 6] = value.M23;
  428. _Accesor[index, 7] = value.M24;
  429. _Accesor[index, 8] = value.M31;
  430. _Accesor[index, 9] = value.M32;
  431. _Accesor[index, 10] = value.M33;
  432. _Accesor[index, 11] = value.M34;
  433. _Accesor[index, 12] = value.M41;
  434. _Accesor[index, 13] = value.M42;
  435. _Accesor[index, 14] = value.M43;
  436. _Accesor[index, 15] = value.M44;
  437. }
  438. }
  439. public void CopyTo(ArraySegment<Matrix4x4> dst) { EncodedArrayUtils.Copy<Matrix4x4>(this, dst); }
  440. public IEnumerator<Matrix4x4> GetEnumerator() { return new EncodedArrayEnumerator<Matrix4x4>(this); }
  441. IEnumerator IEnumerable.GetEnumerator() { return new EncodedArrayEnumerator<Matrix4x4>(this); }
  442. public (Matrix4x4, Matrix4x4) GetBounds() { throw new NotImplementedException(); }
  443. #endregion
  444. }
  445. }