Implement safe ModelAnimation
This commit is contained in:
parent
5a198187ec
commit
43bf3d04de
2 changed files with 39 additions and 12 deletions
|
|
@ -6,6 +6,7 @@ using System.Security;
|
|||
using System.Text;
|
||||
using System.Text.Unicode;
|
||||
using System.Xml;
|
||||
using Microsoft.Toolkit.HighPerformance;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
|
|
@ -2001,7 +2002,25 @@ namespace Raylib_cs
|
|||
|
||||
/// <summary>Load model animations from file</summary>
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ModelAnimation* LoadModelAnimations(string fileName, ref int animsCount);
|
||||
public static extern ModelAnimation* LoadModelAnimations(byte* fileName, int* animsCount);
|
||||
|
||||
public static ReadOnlySpan<ModelAnimation> LoadModelAnimations(Utf8String fileName, ref int animsCount)
|
||||
{
|
||||
fixed (byte* p1 = fileName)
|
||||
{
|
||||
fixed (int* p2 = &animsCount)
|
||||
{
|
||||
var model = LoadModelAnimations(p1, p2);
|
||||
|
||||
if ((IntPtr)model == IntPtr.Zero)
|
||||
{
|
||||
throw new ApplicationException("Failed to load animation");
|
||||
}
|
||||
|
||||
return new ReadOnlySpan<ModelAnimation>(model, animsCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Update model animation pose</summary>
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue