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.
31 lines
741 B
31 lines
741 B
|
3 years ago
|
using Unity.Collections.LowLevel.Unsafe;
|
||
|
|
|
||
|
|
namespace GameCore.LowLevel
|
||
|
|
{
|
||
|
19 hours ago
|
public static class LowLevelUtility
|
||
|
3 years ago
|
{
|
||
|
19 hours ago
|
public static int HashCombine(int h1, int h2)
|
||
|
|
{
|
||
|
|
var hash = h1;
|
||
|
|
hash = (hash * 397) ^ h2;
|
||
|
|
return hash;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static int HashCombine(int h1, int h2, int h3)
|
||
|
|
{
|
||
|
|
return HashCombine(HashCombine(h1, h2), h3);
|
||
|
|
}
|
||
|
|
|
||
|
3 years ago
|
public static int OffsetOf<T, F>()
|
||
|
|
{
|
||
|
|
var fields = typeof(T).GetFields();
|
||
|
|
foreach (var f in fields)
|
||
|
|
{
|
||
|
|
if (f.DeclaringType == typeof(F))
|
||
|
|
return UnsafeUtility.GetFieldOffset(f);
|
||
|
|
}
|
||
|
|
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|