public unsafe static void ComputeHash128 <T>(ref T value, ref Hash128 hash) where T : struct { void * data = UnsafeUtility.AddressOf <T>(ref value); ulong dataSize = (ulong)((long)UnsafeUtility.SizeOf <T>()); Hash128 *hash2 = (Hash128 *)UnsafeUtility.AddressOf <Hash128>(ref hash); HashUnsafeUtilities.ComputeHash128(data, dataSize, hash2); }
public unsafe static void ComputeHash128(void *data, ulong dataSize, Hash128 *hash) { ulong u64_ = hash->u64_0; ulong u64_2 = hash->u64_1; HashUnsafeUtilities.ComputeHash128(data, dataSize, &u64_, &u64_2); *hash = new Hash128(u64_, u64_2); }
public static unsafe void ComputeHash128 <T>(ref T value, ref Hash128 hash) where T : struct { var data = UnsafeUtility.AddressOf(ref value); var dataSize = (ulong)UnsafeUtility.SizeOf <T>(); var hashPtr = (Hash128 *)UnsafeUtility.AddressOf(ref hash); HashUnsafeUtilities.ComputeHash128(data, dataSize, hashPtr); }
public static unsafe void ComputeHash128(byte[] value, ref Hash128 hash) { fixed(byte *data = &value[0]) { var dataSize = (ulong)value.Length; var hashPtr = (Hash128 *)UnsafeUtility.AddressOf(ref hash); HashUnsafeUtilities.ComputeHash128(data, dataSize, hashPtr); } }
public unsafe static void ComputeHash128(byte[] value, ref Hash128 hash) { fixed(byte *ptr = &value[0]) { byte * data = ptr; ulong dataSize = (ulong)((long)value.Length); Hash128 *hash2 = (Hash128 *)UnsafeUtility.AddressOf <Hash128>(ref hash); HashUnsafeUtilities.ComputeHash128((void *)data, dataSize, hash2); } }
public static void AppendHash( ref Hash128 inHash, ref Hash128 outHash ) { unsafe { fixed(Hash128 *outH = &outHash) fixed(Hash128 * message = &inHash) { HashUnsafeUtilities.ComputeHash128(message, (ulong)sizeof(Hash128), outH); } } }
public unsafe static void AppendHash(ref Hash128 inHash, ref Hash128 outHash) { fixed(Hash128 *ptr = &outHash) { Hash128 *hash = ptr; fixed(Hash128 *ptr2 = &inHash) { Hash128 *data = ptr2; HashUnsafeUtilities.ComputeHash128((void *)data, (ulong)((long)sizeof(Hash128)), hash); } } }
public unsafe static void QuantisedVectorHash(ref Vector3 value, ref Hash128 hash) { fixed(Hash128 *ptr = &hash) { Hash128 *hash2 = ptr; int * ptr2 = stackalloc int[3]; for (int i = 0; i < 3; i++) { ptr2[i] = (int)(value[i] * 1000f + 0.5f); } HashUnsafeUtilities.ComputeHash128((void *)ptr2, 12uL, hash2); } }
public unsafe static void QuantisedMatrixHash(ref Matrix4x4 value, ref Hash128 hash) { fixed(Hash128 *ptr = &hash) { Hash128 *hash2 = ptr; int * ptr2 = stackalloc int[16]; for (int i = 0; i < 16; i++) { ptr2[i] = (int)(value[i] * 1000f + 0.5f); } HashUnsafeUtilities.ComputeHash128((void *)ptr2, 64uL, hash2); } }
public static void QuantisedVectorHash(ref Vector3 value, ref Hash128 hash) { unsafe { fixed(Hash128 *h = &hash) { // Transform matrix. int *quantisedVector = stackalloc int[3]; for (int i = 0; i < 3; ++i) { quantisedVector[i] = (int)((value[i] * 1000) + .5f); } HashUnsafeUtilities.ComputeHash128(quantisedVector, sizeof(int) * 3, h); } } }
public static void QuantisedMatrixHash(ref Matrix4x4 value, ref Hash128 hash) { unsafe { fixed(Hash128 *h = &hash) { // Transform matrix. int *quantisedMatrix = stackalloc int[16]; for (int i = 0; i < 16; ++i) { quantisedMatrix[i] = (int)((value[i] * 1000) + .5f); } HashUnsafeUtilities.ComputeHash128(quantisedMatrix, sizeof(int) * 16, h); } } }