fix UNSIGNED_BYTE4 joints

This commit is contained in:
ousttrue 2022-01-13 19:35:03 +09:00
parent 9bf6f45efc
commit 85fb330c8b

View File

@ -122,7 +122,20 @@ namespace VrmLib
}
else
{
throw new Exception($"Stride:{Stride}!= sizeof({typeof(T).Name}:{Marshal.SizeOf(typeof(T))}");
if (typeof(T) == typeof(SkinJoints) && Stride == 4)
{
// 例えば SkinJoints を使う JOINTS_0 は UNSIGNED_BYTE と UNSIGNED_SHORT の2種類がありえる。
fixed (UShort4* p = GetAsUShort4())
{
var nativeArray = new NativeArray<T>(Count, allocator);
UnsafeUtility.MemCpy(nativeArray.GetUnsafePtr(), p, Bytes.Count);
return nativeArray;
}
}
else
{
throw new Exception($"Stride:{Stride}!= sizeof({typeof(T).Name}:{Marshal.SizeOf(typeof(T))}");
}
}
}