Havok: Add more hkTransformf functions

This commit is contained in:
Léo Lam 2022-01-13 02:14:51 +01:00
parent bcbc8bd2ea
commit 3d9664ed52
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
3 changed files with 55 additions and 1 deletions

View File

@ -1,5 +1,17 @@
#pragma once
#include <Havok/Common/Base/Math/Matrix/hkMatrix3f.h>
#include <Havok/Common/Base/Math/Quaternion/hkQuaternionf.h>
class hkRotationf : public hkMatrix3f {};
class hkRotationf : public hkMatrix3f {
public:
void set(hkQuaternionfParameter q);
void setAxisAngle(hkVector4fParameter axis, hkFloat32 angle);
void setAxisAngle(hkVector4fParameter axis, hkSimdFloat32Parameter angle);
bool isOrthonormal(hkFloat32 epsilon = hkFloat32(1e-5f)) const;
bool isOk() const;
void renormalize();
};

View File

@ -1,16 +1,56 @@
#pragma once
#include <Havok/Common/Base/Math/Matrix/hkRotationf.h>
#include <Havok/Common/Base/Math/Quaternion/hkQuaternionf.h>
#include <Havok/Common/Base/Math/Vector/hkVector4f.h>
class hkTransformf {
public:
HK_FORCE_INLINE hkTransformf() = default;
HK_FORCE_INLINE hkTransformf(const hkTransformf& other);
HK_FORCE_INLINE hkTransformf(const hkRotationf& r, hkVector4fParameter t);
HK_FORCE_INLINE hkTransformf(hkQuaternionfParameter r, hkVector4fParameter t);
hkTransformf& operator=(const hkTransformf& other) = default;
hkRotationf& getRotation() { return m_rotation; }
const hkRotationf& getRotation() const { return m_rotation; }
hkVector4f& getTranslation() { return m_translation; }
const hkVector4f& getTranslation() const { return m_translation; }
HK_FORCE_INLINE void set(const hkRotationf& r, hkVector4fParameter t);
HK_FORCE_INLINE void set(hkQuaternionfParameter q, hkVector4fParameter t);
hkRotationf m_rotation;
hkVector4f m_translation;
};
inline hkTransformf::hkTransformf(const hkTransformf& other) {
const auto col0 = other.m_rotation.m_col0;
const auto col1 = other.m_rotation.m_col1;
const auto col2 = other.m_rotation.m_col2;
const auto col3 = other.m_translation;
m_rotation.m_col0 = col0;
m_rotation.m_col1 = col1;
m_rotation.m_col2 = col2;
m_translation = col3;
}
inline hkTransformf::hkTransformf(const hkRotationf& r, const hkVector4f& t)
: m_rotation(r), m_translation(t) {}
inline hkTransformf::hkTransformf(hkQuaternionfParameter r, const hkVector4f& t)
: m_translation(t) {
m_rotation.set(r);
}
inline void hkTransformf::set(const hkRotationf& r, const hkVector4f& t) {
m_rotation = r;
m_translation = t;
}
inline void hkTransformf::set(const hkQuaternionf& q, const hkVector4f& t) {
m_rotation.set(q);
m_translation = t;
}

View File

@ -2,6 +2,8 @@
#include <Havok/Common/Base/Math/Vector/hkVector4f.h>
using hkQuaternionfParameter = const class hkQuaternionf&;
class hkQuaternionf {
public:
hkQuaternionf() {} // NOLINT(modernize-use-equals-default)