From 53f68bb7b0dce309723675c4b97f726a469031c0 Mon Sep 17 00:00:00 2001 From: Joel Stålnacke Date: Sun, 13 Oct 2024 15:09:24 +0300 Subject: Added more math functions and sanity checks No +/-Inf or NaN in my vectors please :) --- Djup.Native/LibDjup.cs | 9 +++++++++ Djup.Native/Types.cs | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'Djup.Native') 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; } -- cgit v1.2.3