Recast.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace ET
  4. {
  5. public static class Recast
  6. {
  7. #if UNITY_IPHONE && !UNITY_EDITOR
  8. const string RecastDLL = "__Internal";
  9. #else
  10. const string RecastDLL = "RecastDll";
  11. #endif
  12. public const int MAX_POLYS = 256;
  13. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  14. private static extern IntPtr RecastLoad(int id, byte[] buffer, int n);
  15. public static long RecastLoadLong(int id, byte[] buffer, int n)
  16. {
  17. return RecastLoad(id, buffer, n).ToInt64();
  18. }
  19. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  20. private static extern IntPtr RecastGet(int id);
  21. public static long RecastGetLong(int id)
  22. {
  23. return RecastGet(id).ToInt32();
  24. }
  25. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  26. private static extern void RecastClear();
  27. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  28. private static extern int RecastFind(IntPtr navPtr, float[] extents, float[] startPos, float[] endPos, float[] straightPath);
  29. public static int RecastFind(long navPtr, float[] extents, float[] startPos, float[] endPos, float[] straightPath)
  30. {
  31. return RecastFind(new IntPtr(navPtr), extents, startPos, endPos, straightPath);
  32. }
  33. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  34. private static extern int RecastFindNearestPoint(IntPtr navPtr, float[] extents, float[] pos, float[] nearestPos);
  35. public static int RecastFindNearestPoint(long navPtr, float[] extents, float[] pos, float[] nearestPos)
  36. {
  37. return RecastFindNearestPoint(new IntPtr(navPtr), extents, pos, nearestPos);
  38. }
  39. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  40. private static extern int RecastFindRandomPointAroundCircle(IntPtr navPtr, float[] extents, float[] centerPos, float radius, float[] randomPos);
  41. public static int RecastFindRandomPointAroundCircle(long navPtr, float[] extents, float[] centerPos, float radius, float[] randomPos)
  42. {
  43. return RecastFindRandomPointAroundCircle(new IntPtr(navPtr), extents, centerPos, radius, randomPos);
  44. }
  45. [DllImport(RecastDLL, CallingConvention=CallingConvention.Cdecl)]
  46. private static extern int RecastFindRandomPoint(IntPtr navPtr, float[] randomPos);
  47. public static int RecastFindRandomPoint(long navPtr, float[] randomPos)
  48. {
  49. return RecastFindRandomPoint(new IntPtr(navPtr), randomPos);
  50. }
  51. }
  52. }