diff --git a/src/DotRecast.Core/Loader.cs b/src/DotRecast.Core/Loader.cs index 67d6fdc..1d2ed8e 100644 --- a/src/DotRecast.Core/Loader.cs +++ b/src/DotRecast.Core/Loader.cs @@ -6,7 +6,7 @@ namespace DotRecast.Core { public static byte[] ToBytes(string filename) { - var filepath = ToRPath(filename); + var filepath = FindParentPath(filename); using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); @@ -14,7 +14,7 @@ namespace DotRecast.Core return buffer; } - public static string ToRPath(string filename) + public static string FindParentPath(string filename) { string filePath = Path.Combine("resources", filename); for (int i = 0; i < 10; ++i) diff --git a/src/DotRecast.Core/RcVec2f.cs b/src/DotRecast.Core/RcVec2f.cs index 192b2fb..53599e0 100644 --- a/src/DotRecast.Core/RcVec2f.cs +++ b/src/DotRecast.Core/RcVec2f.cs @@ -10,6 +10,7 @@ namespace DotRecast.Core public static RcVec2f Zero { get; } = new RcVec2f { x = 0, y = 0 }; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public float Get(int idx) { if (0 == idx) @@ -36,6 +37,7 @@ namespace DotRecast.Core y.Equals(other.y); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public override int GetHashCode() { int hash = x.GetHashCode(); @@ -55,6 +57,7 @@ namespace DotRecast.Core return !left.Equals(right); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string ToString() { return $"{x}, {y}"; diff --git a/src/DotRecast.Core/RcVec3f.cs b/src/DotRecast.Core/RcVec3f.cs index 7abb28d..6f63870 100644 --- a/src/DotRecast.Core/RcVec3f.cs +++ b/src/DotRecast.Core/RcVec3f.cs @@ -48,6 +48,7 @@ namespace DotRecast.Core return new RcVec3f(x, y, z); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public RcVec3f(float x, float y, float z) { this.x = x; @@ -55,6 +56,7 @@ namespace DotRecast.Core this.z = z; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public RcVec3f(float f) { x = f; @@ -63,6 +65,7 @@ namespace DotRecast.Core } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public RcVec3f(float[] f) { x = f[0]; @@ -76,6 +79,7 @@ namespace DotRecast.Core set => SetElement(index, value); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public float GetElement(int index) { switch (index) @@ -87,6 +91,7 @@ namespace DotRecast.Core } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetElement(int index, float value) { switch (index) @@ -202,6 +207,7 @@ namespace DotRecast.Core } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public override int GetHashCode() { int hash = x.GetHashCode(); diff --git a/src/DotRecast.Detour.Crowd/DtProximityGrid.cs b/src/DotRecast.Detour.Crowd/DtProximityGrid.cs index d69ca8d..31a5d58 100644 --- a/src/DotRecast.Detour.Crowd/DtProximityGrid.cs +++ b/src/DotRecast.Detour.Crowd/DtProximityGrid.cs @@ -21,6 +21,7 @@ freely, subject to the following restrictions: using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; namespace DotRecast.Detour.Crowd { @@ -37,6 +38,7 @@ namespace DotRecast.Detour.Crowd _items = new Dictionary>(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long CombineKey(int x, int y) { uint ux = (uint)x; @@ -44,6 +46,7 @@ namespace DotRecast.Detour.Crowd return ((long)ux << 32) | uy; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DecomposeKey(long key, out int x, out int y) { uint ux = (uint)(key >> 32); diff --git a/src/DotRecast.Recast.Demo/Program.cs b/src/DotRecast.Recast.Demo/Program.cs index 48a58db..bd1f69c 100644 --- a/src/DotRecast.Recast.Demo/Program.cs +++ b/src/DotRecast.Recast.Demo/Program.cs @@ -37,7 +37,7 @@ public static class Program private static void InitializeWorkingDirectory() { - var path = Loader.ToRPath("dungeon.obj"); + var path = Loader.FindParentPath("dungeon.obj"); path = Path.GetDirectoryName(path); if (!string.IsNullOrEmpty(path)) { diff --git a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs index 907144a..1918130 100644 --- a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs +++ b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs @@ -81,7 +81,7 @@ public class UnityAStarPathfindingImporterTest private DtNavMesh LoadNavMesh(string filename) { - var filepath = Loader.ToRPath(filename); + var filepath = Loader.FindParentPath(filename); using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); // Import the graphs