diff --git a/Jolt.Native/Debug/linux-x64/libjoltc.so b/Jolt.Native/Debug/linux-x64/libjoltc.so deleted file mode 100644 index 723d67f..0000000 Binary files a/Jolt.Native/Debug/linux-x64/libjoltc.so and /dev/null differ diff --git a/Jolt.Native/Debug/linux-x64/libjoltc.so.meta b/Jolt.Native/Debug/linux-x64/libjoltc.so.meta deleted file mode 100644 index fbeca78..0000000 --- a/Jolt.Native/Debug/linux-x64/libjoltc.so.meta +++ /dev/null @@ -1,71 +0,0 @@ -fileFormatVersion: 2 -guid: a341694cb3188bd4495dbfe0d64c0760 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 1 - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 1 - Exclude Win: 0 - Exclude Win64: 0 - - first: - Android: Android - second: - enabled: 0 - settings: - AndroidSharedLibraryType: Executable - CPU: X86_64 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: Linux - - first: - Standalone: Linux64 - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: OSXUniversal - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 1 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/Debug/macos-x64/libjoltc.dylib.meta b/Jolt.Native/Debug/macos-x64/libjoltc.dylib.meta deleted file mode 100644 index 291ca05..0000000 --- a/Jolt.Native/Debug/macos-x64/libjoltc.dylib.meta +++ /dev/null @@ -1,71 +0,0 @@ -fileFormatVersion: 2 -guid: d626d9cd566f5a94d94a7374d9191dce -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 1 - Exclude Editor: 0 - Exclude Linux64: 1 - Exclude OSXUniversal: 0 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Android: Android - second: - enabled: 0 - settings: - AndroidSharedLibraryType: Executable - CPU: ARMv7 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: OSX - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/Debug/windows-x64/joltc.dll.meta b/Jolt.Native/Debug/windows-x64/joltc.dll.meta deleted file mode 100644 index 83104b3..0000000 --- a/Jolt.Native/Debug/windows-x64/joltc.dll.meta +++ /dev/null @@ -1,71 +0,0 @@ -fileFormatVersion: 2 -guid: cbe4d0b0a8e643d4f980675153ff97bb -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 1 - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - - first: - Android: Android - second: - enabled: 0 - settings: - AndroidSharedLibraryType: Executable - CPU: ARMv7 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: Windows - - first: - Standalone: Linux64 - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: Win - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: Win64 - second: - enabled: 1 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/NativeLibrary.cs b/Jolt.Native/NativeLibrary.cs index 3c9b083..b56caf8 100644 --- a/Jolt.Native/NativeLibrary.cs +++ b/Jolt.Native/NativeLibrary.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using UnityEngine; @@ -11,15 +12,19 @@ namespace Jolt.Native { + // TODO 处理Android 和 IOS public static class NativeLibrary { - [DllImport("kernel32", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "LoadLibrary")] + [DllImport("kernel32", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, + EntryPoint = "LoadLibrary")] private static extern IntPtr LoadLibraryWindows(string path); - [DllImport("libc", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "dlopen")] + [DllImport("libc", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, + EntryPoint = "dlopen")] private static extern IntPtr LoadLibraryLinux(string path, int flags); - [DllImport("libdl", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "dlopen")] + [DllImport("libdl", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, + EntryPoint = "dlopen")] private static extern IntPtr LoadLibraryMacOS(string path, int flags); private static IntPtr libptr; @@ -44,40 +49,58 @@ private static void MaybeLoadLibrary() return; } - string libname; + List libnames = new List(); if (IsWindows()) { - libname = "windows-x64\\joltc.dll"; + libnames.Add("win-x64/native/joltc.dll"); + libnames.Add("win-arm64/native/joltc.dll"); + libnames.Add("win-x86/native/joltc.dll"); } else if (IsLinux()) { - libname = "linux-x64\\libjoltc.so"; + libnames.Add("linux-x64/native/libjoltc.so"); + libnames.Add("linux-arm64/native/libjoltc.so"); } else if (IsMacOS()) { - libname = "macos-x64\\libjoltc.dylib"; + libnames.Add("osx/native/libjoltc.dylib"); + libnames.Add("osx-x64/native/libjoltc.dylib"); + libnames.Add("osx-arm64/native/libjoltc.dylib"); } + // else if (IsAndroid()) + // { + // libnames.Add("android-arm/native/libjoltc.so"); + // libnames.Add("android-arm64/native/libjoltc.so"); + // libnames.Add("android-x64/native/libjoltc.so"); + // } + // else if (IsIOS()) + // { + // } else { throw new Exception("Unrecognized platform, unable to load native lib."); } - #if UNITY_EDITOR +#if UNITY_EDITOR var paths = EditorLibraryPaths(); - #else +#else var paths = RuntimeLibraryPaths(); - #endif +#endif foreach (var path in paths) { - if (TryLoadLibrary(Path.Combine(path, libname), out libptr)) + foreach (var libname in libnames) { - Debug.Log($"Loaded Jolt library at {path}/{libname}"); - break; + if (TryLoadLibrary(Path.Combine(path, libname), out libptr)) + { + Debug.Log($"Loaded Jolt library at {path}/{libname}"); + goto ok; + } } } + ok: if (libptr == IntPtr.Zero) { throw new Exception("Failed to load native lib."); @@ -122,12 +145,7 @@ private static bool IsMacOS() private static string[] EditorLibraryPaths() { const string package = "com.seep.jolt"; - - #if JOLT_RELEASE const string config = "Release"; - #else - const string config = "Debug"; - #endif return new[] { diff --git a/Jolt.Native/Debug.meta b/Jolt.Native/Release/android-arm.meta similarity index 77% rename from Jolt.Native/Debug.meta rename to Jolt.Native/Release/android-arm.meta index 11bbc8f..ddaf6f5 100644 --- a/Jolt.Native/Debug.meta +++ b/Jolt.Native/Release/android-arm.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7aeea15d47a327349ae45afbb000712c +guid: 49340e49bb4b84cb28a3b45592f29337 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Jolt.Native/Debug/linux-x64.meta b/Jolt.Native/Release/android-arm/native.meta similarity index 77% rename from Jolt.Native/Debug/linux-x64.meta rename to Jolt.Native/Release/android-arm/native.meta index 60114ea..516a4ba 100644 --- a/Jolt.Native/Debug/linux-x64.meta +++ b/Jolt.Native/Release/android-arm/native.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f1527b1faacfe6146a38c905ca689743 +guid: b59df1613a79f4672bb9ee80ddf74602 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Jolt.Native/Debug/windows-x64/joltc.dll b/Jolt.Native/Release/android-arm/native/libjoltc.so old mode 100644 new mode 100755 similarity index 50% rename from Jolt.Native/Debug/windows-x64/joltc.dll rename to Jolt.Native/Release/android-arm/native/libjoltc.so index 6a364af..8508cad Binary files a/Jolt.Native/Debug/windows-x64/joltc.dll and b/Jolt.Native/Release/android-arm/native/libjoltc.so differ diff --git a/Jolt.Native/Release/android-arm/native/libjoltc.so.meta b/Jolt.Native/Release/android-arm/native/libjoltc.so.meta new file mode 100644 index 0000000..3e66dac --- /dev/null +++ b/Jolt.Native/Release/android-arm/native/libjoltc.so.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 296eae0a442924faa91b6062f9522fc8 \ No newline at end of file diff --git a/Jolt.Native/Debug/macos-x64.meta b/Jolt.Native/Release/android-arm64.meta similarity index 77% rename from Jolt.Native/Debug/macos-x64.meta rename to Jolt.Native/Release/android-arm64.meta index 1cecd00..6e574fe 100644 --- a/Jolt.Native/Debug/macos-x64.meta +++ b/Jolt.Native/Release/android-arm64.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e3dae78104a77df4eaec8e31a40b44bf +guid: 68e4fe87d724844bfa14b23b498351a2 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Jolt.Native/Debug/windows-x64.meta b/Jolt.Native/Release/android-arm64/native.meta similarity index 77% rename from Jolt.Native/Debug/windows-x64.meta rename to Jolt.Native/Release/android-arm64/native.meta index 04fbbdd..3e4194d 100644 --- a/Jolt.Native/Debug/windows-x64.meta +++ b/Jolt.Native/Release/android-arm64/native.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 78e63df48beb58347a7de177b0f1c1d8 +guid: e47f0d2eab975445d8d33a05d014fb97 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Jolt.Native/Debug/macos-x64/libjoltc.dylib b/Jolt.Native/Release/android-arm64/native/libjoltc.so old mode 100644 new mode 100755 similarity index 70% rename from Jolt.Native/Debug/macos-x64/libjoltc.dylib rename to Jolt.Native/Release/android-arm64/native/libjoltc.so index eae0cdc..f14f148 Binary files a/Jolt.Native/Debug/macos-x64/libjoltc.dylib and b/Jolt.Native/Release/android-arm64/native/libjoltc.so differ diff --git a/Jolt.Native/Release/android-arm64/native/libjoltc.so.meta b/Jolt.Native/Release/android-arm64/native/libjoltc.so.meta new file mode 100644 index 0000000..9907bb4 --- /dev/null +++ b/Jolt.Native/Release/android-arm64/native/libjoltc.so.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e882c461267da483b9d808409258731d \ No newline at end of file diff --git a/Jolt.Native/Release/android-x64.meta b/Jolt.Native/Release/android-x64.meta new file mode 100644 index 0000000..2d4392b --- /dev/null +++ b/Jolt.Native/Release/android-x64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d015559ed7bc740b39568b1c6089ccb7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/android-x64/native.meta b/Jolt.Native/Release/android-x64/native.meta new file mode 100644 index 0000000..db58e8d --- /dev/null +++ b/Jolt.Native/Release/android-x64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 04bddfc11c4cc4e78b5d069f2a29daaa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/android-x64/native/libjoltc.so b/Jolt.Native/Release/android-x64/native/libjoltc.so new file mode 100755 index 0000000..499622f Binary files /dev/null and b/Jolt.Native/Release/android-x64/native/libjoltc.so differ diff --git a/Jolt.Native/Release/android-x64/native/libjoltc.so.meta b/Jolt.Native/Release/android-x64/native/libjoltc.so.meta new file mode 100644 index 0000000..be13f7a --- /dev/null +++ b/Jolt.Native/Release/android-x64/native/libjoltc.so.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c6b5eaa06b9f84aa49349cf15862229a \ No newline at end of file diff --git a/Jolt.Native/Release/linux-arm64.meta b/Jolt.Native/Release/linux-arm64.meta new file mode 100644 index 0000000..a72fb71 --- /dev/null +++ b/Jolt.Native/Release/linux-arm64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f7d8126b442f74c6c9703a9a4ed8a8e1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/linux-arm64/native.meta b/Jolt.Native/Release/linux-arm64/native.meta new file mode 100644 index 0000000..a292bf3 --- /dev/null +++ b/Jolt.Native/Release/linux-arm64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 47bd8fdab417b48d292fed27b2f2e2a5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/linux-arm64/native/libjoltc.so b/Jolt.Native/Release/linux-arm64/native/libjoltc.so new file mode 100755 index 0000000..08feaf3 Binary files /dev/null and b/Jolt.Native/Release/linux-arm64/native/libjoltc.so differ diff --git a/Jolt.Native/Release/linux-arm64/native/libjoltc.so.meta b/Jolt.Native/Release/linux-arm64/native/libjoltc.so.meta new file mode 100644 index 0000000..22331f3 --- /dev/null +++ b/Jolt.Native/Release/linux-arm64/native/libjoltc.so.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: dc92af415772c4d3a95abab576d351ef \ No newline at end of file diff --git a/Jolt.Native/Release/linux-x64.meta b/Jolt.Native/Release/linux-x64.meta index 74d8d96..ac17ee3 100644 --- a/Jolt.Native/Release/linux-x64.meta +++ b/Jolt.Native/Release/linux-x64.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8d17339e225ca9449a59f61096da107a +guid: fcc1a9e6f51e348af8013e2a6b3bd280 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Jolt.Native/Release/linux-x64/libjoltc.so b/Jolt.Native/Release/linux-x64/libjoltc.so deleted file mode 100644 index bf0c689..0000000 Binary files a/Jolt.Native/Release/linux-x64/libjoltc.so and /dev/null differ diff --git a/Jolt.Native/Release/linux-x64/libjoltc.so.meta b/Jolt.Native/Release/linux-x64/libjoltc.so.meta deleted file mode 100644 index 5c75d7c..0000000 --- a/Jolt.Native/Release/linux-x64/libjoltc.so.meta +++ /dev/null @@ -1,71 +0,0 @@ -fileFormatVersion: 2 -guid: 27e8b350261f90b41b3953b6cd9aab3d -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 1 - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - - first: - Android: Android - second: - enabled: 0 - settings: - AndroidSharedLibraryType: Executable - CPU: X86_64 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: Linux - - first: - Standalone: Linux64 - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 1 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/Release/linux-x64/native.meta b/Jolt.Native/Release/linux-x64/native.meta new file mode 100644 index 0000000..fec24be --- /dev/null +++ b/Jolt.Native/Release/linux-x64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1da1a3fb9142b44f18643fc1a844cee8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/linux-x64/native/libjoltc.so b/Jolt.Native/Release/linux-x64/native/libjoltc.so new file mode 100755 index 0000000..8538823 Binary files /dev/null and b/Jolt.Native/Release/linux-x64/native/libjoltc.so differ diff --git a/Jolt.Native/Release/linux-x64/native/libjoltc.so.meta b/Jolt.Native/Release/linux-x64/native/libjoltc.so.meta new file mode 100644 index 0000000..8956c04 --- /dev/null +++ b/Jolt.Native/Release/linux-x64/native/libjoltc.so.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8dabfe87517ed4505ada6eaf8b62947f \ No newline at end of file diff --git a/Jolt.Native/Release/linux-x64/native/libraylib.so b/Jolt.Native/Release/linux-x64/native/libraylib.so new file mode 100755 index 0000000..018784a Binary files /dev/null and b/Jolt.Native/Release/linux-x64/native/libraylib.so differ diff --git a/Jolt.Native/Release/linux-x64/native/libraylib.so.meta b/Jolt.Native/Release/linux-x64/native/libraylib.so.meta new file mode 100644 index 0000000..7f80f81 --- /dev/null +++ b/Jolt.Native/Release/linux-x64/native/libraylib.so.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 196d72d67f4f74bcabe2f55072795c3a \ No newline at end of file diff --git a/Jolt.Native/Release/macos-x64.meta b/Jolt.Native/Release/macos-x64.meta deleted file mode 100644 index 47bab0f..0000000 --- a/Jolt.Native/Release/macos-x64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f21eb3741ee5486488e62c055724412b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/Release/macos-x64/libjoltc.dylib b/Jolt.Native/Release/macos-x64/libjoltc.dylib deleted file mode 100644 index a4a3166..0000000 Binary files a/Jolt.Native/Release/macos-x64/libjoltc.dylib and /dev/null differ diff --git a/Jolt.Native/Release/macos-x64/libjoltc.dylib.meta b/Jolt.Native/Release/macos-x64/libjoltc.dylib.meta deleted file mode 100644 index 6de4ee8..0000000 --- a/Jolt.Native/Release/macos-x64/libjoltc.dylib.meta +++ /dev/null @@ -1,71 +0,0 @@ -fileFormatVersion: 2 -guid: 782b4b903a7072741a2f5f387c48816b -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 1 - Exclude Editor: 0 - Exclude Linux64: 1 - Exclude OSXUniversal: 0 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Android: Android - second: - enabled: 0 - settings: - AndroidSharedLibraryType: Executable - CPU: ARMv7 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: OSX - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/Release/osx-arm64.meta b/Jolt.Native/Release/osx-arm64.meta new file mode 100644 index 0000000..97f18f4 --- /dev/null +++ b/Jolt.Native/Release/osx-arm64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d465f66eee404d30956ff5e257cd4d4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/osx-arm64/native.meta b/Jolt.Native/Release/osx-arm64/native.meta new file mode 100644 index 0000000..26819b3 --- /dev/null +++ b/Jolt.Native/Release/osx-arm64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 05b56d2e70a764e27b4b94a90d50bf57 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/osx-arm64/native/libraylib.dylib b/Jolt.Native/Release/osx-arm64/native/libraylib.dylib new file mode 100755 index 0000000..2d87369 Binary files /dev/null and b/Jolt.Native/Release/osx-arm64/native/libraylib.dylib differ diff --git a/Jolt.Native/Release/osx-arm64/native/libraylib.dylib.meta b/Jolt.Native/Release/osx-arm64/native/libraylib.dylib.meta new file mode 100644 index 0000000..7e69805 --- /dev/null +++ b/Jolt.Native/Release/osx-arm64/native/libraylib.dylib.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 3ad9db17a08b34f3883c5d362c801318 \ No newline at end of file diff --git a/Jolt.Native/Release/osx-x64.meta b/Jolt.Native/Release/osx-x64.meta new file mode 100644 index 0000000..55ddbad --- /dev/null +++ b/Jolt.Native/Release/osx-x64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8511ab0f1bf8e4f249ed3aff62e521aa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/osx-x64/native.meta b/Jolt.Native/Release/osx-x64/native.meta new file mode 100644 index 0000000..9541337 --- /dev/null +++ b/Jolt.Native/Release/osx-x64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c8da853952ab44e4d930013c7419609d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/osx-x64/native/libraylib.dylib b/Jolt.Native/Release/osx-x64/native/libraylib.dylib new file mode 100755 index 0000000..cfdc792 Binary files /dev/null and b/Jolt.Native/Release/osx-x64/native/libraylib.dylib differ diff --git a/Jolt.Native/Release/osx-x64/native/libraylib.dylib.meta b/Jolt.Native/Release/osx-x64/native/libraylib.dylib.meta new file mode 100644 index 0000000..640d5f7 --- /dev/null +++ b/Jolt.Native/Release/osx-x64/native/libraylib.dylib.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 59316ab0d253042b7a86870ccf58c272 \ No newline at end of file diff --git a/Jolt.Native/Release/osx.meta b/Jolt.Native/Release/osx.meta new file mode 100644 index 0000000..f0d013e --- /dev/null +++ b/Jolt.Native/Release/osx.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7e57a8376a9124f98b355bce509e654f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/osx/native.meta b/Jolt.Native/Release/osx/native.meta new file mode 100644 index 0000000..d77210d --- /dev/null +++ b/Jolt.Native/Release/osx/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2dea5b26eceb248a69fcdaf8e5bcc55e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/osx/native/libjoltc.dylib b/Jolt.Native/Release/osx/native/libjoltc.dylib new file mode 100755 index 0000000..5910799 Binary files /dev/null and b/Jolt.Native/Release/osx/native/libjoltc.dylib differ diff --git a/Jolt.Native/Release/osx/native/libjoltc.dylib.meta b/Jolt.Native/Release/osx/native/libjoltc.dylib.meta new file mode 100644 index 0000000..9d7eed9 --- /dev/null +++ b/Jolt.Native/Release/osx/native/libjoltc.dylib.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e8e729819e30b4cb2860f003c796af08 \ No newline at end of file diff --git a/Jolt.Native/Release/win-arm64.meta b/Jolt.Native/Release/win-arm64.meta new file mode 100644 index 0000000..3482a8a --- /dev/null +++ b/Jolt.Native/Release/win-arm64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55196b3d45aff4173a27438338dd3053 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/win-arm64/native.meta b/Jolt.Native/Release/win-arm64/native.meta new file mode 100644 index 0000000..641bbd3 --- /dev/null +++ b/Jolt.Native/Release/win-arm64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 869f1346e6dae468ea36cb6535325d7c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/win-arm64/native/joltc.dll b/Jolt.Native/Release/win-arm64/native/joltc.dll new file mode 100755 index 0000000..e99bcbb Binary files /dev/null and b/Jolt.Native/Release/win-arm64/native/joltc.dll differ diff --git a/Jolt.Native/Release/win-arm64/native/joltc.dll.meta b/Jolt.Native/Release/win-arm64/native/joltc.dll.meta new file mode 100644 index 0000000..1156796 --- /dev/null +++ b/Jolt.Native/Release/win-arm64/native/joltc.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 66dfe75406c264e1baf347e9c32c67fd \ No newline at end of file diff --git a/Jolt.Native/Release/win-arm64/native/joltc_double.dll b/Jolt.Native/Release/win-arm64/native/joltc_double.dll new file mode 100755 index 0000000..81c4284 Binary files /dev/null and b/Jolt.Native/Release/win-arm64/native/joltc_double.dll differ diff --git a/Jolt.Native/Release/win-arm64/native/joltc_double.dll.meta b/Jolt.Native/Release/win-arm64/native/joltc_double.dll.meta new file mode 100644 index 0000000..8c6b48e --- /dev/null +++ b/Jolt.Native/Release/win-arm64/native/joltc_double.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ceb97d5ac6cb5495cb9415dd0c0d68a9 \ No newline at end of file diff --git a/Jolt.Native/Release/win-x64.meta b/Jolt.Native/Release/win-x64.meta new file mode 100644 index 0000000..af3783c --- /dev/null +++ b/Jolt.Native/Release/win-x64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c8feabd4717f4bda85272d81528139c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/win-x64/native.meta b/Jolt.Native/Release/win-x64/native.meta new file mode 100644 index 0000000..72a8a2d --- /dev/null +++ b/Jolt.Native/Release/win-x64/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 203196e549318408f800733eb4740c75 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/win-x64/native/joltc.dll b/Jolt.Native/Release/win-x64/native/joltc.dll new file mode 100755 index 0000000..0f1216e Binary files /dev/null and b/Jolt.Native/Release/win-x64/native/joltc.dll differ diff --git a/Jolt.Native/Release/win-x64/native/joltc.dll.meta b/Jolt.Native/Release/win-x64/native/joltc.dll.meta new file mode 100644 index 0000000..5b8e480 --- /dev/null +++ b/Jolt.Native/Release/win-x64/native/joltc.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: afb09e441c7b84c0f9dc62aa1f4e4c50 \ No newline at end of file diff --git a/Jolt.Native/Release/win-x64/native/joltc_double.dll b/Jolt.Native/Release/win-x64/native/joltc_double.dll new file mode 100755 index 0000000..8e4dd95 Binary files /dev/null and b/Jolt.Native/Release/win-x64/native/joltc_double.dll differ diff --git a/Jolt.Native/Release/win-x64/native/joltc_double.dll.meta b/Jolt.Native/Release/win-x64/native/joltc_double.dll.meta new file mode 100644 index 0000000..bc4dbe2 --- /dev/null +++ b/Jolt.Native/Release/win-x64/native/joltc_double.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a66bf44e4344342319e8b44c47573828 \ No newline at end of file diff --git a/Jolt.Native/Release/win-x64/native/raylib.dll b/Jolt.Native/Release/win-x64/native/raylib.dll new file mode 100755 index 0000000..7834799 Binary files /dev/null and b/Jolt.Native/Release/win-x64/native/raylib.dll differ diff --git a/Jolt.Native/Release/win-x64/native/raylib.dll.meta b/Jolt.Native/Release/win-x64/native/raylib.dll.meta new file mode 100644 index 0000000..cdafed2 --- /dev/null +++ b/Jolt.Native/Release/win-x64/native/raylib.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 362987e6cfab84c32adbaa226179980f \ No newline at end of file diff --git a/Jolt.Native/Release/win-x86.meta b/Jolt.Native/Release/win-x86.meta new file mode 100644 index 0000000..97ffe7e --- /dev/null +++ b/Jolt.Native/Release/win-x86.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4b8a6f65f7254e55929693f05d60906 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/win-x86/native.meta b/Jolt.Native/Release/win-x86/native.meta new file mode 100644 index 0000000..a6474f4 --- /dev/null +++ b/Jolt.Native/Release/win-x86/native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c2a3cd271d9f6436db3bccd90b8192e3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Jolt.Native/Release/win-x86/native/raylib.dll b/Jolt.Native/Release/win-x86/native/raylib.dll new file mode 100755 index 0000000..c782897 Binary files /dev/null and b/Jolt.Native/Release/win-x86/native/raylib.dll differ diff --git a/Jolt.Native/Release/win-x86/native/raylib.dll.meta b/Jolt.Native/Release/win-x86/native/raylib.dll.meta new file mode 100644 index 0000000..4c1b688 --- /dev/null +++ b/Jolt.Native/Release/win-x86/native/raylib.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 98eb87da1dc6847369f63f29c0b6fc9e \ No newline at end of file diff --git a/Jolt.Native/Release/windows-x64.meta b/Jolt.Native/Release/windows-x64.meta deleted file mode 100644 index eda5ea7..0000000 --- a/Jolt.Native/Release/windows-x64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bd26dfcae774f0449afcabb80f07dbed -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt.Native/Release/windows-x64/joltc.dll b/Jolt.Native/Release/windows-x64/joltc.dll deleted file mode 100644 index f5dfba5..0000000 Binary files a/Jolt.Native/Release/windows-x64/joltc.dll and /dev/null differ diff --git a/Jolt.Native/Release/windows-x64/joltc.dll.meta b/Jolt.Native/Release/windows-x64/joltc.dll.meta deleted file mode 100644 index 9a3f2a7..0000000 --- a/Jolt.Native/Release/windows-x64/joltc.dll.meta +++ /dev/null @@ -1,71 +0,0 @@ -fileFormatVersion: 2 -guid: a32c92be075537440a4724073d743de0 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 0 - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - - first: - Android: Android - second: - enabled: 1 - settings: - AndroidSharedLibraryType: Executable - CPU: ARMv7 - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: Windows - - first: - Standalone: Linux64 - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: Win - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: Win64 - second: - enabled: 1 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Jolt/Bindings/Bindings.cs b/Jolt/Bindings/Bindings.cs index f741885..5b4fb72 100644 --- a/Jolt/Bindings/Bindings.cs +++ b/Jolt/Bindings/Bindings.cs @@ -1,9 +1,12 @@ using System; using System.Runtime.CompilerServices; +using Jolt.Native; using UnityEngine; [assembly: InternalsVisibleTo("Jolt.Tests")] +[assembly: InternalsVisibleTo("JoltWrapper")] + namespace Jolt { internal static partial class Bindings diff --git a/Jolt/Bindings/Bindings_JPH_BodyInterface.cs b/Jolt/Bindings/Bindings_JPH_BodyInterface.cs index 20a5e46..0d3b8db 100644 --- a/Jolt/Bindings/Bindings_JPH_BodyInterface.cs +++ b/Jolt/Bindings/Bindings_JPH_BodyInterface.cs @@ -135,11 +135,11 @@ public static bool JPH_BodyInterface_IsAdded(NativeHandle @in return UnsafeBindings.JPH_BodyInterface_IsAdded(@interface, bodyID); } - public static bool JPH_BodyInterface_GetBodyType(NativeHandle @interface, BodyID bodyID) + public static BodyType JPH_BodyInterface_GetBodyType(NativeHandle @interface, BodyID bodyID) { AssertInitialized(); - return UnsafeBindings.JPH_BodyInterface_IsAdded(@interface, bodyID); + return UnsafeBindings.JPH_BodyInterface_GetBodyType(@interface, bodyID); } public static void JPH_BodyInterface_SetLinearVelocity(NativeHandle @interface, BodyID bodyID, float3 velocity) diff --git a/Jolt/Generated/BodyInterface.g.cs b/Jolt/Generated/BodyInterface.g.cs index b1244b7..f4d1664 100644 --- a/Jolt/Generated/BodyInterface.g.cs +++ b/Jolt/Generated/BodyInterface.g.cs @@ -59,7 +59,7 @@ public partial struct BodyInterface : IEquatable public bool IsAdded(BodyID bodyID) => Bindings.JPH_BodyInterface_IsAdded(Handle, bodyID); - public bool GetBodyType(BodyID bodyID) => Bindings.JPH_BodyInterface_GetBodyType(Handle, bodyID); + public BodyType GetBodyType(BodyID bodyID) => Bindings.JPH_BodyInterface_GetBodyType(Handle, bodyID); public void SetLinearVelocity(BodyID bodyID, float3 velocity) => Bindings.JPH_BodyInterface_SetLinearVelocity(Handle, bodyID, velocity); @@ -81,7 +81,7 @@ public partial struct BodyInterface : IEquatable public void SetPosition(BodyID bodyID, rvec3 position, Activation activation) => Bindings.JPH_BodyInterface_SetPosition(Handle, bodyID, position, activation); - public rvec3 GetPosition(BodyID bodyID) => Bindings.JPH_BodyInterface_GetPosition(Handle, bodyID); + public readonly rvec3 GetPosition(BodyID bodyID) => Bindings.JPH_BodyInterface_GetPosition(Handle, bodyID); public void SetRotation(BodyID bodyID, quaternion rotation, Activation activation) => Bindings.JPH_BodyInterface_SetRotation(Handle, bodyID, rotation, activation); diff --git a/Jolt/Generated/JobSystem.g.cs b/Jolt/Generated/JobSystem.g.cs index c2cc9ae..00ade58 100644 --- a/Jolt/Generated/JobSystem.g.cs +++ b/Jolt/Generated/JobSystem.g.cs @@ -23,7 +23,7 @@ public partial struct JobSystem : IEquatable #region JPH_JobSystem - public void Destroy() => Bindings.JPH_JobSystem_Destroy(Handle); + public readonly void Destroy() => Bindings.JPH_JobSystem_Destroy(Handle); #endregion diff --git a/Jolt/Generated/PhysicsSystem.g.cs b/Jolt/Generated/PhysicsSystem.g.cs index 0ce0591..f705b5e 100644 --- a/Jolt/Generated/PhysicsSystem.g.cs +++ b/Jolt/Generated/PhysicsSystem.g.cs @@ -23,15 +23,16 @@ public partial struct PhysicsSystem : IEquatable #region JPH_PhysicsSystem - public void Destroy() => Bindings.JPH_PhysicsSystem_Destroy(Handle); + public readonly void Destroy() => Bindings.JPH_PhysicsSystem_Destroy(Handle); public void SetPhysicsSettings(ref PhysicsSettings settings) => Bindings.JPH_PhysicsSystem_SetPhysicsSettings(Handle, ref settings); public void GetPhysicsSettings(ref PhysicsSettings settings) => Bindings.JPH_PhysicsSystem_GetPhysicsSettings(Handle, ref settings); public void OptimizeBroadPhase() => Bindings.JPH_PhysicsSystem_OptimizeBroadPhase(Handle); - - public BodyInterface GetBodyInterface() => new BodyInterface { Handle = Bindings.JPH_PhysicsSystem_GetBodyInterface(Handle) }; + + public BodyInterface BodyInterface => GetBodyInterface(); + public readonly BodyInterface GetBodyInterface() => new BodyInterface { Handle = Bindings.JPH_PhysicsSystem_GetBodyInterface(Handle) }; public BodyInterface GetBodyInterfaceNoLock() => new BodyInterface { Handle = Bindings.JPH_PhysicsSystem_GetBodyInterfaceNoLock(Handle) }; @@ -55,10 +56,22 @@ public partial struct PhysicsSystem : IEquatable public uint GetNumConstraints() => Bindings.JPH_PhysicsSystem_GetNumConstraints(Handle); - public void SetGravity(float3 gravity) => Bindings.JPH_PhysicsSystem_SetGravity(Handle, gravity); + public readonly void SetGravity(float3 gravity) => Bindings.JPH_PhysicsSystem_SetGravity(Handle, gravity); public float3 GetGravity() => Bindings.JPH_PhysicsSystem_GetGravity(Handle); - + + public float3 gravity + { + get + { + return Bindings.JPH_PhysicsSystem_GetGravity(Handle); + } + set + { + Bindings.JPH_PhysicsSystem_SetGravity(Handle, gravity); + } + } + public void AddConstraint(Constraint constraint) => Bindings.JPH_PhysicsSystem_AddConstraint(Handle, constraint.Handle); public void RemoveConstraint(Constraint constraint) => Bindings.JPH_PhysicsSystem_RemoveConstraint(Handle, constraint.Handle); diff --git a/Jolt/Generated/Shape.g.cs b/Jolt/Generated/Shape.g.cs index 4e52899..38b6d7e 100644 --- a/Jolt/Generated/Shape.g.cs +++ b/Jolt/Generated/Shape.g.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using Jolt; using Unity.Collections; using Unity.Mathematics; @@ -27,6 +28,12 @@ public partial struct Shape : IEquatable public ShapeType GetShapeType() => Bindings.JPH_Shape_GetType(Handle); + public ShapeSubType subType + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return Bindings.JPH_Shape_GetSubType(Handle); } + } + public ShapeSubType GetSubType() => Bindings.JPH_Shape_GetSubType(Handle); public ulong GetUserData() => Bindings.JPH_Shape_GetUserData(Handle); diff --git a/Jolt/Mathematics/rvec3.cs b/Jolt/Mathematics/rvec3.cs index d3d2ecd..04927ff 100644 --- a/Jolt/Mathematics/rvec3.cs +++ b/Jolt/Mathematics/rvec3.cs @@ -41,6 +41,26 @@ public static unsafe implicit operator rvec3(float3 vec) return *((rvec3*) &vec); } + public static implicit operator rvec3(System.Numerics.Vector3 vec) + { + return new rvec3(vec.X, vec.Y, vec.Z); + } + + public static implicit operator System.Numerics.Vector3(rvec3 vec) + { + return new System.Numerics.Vector3(vec.x, vec.y, vec.z); + } + + public static implicit operator rvec3(UnityEngine.Vector3 vec) + { + return new rvec3(vec.x, vec.y, vec.z); + } + + public static implicit operator UnityEngine.Vector3(rvec3 vec) + { + return new UnityEngine.Vector3(vec.x, vec.y, vec.z); + } + public static rvec3 one => new rvec3(1f, 1f, 1f); #else diff --git a/Jolt/Types/BodyCreationSettings.cs b/Jolt/Types/BodyCreationSettings.cs index 675190f..927c802 100644 --- a/Jolt/Types/BodyCreationSettings.cs +++ b/Jolt/Types/BodyCreationSettings.cs @@ -13,6 +13,15 @@ public static BodyCreationSettings Create() { return new BodyCreationSettings { Handle = JPH_BodyCreationSettings_Create() }; } + public BodyCreationSettings (ShapeSettings settings, rvec3 position, quaternion rotation, MotionType motion, ObjectLayer layer) + { + Handle = JPH_BodyCreationSettings_Create(settings.Handle, position, rotation, motion, layer); + } + + public BodyCreationSettings (Shape shape, rvec3 position, quaternion rotation, MotionType motion, ObjectLayer layer) + { + Handle = JPH_BodyCreationSettings_Create(shape.Handle, position, rotation, motion, layer); + } public static BodyCreationSettings Create(ShapeSettings settings, rvec3 position, quaternion rotation, MotionType motion, ObjectLayer layer) { diff --git a/Jolt/Types/BodyID.cs b/Jolt/Types/BodyID.cs index e5f3bb3..3fb51ee 100644 --- a/Jolt/Types/BodyID.cs +++ b/Jolt/Types/BodyID.cs @@ -6,8 +6,30 @@ namespace Jolt [StructLayout(LayoutKind.Sequential), ExpectedStructSize(typeof(uint))] public struct BodyID : IEquatable { + /// + /// The value for an invalid body ID + /// + public const uint InvalidBodyID = 0xffffffff; + public uint Value; + public uint ID => Value; + + public BodyID(uint value) + { + Value = value; + } + + public static implicit operator uint(BodyID id) + { + return id.Value; + } + + public static implicit operator BodyID(uint id) + { + return new BodyID { Value = id }; + } + #region IEquatable public bool Equals(BodyID other) diff --git a/Jolt/Types/BoxShape.cs b/Jolt/Types/BoxShape.cs index e109e45..4fa22c2 100644 --- a/Jolt/Types/BoxShape.cs +++ b/Jolt/Types/BoxShape.cs @@ -7,6 +7,11 @@ namespace Jolt public partial struct BoxShape { internal NativeHandle Handle; + + public BoxShape(float3 halfExtent, float convexRadius = PhysicsSettings.DefaultConvexRadius) + { + Handle = JPH_BoxShape_Create(halfExtent, convexRadius); + } public static BoxShape Create(float3 halfExtent, float convexRadius = PhysicsSettings.DefaultConvexRadius) { diff --git a/Jolt/Types/BoxShapeSettings.cs b/Jolt/Types/BoxShapeSettings.cs index 28a9cda..4d93b46 100644 --- a/Jolt/Types/BoxShapeSettings.cs +++ b/Jolt/Types/BoxShapeSettings.cs @@ -8,7 +8,11 @@ namespace Jolt public partial struct BoxShapeSettings { internal NativeHandle Handle; - + + public BoxShapeSettings(float3 halfExtents,float convexRadius = PhysicsSettings.DefaultConvexRadius) + { + Handle = JPH_BoxShapeSettings_Create(halfExtents, convexRadius); + } public static BoxShapeSettings Create(float3 halfExtent, float convexRadius = PhysicsSettings.DefaultConvexRadius) { return new BoxShapeSettings { Handle = JPH_BoxShapeSettings_Create(halfExtent, convexRadius) }; diff --git a/Jolt/Types/BroadPhaseLayerInterfaceTable.cs b/Jolt/Types/BroadPhaseLayerInterfaceTable.cs index f5e3630..563ad08 100644 --- a/Jolt/Types/BroadPhaseLayerInterfaceTable.cs +++ b/Jolt/Types/BroadPhaseLayerInterfaceTable.cs @@ -6,6 +6,11 @@ namespace Jolt public partial struct BroadPhaseLayerInterfaceTable { internal NativeHandle Handle; + + public BroadPhaseLayerInterfaceTable(uint numObjectLayers, uint numBroadPhaseLayers) + { + Handle = JPH_BroadPhaseLayerInterfaceTable_Create(numObjectLayers, numBroadPhaseLayers); + } public static BroadPhaseLayerInterfaceTable Create(uint numObjectLayers, uint numBroadPhaseLayers) { diff --git a/Jolt/Types/ObjectLayer.cs b/Jolt/Types/ObjectLayer.cs index b19df6b..85eb27b 100644 --- a/Jolt/Types/ObjectLayer.cs +++ b/Jolt/Types/ObjectLayer.cs @@ -6,35 +6,41 @@ namespace Jolt [StructLayout(LayoutKind.Sequential)] public readonly struct ObjectLayer : IEquatable { - // A distinct type wrapper around ushort (or optionally uint, but unsupported). See https://github.com/jrouwe/JoltPhysics/blob/master/Jolt/Physics/Collision/ObjectLayer.h + // A distinct type wrapper around uint (or optionally uint, but unsupported). See https://github.com/jrouwe/JoltPhysics/blob/master/Jolt/Physics/Collision/ObjectLayer.h /// /// Number of bits in an object layer. /// - public const uint ObjectLayerBits = 16; // TODO can be 32 with compiler flag + public const int Bits = 32 /*0x20*/; - /// - /// The invalid ObjectLayer (0). - /// - public static readonly ObjectLayer Invalid = 0; + public const uint ObjectLayerInvalid = 4294967295 /*0xFFFFFFFF*/; /// /// The layer value. /// - public readonly ushort Value; + public readonly uint Value; - public ObjectLayer(ushort value) + public ObjectLayer(uint value) { Value = value; } + public bool IsValid => this.Value != uint.MaxValue; + + public bool IsInvalid => this.Value == uint.MaxValue; + public static ObjectLayer Invalid => new ObjectLayer(uint.MaxValue); /// - /// Implicit cast from ushort. The inverse is not available to avoid confusion. + /// Implicit cast from uint. The inverse is not available to avoid confusion. /// - public static implicit operator ObjectLayer(ushort layer) + public static implicit operator ObjectLayer(uint layer) { return new ObjectLayer(layer); } + + public static implicit operator uint(ObjectLayer layer) + { + return layer.Value; + } #region IEquatable diff --git a/Jolt/Types/ObjectLayerPairFilterMask.cs b/Jolt/Types/ObjectLayerPairFilterMask.cs index e90f116..e15d48a 100644 --- a/Jolt/Types/ObjectLayerPairFilterMask.cs +++ b/Jolt/Types/ObjectLayerPairFilterMask.cs @@ -14,7 +14,7 @@ public partial struct ObjectLayerPairFilterMask /// /// The number of bits in a group. /// - private const uint NumBits = ObjectLayer.ObjectLayerBits / 2; + private const uint NumBits = ObjectLayer.Bits / 2; /// /// The mask bits. diff --git a/Jolt/Types/ObjectLayerPairFilterTable.cs b/Jolt/Types/ObjectLayerPairFilterTable.cs index 9151f39..3691d44 100644 --- a/Jolt/Types/ObjectLayerPairFilterTable.cs +++ b/Jolt/Types/ObjectLayerPairFilterTable.cs @@ -6,6 +6,11 @@ public partial struct ObjectLayerPairFilterTable { internal NativeHandle Handle; + public ObjectLayerPairFilterTable(uint numObjectLayers) + { + Handle = JPH_ObjectLayerPairFilterTable_Create(numObjectLayers); + } + public static ObjectLayerPairFilterTable Create(uint numObjectLayers) { return new ObjectLayerPairFilterTable { Handle = JPH_ObjectLayerPairFilterTable_Create(numObjectLayers) }; diff --git a/Jolt/Types/ObjectVsBroadPhaseLayerFilterTable.cs b/Jolt/Types/ObjectVsBroadPhaseLayerFilterTable.cs index 38a667a..aa4d508 100644 --- a/Jolt/Types/ObjectVsBroadPhaseLayerFilterTable.cs +++ b/Jolt/Types/ObjectVsBroadPhaseLayerFilterTable.cs @@ -6,6 +6,12 @@ public partial struct ObjectVsBroadPhaseLayerFilterTable { internal NativeHandle Handle; + public ObjectVsBroadPhaseLayerFilterTable(BroadPhaseLayerInterface @interface, uint numBroadPhaseLayers, + ObjectLayerPairFilter filter, uint numObjectLayers) + { + Handle = JPH_ObjectVsBroadPhaseLayerFilterTable_Create(@interface.Handle, numBroadPhaseLayers, + filter.Handle, numObjectLayers); + } public static ObjectVsBroadPhaseLayerFilterTable Create(BroadPhaseLayerInterface @interface, uint numBroadPhaseLayers, ObjectLayerPairFilter filter, uint numObjectLayers) { return new ObjectVsBroadPhaseLayerFilterTable { Handle = JPH_ObjectVsBroadPhaseLayerFilterTable_Create(@interface.Handle, numBroadPhaseLayers, filter.Handle, numObjectLayers) }; diff --git a/Jolt/Types/PhysicsSystem.cs b/Jolt/Types/PhysicsSystem.cs index 251dd35..59ed312 100644 --- a/Jolt/Types/PhysicsSystem.cs +++ b/Jolt/Types/PhysicsSystem.cs @@ -47,7 +47,7 @@ public void SetBodyActivationListener(BodyActivationListener listener) /// /// The out parameter will contain the error if any. /// - public bool Update(float deltaTime, int collisionSteps, JobSystem jobSystem, out PhysicsUpdateError error) + public readonly bool Update(float deltaTime, int collisionSteps, JobSystem jobSystem, out PhysicsUpdateError error) { return (error = JPH_PhysicsSystem_Update(Handle, deltaTime, collisionSteps, jobSystem.Handle)) == PhysicsUpdateError.None; } diff --git a/Jolt/Types/Plane.cs b/Jolt/Types/Plane.cs index a3f4fec..8beb511 100644 --- a/Jolt/Types/Plane.cs +++ b/Jolt/Types/Plane.cs @@ -11,6 +11,12 @@ public struct Plane : IEquatable public float Distance; + public Plane(float3 normal, float distance) + { + this.Normal = normal; + this.Distance = distance; + } + #region IEquatable public bool Equals(Plane other) diff --git a/Jolt/Types/PlaneShape.cs b/Jolt/Types/PlaneShape.cs index 6d7f122..56e6149 100644 --- a/Jolt/Types/PlaneShape.cs +++ b/Jolt/Types/PlaneShape.cs @@ -6,6 +6,11 @@ namespace Jolt public partial struct PlaneShape { internal NativeHandle Handle; + + public PlaneShape(in Plane plane, in float halfExtent) + { + Handle = JPH_PlaneShape_Create(plane, halfExtent); + } public static PlaneShape Create(Plane plane, float halfExtent) { diff --git a/Jolt/Types/PlaneShapeSettings.cs b/Jolt/Types/PlaneShapeSettings.cs index cdf4066..57846ee 100644 --- a/Jolt/Types/PlaneShapeSettings.cs +++ b/Jolt/Types/PlaneShapeSettings.cs @@ -6,7 +6,12 @@ namespace Jolt public partial struct PlaneShapeSettings { internal NativeHandle Handle; - + + public PlaneShapeSettings(Plane plane, float halfExtent) + { + Handle = JPH_PlaneShapeSettings_Create(plane, halfExtent); + } + public static PlaneShapeSettings Create(Plane plane, float halfExtent) { return new PlaneShapeSettings { Handle = JPH_PlaneShapeSettings_Create(plane, halfExtent) }; diff --git a/Jolt/Types/Shape.cs b/Jolt/Types/Shape.cs index fdf3ebc..18f6a60 100644 --- a/Jolt/Types/Shape.cs +++ b/Jolt/Types/Shape.cs @@ -8,6 +8,11 @@ public partial struct Shape { internal NativeHandle Handle; + public static implicit operator Shape(PlaneShape shape) + { + return new Shape { Handle = shape.Handle.Reinterpret() }; + } + public static implicit operator Shape(BoxShape shape) { return new Shape { Handle = shape.Handle.Reinterpret() }; diff --git a/Jolt/Types/SphereShape.cs b/Jolt/Types/SphereShape.cs index 131b9b8..31a5329 100644 --- a/Jolt/Types/SphereShape.cs +++ b/Jolt/Types/SphereShape.cs @@ -7,6 +7,11 @@ public partial struct SphereShape { internal NativeHandle Handle; + public SphereShape(float radius) + { + Handle = JPH_SphereShape_Create(radius); + } + public static SphereShape Create(float radius) { return new SphereShape { Handle = JPH_SphereShape_Create(radius) }; diff --git a/Jolt/Types/SphereShapeSettings.cs b/Jolt/Types/SphereShapeSettings.cs index b4e9ba2..7bf45ff 100644 --- a/Jolt/Types/SphereShapeSettings.cs +++ b/Jolt/Types/SphereShapeSettings.cs @@ -6,7 +6,12 @@ namespace Jolt public partial struct SphereShapeSettings { internal NativeHandle Handle; - + + public SphereShapeSettings(float radius) + { + Handle = JPH_SphereShapeSettings_Create(radius); + } + /// /// Allocate a new native SphereShapeSettings and return the handle. ///