diff --git a/CMakeLists.txt b/CMakeLists.txt index 786b8e9..5fed5f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ add_library(Math include/Global.hpp include/MathLib.hpp include/TVectorUnion.hpp + include/CVector2i.hpp include/CVector2f.hpp include/CVector3f.hpp include/CVector3d.hpp diff --git a/include/CMatrix4f.hpp b/include/CMatrix4f.hpp index 14e96f0..6b59364 100644 --- a/include/CMatrix4f.hpp +++ b/include/CMatrix4f.hpp @@ -132,6 +132,12 @@ public: return ret; } + inline CVector3f multiplyOneOverW(const CVector3f& point) const + { + CVector4f xfVec = *this * point; + return xfVec.toVec3f() / xfVec.w; + } + union { float m[4][4]; diff --git a/include/CTransform.hpp b/include/CTransform.hpp index 37772d5..c73c7a1 100644 --- a/include/CTransform.hpp +++ b/include/CTransform.hpp @@ -126,6 +126,11 @@ public: m_basis[1] -= b0; } + inline CVector3f transposeRotate(const CVector3f& in) const + { + return CVector3f(m_basis[0].dot(in), m_basis[1].dot(in), m_basis[2].dot(in)); + } + inline void scaleBy(float factor) { CTransform xfrm(CMatrix3f(CVector3f(factor, factor, factor))); *this = *this * xfrm; } diff --git a/include/CVector2i.hpp b/include/CVector2i.hpp new file mode 100644 index 0000000..dd41242 --- /dev/null +++ b/include/CVector2i.hpp @@ -0,0 +1,34 @@ +#ifndef CVECTOR2i_HPP +#define CVECTOR2i_HPP + +#include "Global.hpp" +#include "Math.hpp" + +#if ZE_ATHENA_TYPES +#include +#endif + +#include +#include + +namespace Zeus +{ + +class CVector2i +{ +public: + union + { + struct + { + int x, y; + }; + int v[2]; + }; + CVector2i() = default; + CVector2i(int xin, int yin) : x(xin), y(yin) {} +}; + +} + +#endif // CVECTOR2i_HPP diff --git a/include/CVector4f.hpp b/include/CVector4f.hpp index 08f4c50..ded0556 100644 --- a/include/CVector4f.hpp +++ b/include/CVector4f.hpp @@ -88,12 +88,25 @@ public: CVector4f(const CVector3f& other) { +#if __SSE__ + mVec128 = other.mVec128; +#else x = other.x; y = other.y; z = other.z; +#endif w = 1.0f; } + inline CVector3f toVec3f() const + { +#if __SSE__ + return CVector3f(mVec128); +#else + return CVector3f(x, y, z); +#endif + } + CVector4f& operator=(const CColor& other); inline bool operator ==(const CVector4f& rhs) const {