From 0c391fdbce5a079cf03e483eb6174dd47806163d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Aug 2019 21:08:47 +0800 Subject: *misc --- source/modules/asura-utils/Math/Curve.cpp | 0 source/modules/asura-utils/Math/Curve.h | 0 source/modules/asura-utils/Math/Functions.cpp | 0 source/modules/asura-utils/Math/Functions.h | 0 source/modules/asura-utils/Math/Matrix44.cpp | 217 ---------------------- source/modules/asura-utils/Math/Matrix44.h | 96 ---------- source/modules/asura-utils/Math/Quaternion.cpp | 0 source/modules/asura-utils/Math/Quaternion.h | 0 source/modules/asura-utils/Math/Rand/Rand.h | 88 --------- source/modules/asura-utils/Math/Rand/Random.h | 9 - source/modules/asura-utils/Math/RangedValue.cpp | 0 source/modules/asura-utils/Math/RangedValue.h | 0 source/modules/asura-utils/Math/Rect.hpp | 50 ----- source/modules/asura-utils/Math/Rect.inc | 28 --- source/modules/asura-utils/Math/Transform.cpp | 0 source/modules/asura-utils/Math/Transform.h | 30 --- source/modules/asura-utils/Math/Vector2.hpp | 72 -------- source/modules/asura-utils/Math/Vector2.inc | 114 ------------ source/modules/asura-utils/Math/Vector3.hpp | 235 ------------------------ source/modules/asura-utils/Math/Vector3.inc | 145 --------------- source/modules/asura-utils/Math/Vector4.h | 234 ----------------------- source/modules/asura-utils/Math/Vector4.inc | 152 --------------- 22 files changed, 1470 deletions(-) delete mode 100644 source/modules/asura-utils/Math/Curve.cpp delete mode 100644 source/modules/asura-utils/Math/Curve.h delete mode 100644 source/modules/asura-utils/Math/Functions.cpp delete mode 100644 source/modules/asura-utils/Math/Functions.h delete mode 100644 source/modules/asura-utils/Math/Matrix44.cpp delete mode 100644 source/modules/asura-utils/Math/Matrix44.h delete mode 100644 source/modules/asura-utils/Math/Quaternion.cpp delete mode 100644 source/modules/asura-utils/Math/Quaternion.h delete mode 100644 source/modules/asura-utils/Math/Rand/Rand.h delete mode 100644 source/modules/asura-utils/Math/Rand/Random.h delete mode 100644 source/modules/asura-utils/Math/RangedValue.cpp delete mode 100644 source/modules/asura-utils/Math/RangedValue.h delete mode 100644 source/modules/asura-utils/Math/Rect.hpp delete mode 100644 source/modules/asura-utils/Math/Rect.inc delete mode 100644 source/modules/asura-utils/Math/Transform.cpp delete mode 100644 source/modules/asura-utils/Math/Transform.h delete mode 100644 source/modules/asura-utils/Math/Vector2.hpp delete mode 100644 source/modules/asura-utils/Math/Vector2.inc delete mode 100644 source/modules/asura-utils/Math/Vector3.hpp delete mode 100644 source/modules/asura-utils/Math/Vector3.inc delete mode 100644 source/modules/asura-utils/Math/Vector4.h delete mode 100644 source/modules/asura-utils/Math/Vector4.inc (limited to 'source/modules/asura-utils/Math') diff --git a/source/modules/asura-utils/Math/Curve.cpp b/source/modules/asura-utils/Math/Curve.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Curve.h b/source/modules/asura-utils/Math/Curve.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Functions.cpp b/source/modules/asura-utils/Math/Functions.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Functions.h b/source/modules/asura-utils/Math/Functions.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Matrix44.cpp b/source/modules/asura-utils/Math/Matrix44.cpp deleted file mode 100644 index 9ecf448..0000000 --- a/source/modules/asura-utils/Math/Matrix44.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "Matrix44.h" - -#include // memcpy -#include - -namespace AsuraEngine -{ - namespace Math - { - - const Matrix44 Matrix44::Identity; - - // | e0 e4 e8 e12 | - // | e1 e5 e9 e13 | - // | e2 e6 e10 e14 | - // | e3 e7 e11 e15 | - - Matrix44::Matrix44() - { - SetIdentity(); - } - - Matrix44::Matrix44(const Matrix44& m) - { - memcpy(&e, &m.e, 16 * sizeof(float)); - } - - Matrix44::~Matrix44() - { - } - - void Matrix44::operator = (const Matrix44& m) - { - memcpy(&e, &m.e, 16 * sizeof(float)); - } - - void Matrix44::SetOrtho(float l, float r, float b, float t, float n, float f) - { - SetIdentity(); - float w = r - l; - float h = t - b; - float z = f - n; - e[0] = 2 / w; - e[5] = 2 / h; - e[10] = -2 / z; - e[12] = -(r + l) / w; - e[13] = -(t + b) / h; - e[14] = -(f + n) / z; - e[15] = 1; - } - - // | e0 e4 e8 e12 | - // | e1 e5 e9 e13 | - // | e2 e6 e10 e14 | - // | e3 e7 e11 e15 | - // | e0 e4 e8 e12 | - // | e1 e5 e9 e13 | - // | e2 e6 e10 e14 | - // | e3 e7 e11 e15 | - - Matrix44 Matrix44::operator * (const Matrix44 & m) const - { - Matrix44 t; - - t.e[0] = (e[0] * m.e[0]) + (e[4] * m.e[1]) + (e[8] * m.e[2]) + (e[12] * m.e[3]); - t.e[4] = (e[0] * m.e[4]) + (e[4] * m.e[5]) + (e[8] * m.e[6]) + (e[12] * m.e[7]); - t.e[8] = (e[0] * m.e[8]) + (e[4] * m.e[9]) + (e[8] * m.e[10]) + (e[12] * m.e[11]); - t.e[12] = (e[0] * m.e[12]) + (e[4] * m.e[13]) + (e[8] * m.e[14]) + (e[12] * m.e[15]); - - t.e[1] = (e[1] * m.e[0]) + (e[5] * m.e[1]) + (e[9] * m.e[2]) + (e[13] * m.e[3]); - t.e[5] = (e[1] * m.e[4]) + (e[5] * m.e[5]) + (e[9] * m.e[6]) + (e[13] * m.e[7]); - t.e[9] = (e[1] * m.e[8]) + (e[5] * m.e[9]) + (e[9] * m.e[10]) + (e[13] * m.e[11]); - t.e[13] = (e[1] * m.e[12]) + (e[5] * m.e[13]) + (e[9] * m.e[14]) + (e[13] * m.e[15]); - - t.e[2] = (e[2] * m.e[0]) + (e[6] * m.e[1]) + (e[10] * m.e[2]) + (e[14] * m.e[3]); - t.e[6] = (e[2] * m.e[4]) + (e[6] * m.e[5]) + (e[10] * m.e[6]) + (e[14] * m.e[7]); - t.e[10] = (e[2] * m.e[8]) + (e[6] * m.e[9]) + (e[10] * m.e[10]) + (e[14] * m.e[11]); - t.e[14] = (e[2] * m.e[12]) + (e[6] * m.e[13]) + (e[10] * m.e[14]) + (e[14] * m.e[15]); - - t.e[3] = (e[3] * m.e[0]) + (e[7] * m.e[1]) + (e[11] * m.e[2]) + (e[15] * m.e[3]); - t.e[7] = (e[3] * m.e[4]) + (e[7] * m.e[5]) + (e[11] * m.e[6]) + (e[15] * m.e[7]); - t.e[11] = (e[3] * m.e[8]) + (e[7] * m.e[9]) + (e[11] * m.e[10]) + (e[15] * m.e[11]); - t.e[15] = (e[3] * m.e[12]) + (e[7] * m.e[13]) + (e[11] * m.e[14]) + (e[15] * m.e[15]); - - return t; - } - - void Matrix44::operator *= (const Matrix44 & m) - { - Matrix44 t = (*this) * m; - memcpy((void*)this->e, (void*)t.e, sizeof(float) * 16); - } - - const float * Matrix44::GetElements() const - { - return e; - } - - void Matrix44::SetIdentity() - { - memset(e, 0, sizeof(float) * 16); - e[0] = e[5] = e[10] = e[15] = 1; - } - - void Matrix44::SetTranslation(float x, float y) - { - SetIdentity(); - e[12] = x; - e[13] = y; - } - - void Matrix44::SetRotation(float rad) - { - SetIdentity(); - float c = cos(rad), s = sin(rad); - e[0] = c; e[4] = -s; - e[1] = s; e[5] = c; - } - - void Matrix44::SetScale(float sx, float sy) - { - SetIdentity(); - e[0] = sx; - e[5] = sy; - } - - void Matrix44::SetShear(float kx, float ky) - { - SetIdentity(); - e[1] = ky; - e[4] = kx; - } - - void Matrix44::SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy) - { - memset(e, 0, sizeof(float) * 16); // zero out matrix - float c = cos(angle), s = sin(angle); - // matrix multiplication carried out on paper: - // |1 x| |c -s | |sx | |1 -ox| - // | 1 y| |s c | | sy | | 1 -oy| - // | 1 | | 1 | | 1 | | 1 | - // | 1| | 1| | 1| | 1 | - // move rotate scale origin - e[10] = e[15] = 1.0f; - e[0] = c * sx; // = a - e[1] = s * sx; // = b - e[4] = -s * sy; // = c - e[5] = c * sy; // = d - e[12] = x - ox * e[0] - oy * e[4]; - e[13] = y - ox * e[1] - oy * e[5]; - } - - void Matrix44::Translate(float x, float y) - { - Matrix44 t; - t.SetTranslation(x, y); - this->operator *=(t); - } - - void Matrix44::Rotate(float rad) - { - Matrix44 t; - t.SetRotation(rad); - this->operator *=(t); - } - - void Matrix44::Scale(float sx, float sy) - { - Matrix44 t; - t.SetScale(sx, sy); - this->operator *=(t); - } - - void Matrix44::Shear(float kx, float ky) - { - Matrix44 t; - t.SetShear(kx, ky); - this->operator *=(t); - } - - void Matrix44::Transform(float x, float y, float angle, float sx, float sy, float ox, float oy) - { - Matrix44 t; - t.SetTransformation(x, y, angle, sx, sy, ox, oy); - this->operator *=(t); - } - - void Matrix44::Ortho(float left, float right, float bottom, float top, float near, float far) - { - Matrix44 t; - t.SetOrtho(left, right, bottom, top, near, far); - this->operator *=(t); - } - - // | x | - // | y | - // | 0 | - // | 1 | - // | e0 e4 e8 e12 | - // | e1 e5 e9 e13 | - // | e2 e6 e10 e14 | - // | e3 e7 e11 e15 | - - //void Matrix44::transform(Graphics::Vertex* dst, const Graphics::Vertex* src, int size) const - //{ - // for (int i = 0; i - -#include "../Scripting/Portable.hpp" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -/// 不需要转置的OpenGL矩阵,类似glm::mat4。 -/// https://blog.csdn.net/candycat1992/article/details/8830894 -class Matrix44 -{ -public: - - static const Matrix44 Identity; - - Matrix44(); - - Matrix44(const Matrix44& m); - - ~Matrix44(); - - void operator = (const Matrix44& m); - - void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far); - - Matrix44 operator * (const Matrix44 & m) const; - - void operator *= (const Matrix44 & m); - - const float* GetElements() const; - - void SetIdentity(); - - void SetTranslation(float x, float y); - - void SetRotation(float r); - - void SetScale(float sx, float sy); - - void SetShear(float kx, float ky); - - void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy); - - void Translate(float x, float y); - - void Rotate(float r); - - void Scale(float sx, float sy); - - void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy); - - /// - /// Multiplies this Matrix44 with a shear transformation. - /// @param kx Shear along the x-axis. - /// @param ky Shear along the y-axis. - /// - void Shear(float kx, float ky); - - void Ortho(float left, float right, float bottom, float top, float near, float far); - - ///// - ///// Transforms an array of vertices by this Matrix44. The sources and - ///// destination arrays may be the same. - ///// - ///// @param dst Storage for the transformed vertices. - ///// @param src The source vertices. - ///// @param size The number of vertices. - ///// - //void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; - - /// - /// 计算行列式 - /// - float Calculate(); - -private: - - /// - /// | e0 e4 e8 e12 | - /// | e1 e5 e9 e13 | - /// | e2 e6 e10 e14 | - /// | e3 e7 e11 e15 | - /// - float e[16]; - -}; - -namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Quaternion.cpp b/source/modules/asura-utils/Math/Quaternion.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Quaternion.h b/source/modules/asura-utils/Math/Quaternion.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Rand/Rand.h b/source/modules/asura-utils/Math/Rand/Rand.h deleted file mode 100644 index 74b1102..0000000 --- a/source/modules/asura-utils/Math/Rand/Rand.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef RAND_H -#define RAND_H - -#include "../../Type.h" -#include "../../Classes.h" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -/* -Some random generator timings: -MacBook Pro w/ Core 2 Duo 2.4GHz. Times are for gcc 4.0.1 (OS X 10.6.2) / VS2008 SP1 (Win XP SP3), -in milliseconds for this loop (4915200 calls): - -for (int j = 0; j < 100; ++j) -for (int i = 0; i < 128*128*3; ++i) -data[i] = (rnd.get() & 0x3) << 6; - -gcc vs2008 Size -C's rand(): 57.0 109.3 ms 1 -Mersenne Twister: 56.0 37.4 ms 2500 -Unity 2.x LCG: 11.1 9.2 ms 4 -Xorshift 128: 15.0 17.8 ms 16 -Xorshift 32: 20.6 10.7 ms 4 -WELL 512: 43.6 55.1 ms 68 -*/ - -// Xorshift 128 implementation -// Xorshift paper: http://www.jstatsoft.org/v08/i14/paper -// Wikipedia: http://en.wikipedia.org/wiki/Xorshift -class Rand { -public: - - Rand(uint32 seed = 0) - { - SetSeed(seed); - } - - uint32 Get() - { - uint32 t; - t = x ^ (x << 11); - x = y; y = z; z = w; - return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); - } - - inline static float GetFloatFromInt(uint32 value) - { - // take 23 bits of integer, and divide by 2^23-1 - return float(value & 0x007FFFFF) * (1.0f / 8388607.0f); - } - - inline static uint8 GetByteFromInt(uint32 value) - { - // take the most significant byte from the 23-bit value - return uint8(value >> (23 - 8)); - } - - // random number between 0.0 and 1.0 - float GetFloat() - { - return GetFloatFromInt(Get()); - } - - // random number between -1.0 and 1.0 - float GetSignedFloat() - { - return GetFloat() * 2.0f - 1.0f; - } - - void SetSeed(uint32 seed) - { - x = seed; - y = x * 1812433253U + 1; - z = y * 1812433253U + 1; - w = z * 1812433253U + 1; - } - - uint32 GetSeed() const { return x; } - -private: - uint32 x, y, z, w; -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Rand/Random.h b/source/modules/asura-utils/Math/Rand/Random.h deleted file mode 100644 index cf2fc54..0000000 --- a/source/modules/asura-utils/Math/Rand/Random.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "Rand.h" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - - - -namespace_end -namespace_end \ No newline at end of file diff --git a/source/modules/asura-utils/Math/RangedValue.cpp b/source/modules/asura-utils/Math/RangedValue.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/RangedValue.h b/source/modules/asura-utils/Math/RangedValue.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Rect.hpp b/source/modules/asura-utils/Math/Rect.hpp deleted file mode 100644 index 45bf1ba..0000000 --- a/source/modules/asura-utils/Math/Rect.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _ASURA_ENGINE_RECT_H_ -#define _ASURA_ENGINE_RECT_H_ - -namespace AsuraEngine -{ - namespace Math - { - - template - struct Rect - { - public: - Rect(); - Rect(T x, T y, T w, T h); - ~Rect() {}; - - /// - /// x,y是否落在rect内。 - /// - bool Contain(T x, T y); - - /// - /// 两个矩形是否相交,并返回相交的矩形 - /// - bool Intersect(const Rect& src, Rect& intersection); - - /// - /// 两个矩形是否相交,并返回相交的矩形 - /// - static bool Intersect(const Rect& src1, const Rect& src2, Rect& intersection); - - void Set(T x, T y, T w, T h); - - T x, y, w, h; - }; - -#include "Rect.inc" - - // Define the most common types - typedef Rect Recti; - typedef Rect Rectu; - typedef Rect Rectf; - typedef Rect Reftl; - - } -} - -namespace AEMath = AsuraEngine::Math; - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Rect.inc b/source/modules/asura-utils/Math/Rect.inc deleted file mode 100644 index efafbf9..0000000 --- a/source/modules/asura-utils/Math/Rect.inc +++ /dev/null @@ -1,28 +0,0 @@ -template -inline Rect::Rect() - : x(0) - , y(0) - , w(0) - , h(0) -{ - -} - -template -inline Rect::Rect(T X, T Y, T W, T H) - : x(X) - , y(Y) - , w(W) - , h(H) -{ - -} - -template -void Rect::Set(T X, T Y, T W, T H) -{ - x = X; - y = Y; - w = W; - h = H; -} \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Transform.cpp b/source/modules/asura-utils/Math/Transform.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-utils/Math/Transform.h b/source/modules/asura-utils/Math/Transform.h deleted file mode 100644 index 23d0709..0000000 --- a/source/modules/asura-utils/Math/Transform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ASURA_ENGINE_TRANSFORM_H_ -#define _ASURA_ENGINE_TRANSFORM_H_ - -#include "../scripting/Portable.hpp" - -namespace AsuraEngine -{ - namespace Math - { - - class Transform - { - public: - - void Set(float x, float y, float sx, float sy, float ox, float oy, float r); - - void LoadIdentity(); - - void Move(float dx = 0, float dy = 0); - void Rotate(float r); - void Scale(float sx, float sy); - - float m[16]; //4x4 matrix - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector2.hpp b/source/modules/asura-utils/Math/Vector2.hpp deleted file mode 100644 index 326a57e..0000000 --- a/source/modules/asura-utils/Math/Vector2.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR2_H__ -#define _ASURA_ENGINE_VECTOR2_H__ - -#include - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -template -class Vector2 -{ -public: - Vector2(); - Vector2(T X, T Y); - - template - explicit Vector2(const Vector2& vector); - - void Set(T X, T Y); - - T x; ///< X coordinate of the vector - T y; ///< Y coordinate of the vector -}; - -template -Vector2 operator -(const Vector2& right); - -template -Vector2& operator +=(Vector2& left, const Vector2& right); - -template -Vector2& operator -=(Vector2& left, const Vector2& right); - -template -Vector2 operator +(const Vector2& left, const Vector2& right); - -template -Vector2 operator -(const Vector2& left, const Vector2& right); - -template -Vector2 operator *(const Vector2& left, T right); - -template -Vector2 operator *(T left, const Vector2& right); - -template -Vector2& operator *=(Vector2& left, T right); - -template -Vector2 operator /(const Vector2& left, T right); - -template -Vector2& operator /=(Vector2& left, T right); - -template -bool operator ==(const Vector2& left, const Vector2& right); - -template -bool operator !=(const Vector2& left, const Vector2& right); - -#include "Vector2.inc" - -typedef Vector2 Vector2i; -typedef Vector2 Vector2u; -typedef Vector2 Vector2f; - -namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector2.inc b/source/modules/asura-utils/Math/Vector2.inc deleted file mode 100644 index 155432a..0000000 --- a/source/modules/asura-utils/Math/Vector2.inc +++ /dev/null @@ -1,114 +0,0 @@ -template -inline Vector2::Vector2() : - x(0), - y(0) -{ - -} - -template -inline Vector2::Vector2(T X, T Y) : - x(X), - y(Y) -{ - -} - -template -template -inline Vector2::Vector2(const Vector2& vector) : - x(static_cast(vector.x)), - y(static_cast(vector.y)) -{ -} - -template -inline void Vector2::Set(T X, T Y) -{ - x = X; - y = Y; -} - -template -inline Vector2 operator -(const Vector2& right) -{ - return Vector2(-right.x, -right.y); -} - -template -inline Vector2& operator +=(Vector2& left, const Vector2& right) -{ - left.x += right.x; - left.y += right.y; - - return left; -} - -template -inline Vector2& operator -=(Vector2& left, const Vector2& right) -{ - left.x -= right.x; - left.y -= right.y; - - return left; -} - -template -inline Vector2 operator +(const Vector2& left, const Vector2& right) -{ - return Vector2(left.x + right.x, left.y + right.y); -} - -template -inline Vector2 operator -(const Vector2& left, const Vector2& right) -{ - return Vector2(left.x - right.x, left.y - right.y); -} - -template -inline Vector2 operator *(const Vector2& left, T right) -{ - return Vector2(left.x * right, left.y * right); -} - -template -inline Vector2 operator *(T left, const Vector2& right) -{ - return Vector2(right.x * left, right.y * left); -} - -template -inline Vector2& operator *=(Vector2& left, T right) -{ - left.x *= right; - left.y *= right; - - return left; -} - -template -inline Vector2 operator /(const Vector2& left, T right) -{ - return Vector2(left.x / right, left.y / right); -} - -template -inline Vector2& operator /=(Vector2& left, T right) -{ - left.x /= right; - left.y /= right; - - return left; -} - -template -inline bool operator ==(const Vector2& left, const Vector2& right) -{ - return (left.x == right.x) && (left.y == right.y); -} - -template -inline bool operator !=(const Vector2& left, const Vector2& right) -{ - return (left.x != right.x) || (left.y != right.y); -} diff --git a/source/modules/asura-utils/Math/Vector3.hpp b/source/modules/asura-utils/Math/Vector3.hpp deleted file mode 100644 index c526ace..0000000 --- a/source/modules/asura-utils/Math/Vector3.hpp +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR3_H__ -#define _ASURA_ENGINE_VECTOR3_H__ - -namespace AsuraEngine -{ - namespace Math - { - template - class Vector3 - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Default constructor - /// - /// Creates a Vector3(0, 0, 0). - /// - //////////////////////////////////////////////////////////// - Vector3(); - - //////////////////////////////////////////////////////////// - /// \brief Construct the vector from its coordinates - /// - /// \param X X coordinate - /// \param Y Y coordinate - /// \param Z Z coordinate - /// - //////////////////////////////////////////////////////////// - Vector3(T X, T Y, T Z); - - //////////////////////////////////////////////////////////// - /// \brief Construct the vector from another type of vector - /// - /// This constructor doesn't replace the copy constructor, - /// it's called only when U != T. - /// A call to this constructor will fail to compile if U - /// is not convertible to T. - /// - /// \param vector Vector to convert - /// - //////////////////////////////////////////////////////////// - template - explicit Vector3(const Vector3& vector); - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - T x; ///< X coordinate of the vector - T y; ///< Y coordinate of the vector - T z; ///< Z coordinate of the vector - }; - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of unary operator - - /// - /// \param left Vector to negate - /// - /// \return Memberwise opposite of the vector - /// - //////////////////////////////////////////////////////////// - template - Vector3 operator -(const Vector3& left); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator += - /// - /// This operator performs a memberwise addition of both vectors, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector3& operator +=(Vector3& left, const Vector3& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator -= - /// - /// This operator performs a memberwise subtraction of both vectors, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector3& operator -=(Vector3& left, const Vector3& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator + - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Memberwise addition of both vectors - /// - //////////////////////////////////////////////////////////// - template - Vector3 operator +(const Vector3& left, const Vector3& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator - - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Memberwise subtraction of both vectors - /// - //////////////////////////////////////////////////////////// - template - Vector3 operator -(const Vector3& left, const Vector3& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator * - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Memberwise multiplication by \a right - /// - //////////////////////////////////////////////////////////// - template - Vector3 operator *(const Vector3& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator * - /// - /// \param left Left operand (a scalar value) - /// \param right Right operand (a vector) - /// - /// \return Memberwise multiplication by \a left - /// - //////////////////////////////////////////////////////////// - template - Vector3 operator *(T left, const Vector3& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator *= - /// - /// This operator performs a memberwise multiplication by \a right, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector3& operator *=(Vector3& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator / - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Memberwise division by \a right - /// - //////////////////////////////////////////////////////////// - template - Vector3 operator /(const Vector3& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator /= - /// - /// This operator performs a memberwise division by \a right, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector3& operator /=(Vector3& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator == - /// - /// This operator compares strict equality between two vectors. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return True if \a left is equal to \a right - /// - //////////////////////////////////////////////////////////// - template - bool operator ==(const Vector3& left, const Vector3& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector3 - /// \brief Overload of binary operator != - /// - /// This operator compares strict difference between two vectors. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return True if \a left is not equal to \a right - /// - //////////////////////////////////////////////////////////// - template - bool operator !=(const Vector3& left, const Vector3& right); - -#include "Vector3.inc" - - // Define the most common types - typedef Vector3 Vector3i; - typedef Vector3 Vector3f; - - } -} - -namespace AEMath = AsuraEngine::Math; - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector3.inc b/source/modules/asura-utils/Math/Vector3.inc deleted file mode 100644 index 3a2aa93..0000000 --- a/source/modules/asura-utils/Math/Vector3.inc +++ /dev/null @@ -1,145 +0,0 @@ - - -//////////////////////////////////////////////////////////// -template -inline Vector3::Vector3() : - x(0), - y(0), - z(0) -{ - -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3::Vector3(T X, T Y, T Z) : - x(X), - y(Y), - z(Z) -{ - -} - - -//////////////////////////////////////////////////////////// -template -template -inline Vector3::Vector3(const Vector3& vector) : - x(static_cast(vector.x)), - y(static_cast(vector.y)), - z(static_cast(vector.z)) -{ -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3 operator -(const Vector3& left) -{ - return Vector3(-left.x, -left.y, -left.z); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3& operator +=(Vector3& left, const Vector3& right) -{ - left.x += right.x; - left.y += right.y; - left.z += right.z; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3& operator -=(Vector3& left, const Vector3& right) -{ - left.x -= right.x; - left.y -= right.y; - left.z -= right.z; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3 operator +(const Vector3& left, const Vector3& right) -{ - return Vector3(left.x + right.x, left.y + right.y, left.z + right.z); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3 operator -(const Vector3& left, const Vector3& right) -{ - return Vector3(left.x - right.x, left.y - right.y, left.z - right.z); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3 operator *(const Vector3& left, T right) -{ - return Vector3(left.x * right, left.y * right, left.z * right); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3 operator *(T left, const Vector3& right) -{ - return Vector3(right.x * left, right.y * left, right.z * left); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3& operator *=(Vector3& left, T right) -{ - left.x *= right; - left.y *= right; - left.z *= right; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3 operator /(const Vector3& left, T right) -{ - return Vector3(left.x / right, left.y / right, left.z / right); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector3& operator /=(Vector3& left, T right) -{ - left.x /= right; - left.y /= right; - left.z /= right; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline bool operator ==(const Vector3& left, const Vector3& right) -{ - return (left.x == right.x) && (left.y == right.y) && (left.z == right.z); -} - - -//////////////////////////////////////////////////////////// -template -inline bool operator !=(const Vector3& left, const Vector3& right) -{ - return (left.x != right.x) || (left.y != right.y) || (left.z != right.z); -} diff --git a/source/modules/asura-utils/Math/Vector4.h b/source/modules/asura-utils/Math/Vector4.h deleted file mode 100644 index a5bf549..0000000 --- a/source/modules/asura-utils/Math/Vector4.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR4_H__ -#define _ASURA_ENGINE_VECTOR4_H__ - -namespace AsuraEngine -{ - namespace Math - { - template - class Vector4 - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Default constructor - /// - /// Creates a Vector4(0, 0, 0). - /// - //////////////////////////////////////////////////////////// - Vector4(); - - //////////////////////////////////////////////////////////// - /// \brief Construct the vector from its coordinates - /// - /// \param X X coordinate - /// \param Y Y coordinate - /// \param Z Z coordinate - /// - //////////////////////////////////////////////////////////// - Vector4(T X, T Y, T Z, T W); - - //////////////////////////////////////////////////////////// - /// \brief Construct the vector from another type of vector - /// - /// This constructor doesn't replace the copy constructor, - /// it's called only when U != T. - /// A call to this constructor will fail to compile if U - /// is not convertible to T. - /// - /// \param vector Vector to convert - /// - //////////////////////////////////////////////////////////// - template - explicit Vector4(const Vector4& vector); - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - T x; ///< X coordinate of the vector - T y; ///< Y coordinate of the vector - T z; ///< Z coordinate of the vector - T w; ///< W coordinate of the vector - }; - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of unary operator - - /// - /// \param left Vector to negate - /// - /// \return Memberwise opposite of the vector - /// - //////////////////////////////////////////////////////////// - template - Vector4 operator -(const Vector4& left); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator += - /// - /// This operator performs a memberwise addition of both vectors, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector4& operator +=(Vector4& left, const Vector4& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator -= - /// - /// This operator performs a memberwise subtraction of both vectors, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector4& operator -=(Vector4& left, const Vector4& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator + - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Memberwise addition of both vectors - /// - //////////////////////////////////////////////////////////// - template - Vector4 operator +(const Vector4& left, const Vector4& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator - - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return Memberwise subtraction of both vectors - /// - //////////////////////////////////////////////////////////// - template - Vector4 operator -(const Vector4& left, const Vector4& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator * - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Memberwise multiplication by \a right - /// - //////////////////////////////////////////////////////////// - template - Vector4 operator *(const Vector4& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator * - /// - /// \param left Left operand (a scalar value) - /// \param right Right operand (a vector) - /// - /// \return Memberwise multiplication by \a left - /// - //////////////////////////////////////////////////////////// - template - Vector4 operator *(T left, const Vector4& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator *= - /// - /// This operator performs a memberwise multiplication by \a right, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector4& operator *=(Vector4& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator / - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Memberwise division by \a right - /// - //////////////////////////////////////////////////////////// - template - Vector4 operator /(const Vector4& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator /= - /// - /// This operator performs a memberwise division by \a right, - /// and assigns the result to \a left. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a scalar value) - /// - /// \return Reference to \a left - /// - //////////////////////////////////////////////////////////// - template - Vector4& operator /=(Vector4& left, T right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator == - /// - /// This operator compares strict equality between two vectors. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return True if \a left is equal to \a right - /// - //////////////////////////////////////////////////////////// - template - bool operator ==(const Vector4& left, const Vector4& right); - - //////////////////////////////////////////////////////////// - /// \relates Vector4 - /// \brief Overload of binary operator != - /// - /// This operator compares strict difference between two vectors. - /// - /// \param left Left operand (a vector) - /// \param right Right operand (a vector) - /// - /// \return True if \a left is not equal to \a right - /// - //////////////////////////////////////////////////////////// - template - bool operator !=(const Vector4& left, const Vector4& right); - -#include "Vector4.inc" - - // Define the most common types - typedef Vector4 Vector4i; - typedef Vector4 Vector4f; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector4.inc b/source/modules/asura-utils/Math/Vector4.inc deleted file mode 100644 index 4b043a1..0000000 --- a/source/modules/asura-utils/Math/Vector4.inc +++ /dev/null @@ -1,152 +0,0 @@ - - -//////////////////////////////////////////////////////////// -template -inline Vector4::Vector4() : - x(0), - y(0), - z(0), - w(0) -{ - -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4::Vector4(T X, T Y, T Z, T W) : - x(X), - y(Y), - z(Z), - w(W) -{ - -} - - -//////////////////////////////////////////////////////////// -template -template -inline Vector4::Vector4(const Vector4& vector) : - x(static_cast(vector.x)), - y(static_cast(vector.y)), - z(static_cast(vector.z)), - w(static_cast(vector.w)) -{ -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4 operator -(const Vector4& left) -{ - return Vector4(-left.x, -left.y, -left.z, -left.w); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4& operator +=(Vector4& left, const Vector4& right) -{ - left.x += right.x; - left.y += right.y; - left.z += right.z; - left.w += right.w; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4& operator -=(Vector4& left, const Vector4& right) -{ - left.x -= right.x; - left.y -= right.y; - left.z -= right.z; - left.w -= right.w; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4 operator +(const Vector4& left, const Vector4& right) -{ - return Vector4(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4 operator -(const Vector4& left, const Vector4& right) -{ - return Vector4(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4 operator *(const Vector4& left, T right) -{ - return Vector4(left.x * right, left.y * right, left.z * right, left.w * right); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4 operator *(T left, const Vector4& right) -{ - return Vector4(right.x * left, right.y * left, right.z * left, right.w * left); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4& operator *=(Vector4& left, T right) -{ - left.x *= right; - left.y *= right; - left.z *= right; - left.w *= right; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4 operator /(const Vector4& left, T right) -{ - return Vector4(left.x / right, left.y / right, left.z / right, left.w / right); -} - - -//////////////////////////////////////////////////////////// -template -inline Vector4& operator /=(Vector4& left, T right) -{ - left.x /= right; - left.y /= right; - left.z /= right; - left.w /= right; - - return left; -} - - -//////////////////////////////////////////////////////////// -template -inline bool operator ==(const Vector4& left, const Vector4& right) -{ - return (left.x == right.x) && (left.y == right.y) && (left.z == right.z) && (left.w == right.w); -} - - -//////////////////////////////////////////////////////////// -template -inline bool operator !=(const Vector4& left, const Vector4& right) -{ - return (left.x != right.x) || (left.y != right.y) || (left.z != right.z) || (left.w != right.w); -} -- cgit v1.1-26-g67d0