From e681906faa0e229eb2b281238668466194ce6005 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 31 May 2023 00:19:21 +0200 Subject: [PATCH] Added 2 missing methods to Quaternion. --- gdnative/quaternion.cpp | 11 +++++++++++ include/gdn/quaternion.h | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gdnative/quaternion.cpp b/gdnative/quaternion.cpp index 82491e3..f2266ee 100644 --- a/gdnative/quaternion.cpp +++ b/gdnative/quaternion.cpp @@ -84,11 +84,22 @@ pandemonium_real GDAPI pandemonium_quaternion_length(const pandemonium_quaternio return self->length(); } +void GDAPI pandemonium_quaternion_normalize(pandemonium_quaternion *p_self) { + Quaternion *self = (Quaternion *)p_self; + self->normalize(); +} + pandemonium_real GDAPI pandemonium_quaternion_length_squared(const pandemonium_quaternion *p_self) { const Quaternion *self = (const Quaternion *)p_self; return self->length_squared(); } +pandemonium_bool GDAPI pandemonium_quaternion_is_equal_approx(const pandemonium_quaternion *p_self, const pandemonium_quaternion *p_quat) { + const Quaternion *self = (const Quaternion *)p_self; + const Quaternion *quat = (const Quaternion *)p_quat; + return self->is_equal_approx(*quat); +} + pandemonium_quaternion GDAPI pandemonium_quaternion_normalized(const pandemonium_quaternion *p_self) { pandemonium_quaternion dest; const Quaternion *self = (const Quaternion *)p_self; diff --git a/include/gdn/quaternion.h b/include/gdn/quaternion.h index 2dca35d..78f0d90 100644 --- a/include/gdn/quaternion.h +++ b/include/gdn/quaternion.h @@ -71,9 +71,9 @@ pandemonium_real GDAPI pandemonium_quaternion_get_w(const pandemonium_quaternion void GDAPI pandemonium_quaternion_set_w(pandemonium_quaternion *p_self, const pandemonium_real val); pandemonium_real GDAPI pandemonium_quaternion_length_squared(const pandemonium_quaternion *p_self); -//bool is_equal_approx(const Quaternion &p_quat) const; +pandemonium_bool GDAPI pandemonium_quaternion_is_equal_approx(const pandemonium_quaternion *p_self, const pandemonium_quaternion *p_quat); pandemonium_real GDAPI pandemonium_quaternion_length(const pandemonium_quaternion *p_self); -//void normalize(); +void GDAPI pandemonium_quaternion_normalize(pandemonium_quaternion *p_self); pandemonium_quaternion GDAPI pandemonium_quaternion_normalized(const pandemonium_quaternion *p_self); pandemonium_bool GDAPI pandemonium_quaternion_is_normalized(const pandemonium_quaternion *p_self);