diff options
| author | Joel Stålnacke <joel@saker.fi> | 2024-10-13 15:09:24 +0300 |
|---|---|---|
| committer | Joel Stålnacke <joel@saker.fi> | 2024-10-13 15:09:24 +0300 |
| commit | 53f68bb7b0dce309723675c4b97f726a469031c0 (patch) | |
| tree | bb156bf099abd5b054822bb7a0cc59cd1ec036c7 /Djup.Native | |
| parent | 6a9b5df8b5ed811fbfde9c78f2599247751a650f (diff) | |
Added more math functions and sanity checks
No +/-Inf or NaN in my vectors please :)
Diffstat (limited to 'Djup.Native')
| -rw-r--r-- | Djup.Native/LibDjup.cs | 9 | ||||
| -rw-r--r-- | Djup.Native/Types.cs | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Djup.Native/LibDjup.cs b/Djup.Native/LibDjup.cs index 0ecf7a8..0b4a3db 100644 --- a/Djup.Native/LibDjup.cs +++ b/Djup.Native/LibDjup.cs @@ -16,6 +16,15 @@ public static partial class LibDjup [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(get_vec2))] public static partial Vec2 get_vec2(); + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(vec2_mul))] + public static partial Vec2 vec2_mul(Vec2 v, float scalar); + + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(vec2_normal))] + public static partial Vec2 vec2_normal(Vec2 v); + + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(vec2_length))] + public static partial float vec2_length(Vec2 v); + [LibraryImport(LibraryName, EntryPoint = Prefix + nameof(log_set_output))] public static partial Vec2 log_set_output([MarshalAs(UnmanagedType.FunctionPtr)] LoggerDelegate logger); diff --git a/Djup.Native/Types.cs b/Djup.Native/Types.cs index 572277f..478208f 100644 --- a/Djup.Native/Types.cs +++ b/Djup.Native/Types.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using System.Runtime.InteropServices; namespace Djup.Native; @@ -10,6 +11,9 @@ public struct Vec2 public Vec2(float x, float y) { + Debug.Assert(float.IsFinite(x)); + Debug.Assert(float.IsFinite(y)); + X = x; Y = y; } |
