mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Removed the deprecated built-in matrix and vector code.
This commit is contained in:
parent
85444c0ee6
commit
71d0e14a77
|
@ -59,11 +59,6 @@ set(CORE_HEADERS
|
|||
|
||||
# Math
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Misc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Transform4x4f.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector2f.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector2i.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector3f.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector4f.h
|
||||
|
||||
# Renderers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Renderer.h
|
||||
|
@ -136,11 +131,6 @@ set(CORE_SOURCES
|
|||
|
||||
# Math
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Misc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Transform4x4f.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector2f.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector2i.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector3f.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/math/Vector4f.cpp
|
||||
|
||||
# Renderer
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/renderers/Renderer.cpp
|
||||
|
|
|
@ -1,325 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Transform4x4f.cpp
|
||||
//
|
||||
// 4x4 matrix functions.
|
||||
//
|
||||
|
||||
#include "math/Transform4x4f.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// clang-format off
|
||||
const Transform4x4f Transform4x4f::operator*(const Transform4x4f& _other) const
|
||||
{
|
||||
const float* tm = reinterpret_cast<const float*>(this);
|
||||
const float* om = reinterpret_cast<const float*>(&_other);
|
||||
|
||||
return
|
||||
{
|
||||
{
|
||||
tm[ 0] * om[ 0] + tm[ 4] * om[ 1] + tm[ 8] * om[ 2],
|
||||
tm[ 1] * om[ 0] + tm[ 5] * om[ 1] + tm[ 9] * om[ 2],
|
||||
tm[ 2] * om[ 0] + tm[ 6] * om[ 1] + tm[10] * om[ 2],
|
||||
0
|
||||
},
|
||||
{
|
||||
tm[ 0] * om[ 4] + tm[ 4] * om[ 5] + tm[ 8] * om[ 6],
|
||||
tm[ 1] * om[ 4] + tm[ 5] * om[ 5] + tm[ 9] * om[ 6],
|
||||
tm[ 2] * om[ 4] + tm[ 6] * om[ 5] + tm[10] * om[ 6],
|
||||
0
|
||||
},
|
||||
{
|
||||
tm[ 0] * om[ 8] + tm[ 4] * om[ 9] + tm[ 8] * om[10],
|
||||
tm[ 1] * om[ 8] + tm[ 5] * om[ 9] + tm[ 9] * om[10],
|
||||
tm[ 2] * om[ 8] + tm[ 6] * om[ 9] + tm[10] * om[10],
|
||||
0
|
||||
},
|
||||
{
|
||||
tm[ 0] * om[12] + tm[ 4] * om[13] + tm[ 8] * om[14] + tm[12],
|
||||
tm[ 1] * om[12] + tm[ 5] * om[13] + tm[ 9] * om[14] + tm[13],
|
||||
tm[ 2] * om[12] + tm[ 6] * om[13] + tm[10] * om[14] + tm[14],
|
||||
1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const Vector3f Transform4x4f::operator*(const Vector3f& _other) const
|
||||
{
|
||||
const float* tm = reinterpret_cast<const float*>(this);
|
||||
const float* ov = reinterpret_cast<const float*>(&_other);
|
||||
|
||||
return
|
||||
{
|
||||
tm[ 0] * ov[0] + tm[ 4] * ov[1] + tm[ 8] * ov[2] + tm[12],
|
||||
tm[ 1] * ov[0] + tm[ 5] * ov[1] + tm[ 9] * ov[2] + tm[13],
|
||||
tm[ 2] * ov[0] + tm[ 6] * ov[1] + tm[10] * ov[2] + tm[14]
|
||||
};
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::orthoProjection(
|
||||
float _left,
|
||||
float _right,
|
||||
float _bottom,
|
||||
float _top,
|
||||
float _near,
|
||||
float _far)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
|
||||
const float o[6] = { 2 / (_right - _left),
|
||||
2 / (_top - _bottom),
|
||||
-2 / (_far - _near),
|
||||
-(_right + _left) / (_right - _left),
|
||||
-(_top + _bottom) / (_top - _bottom),
|
||||
-(_far + _near) / (_far - _near) };
|
||||
const float temp[12] = { tm[ 0] * o[0],
|
||||
tm[ 1] * o[0],
|
||||
tm[ 2] * o[0],
|
||||
tm[ 4] * o[1],
|
||||
tm[ 5] * o[1],
|
||||
tm[ 6] * o[1],
|
||||
tm[ 8] * o[2],
|
||||
tm[ 9] * o[2],
|
||||
tm[10] * o[2],
|
||||
tm[ 0] * o[3] + tm[ 4] * o[4] + tm[ 8] * o[5] + tm[12],
|
||||
tm[ 1] * o[3] + tm[ 5] * o[4] + tm[ 9] * o[5] + tm[13],
|
||||
tm[ 2] * o[3] + tm[ 6] * o[4] + tm[10] * o[5] + tm[14] };
|
||||
|
||||
tm[ 0] = temp[ 0];
|
||||
tm[ 1] = temp[ 1];
|
||||
tm[ 2] = temp[ 2];
|
||||
tm[ 4] = temp[ 3];
|
||||
tm[ 5] = temp[ 4];
|
||||
tm[ 6] = temp[ 5];
|
||||
tm[ 8] = temp[ 6];
|
||||
tm[ 9] = temp[ 7];
|
||||
tm[10] = temp[ 8];
|
||||
tm[12] = temp[ 9];
|
||||
tm[13] = temp[10];
|
||||
tm[14] = temp[11];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::invert(const Transform4x4f& _other)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* om = reinterpret_cast<const float*>(&_other);
|
||||
|
||||
// Full invert
|
||||
// tm[ 0] = ((om[ 5] * (om[10] * om[15] - om[11] * om[14])) - (om[ 9] * (om[ 6] * om[15] - om[ 7] * om[14])) + (om[13] * (om[ 6] * om[11] - om[ 7] * om[10])));
|
||||
// tm[ 1] = -((om[ 1] * (om[10] * om[15] - om[11] * om[14])) - (om[ 9] * (om[ 2] * om[15] - om[ 3] * om[14])) + (om[13] * (om[ 2] * om[11] - om[ 3] * om[10])));
|
||||
// tm[ 2] = ((om[ 1] * (om[ 6] * om[15] - om[ 7] * om[14])) - (om[ 5] * (om[ 2] * om[15] - om[ 3] * om[14])) + (om[13] * (om[ 2] * om[ 7] - om[ 3] * om[ 6])));
|
||||
// tm[ 3] = -((om[ 1] * (om[ 6] * om[11] - om[ 7] * om[10])) - (om[ 5] * (om[ 2] * om[11] - om[ 3] * om[10])) + (om[ 9] * (om[ 2] * om[ 7] - om[ 3] * om[ 6])));
|
||||
// tm[ 4] = -((om[ 4] * (om[10] * om[15] - om[11] * om[14])) - (om[ 8] * (om[ 6] * om[15] - om[ 7] * om[14])) + (om[12] * (om[ 6] * om[11] - om[ 7] * om[10])));
|
||||
// tm[ 5] = ((om[ 0] * (om[10] * om[15] - om[11] * om[14])) - (om[ 8] * (om[ 2] * om[15] - om[ 3] * om[14])) + (om[12] * (om[ 2] * om[11] - om[ 3] * om[10])));
|
||||
// tm[ 6] = -((om[ 0] * (om[ 6] * om[15] - om[ 7] * om[14])) - (om[ 4] * (om[ 2] * om[15] - om[ 3] * om[14])) + (om[12] * (om[ 2] * om[ 7] - om[ 3] * om[ 6])));
|
||||
// tm[ 7] = ((om[ 0] * (om[ 6] * om[11] - om[ 7] * om[10])) - (om[ 4] * (om[ 2] * om[11] - om[ 3] * om[10])) + (om[ 8] * (om[ 2] * om[ 7] - om[ 3] * om[ 6])));
|
||||
// tm[ 8] = ((om[ 4] * (om[ 9] * om[15] - om[11] * om[13])) - (om[ 8] * (om[ 5] * om[15] - om[ 7] * om[13])) + (om[12] * (om[ 5] * om[11] - om[ 7] * om[ 9])));
|
||||
// tm[ 9] = -((om[ 0] * (om[ 9] * om[15] - om[11] * om[13])) - (om[ 8] * (om[ 1] * om[15] - om[ 3] * om[13])) + (om[12] * (om[ 1] * om[11] - om[ 3] * om[ 9])));
|
||||
// tm[10] = ((om[ 0] * (om[ 5] * om[15] - om[ 7] * om[13])) - (om[ 4] * (om[ 1] * om[15] - om[ 3] * om[13])) + (om[12] * (om[ 1] * om[ 7] - om[ 3] * om[ 5])));
|
||||
// tm[11] = -((om[ 0] * (om[ 5] * om[11] - om[ 7] * om[ 9])) - (om[ 4] * (om[ 1] * om[11] - om[ 3] * om[ 9])) + (om[ 8] * (om[ 1] * om[ 7] - om[ 3] * om[ 5])));
|
||||
// tm[12] = -((om[ 4] * (om[ 9] * om[14] - om[10] * om[13])) - (om[ 8] * (om[ 5] * om[14] - om[ 6] * om[13])) + (om[12] * (om[ 5] * om[10] - om[ 6] * om[ 9])));
|
||||
// tm[13] = ((om[ 0] * (om[ 9] * om[14] - om[10] * om[13])) - (om[ 8] * (om[ 1] * om[14] - om[ 2] * om[13])) + (om[12] * (om[ 1] * om[10] - om[ 2] * om[ 9])));
|
||||
// tm[14] = -((om[ 0] * (om[ 5] * om[14] - om[ 6] * om[13])) - (om[ 4] * (om[ 1] * om[14] - om[ 2] * om[13])) + (om[12] * (om[ 1] * om[ 6] - om[ 2] * om[ 5])));
|
||||
// tm[15] = ((om[ 0] * (om[ 5] * om[10] - om[ 6] * om[ 9])) - (om[ 4] * (om[ 1] * om[10] - om[ 2] * om[ 9])) + (om[ 8] * (om[ 1] * om[ 6] - om[ 2] * om[ 5])));
|
||||
|
||||
// Optimized invert ( om[3, 7 and 11] is always 0, and om[15] is always 1 ).
|
||||
tm[ 0] = ((om[ 5] * om[10]) - (om[ 9] * om[ 6]));
|
||||
tm[ 1] = -((om[ 1] * om[10]) - (om[ 9] * om[ 2]));
|
||||
tm[ 2] = ((om[ 1] * om[ 6]) - (om[ 5] * om[ 2]));
|
||||
tm[ 3] = 0;
|
||||
tm[ 4] = -((om[ 4] * om[10]) - (om[ 8] * om[ 6]));
|
||||
tm[ 5] = ((om[ 0] * om[10]) - (om[ 8] * om[ 2]));
|
||||
tm[ 6] = -((om[ 0] * om[ 6]) - (om[ 4] * om[ 2]));
|
||||
tm[ 7] = 0;
|
||||
tm[ 8] = ((om[ 4] * om[ 9]) - (om[ 8] * om[ 5]));
|
||||
tm[ 9] = -((om[ 0] * om[ 9]) - (om[ 8] * om[ 1]));
|
||||
tm[10] = ((om[ 0] * om[ 5]) - (om[ 4] * om[ 1]));
|
||||
tm[11] = 0;
|
||||
tm[12] = -((om[ 4] * (om[ 9] * om[14] - om[10] * om[13])) - (om[ 8] * (om[ 5] * om[14] - om[ 6] * om[13])) + (om[12] * (om[ 5] * om[10] - om[ 6] * om[ 9])));
|
||||
tm[13] = ((om[ 0] * (om[ 9] * om[14] - om[10] * om[13])) - (om[ 8] * (om[ 1] * om[14] - om[ 2] * om[13])) + (om[12] * (om[ 1] * om[10] - om[ 2] * om[ 9])));
|
||||
tm[14] = -((om[ 0] * (om[ 5] * om[14] - om[ 6] * om[13])) - (om[ 4] * (om[ 1] * om[14] - om[ 2] * om[13])) + (om[12] * (om[ 1] * om[ 6] - om[ 2] * om[ 5])));
|
||||
tm[15] = 1;
|
||||
|
||||
float Determinant = om[ 0] * tm[ 0] +
|
||||
om[ 4] * tm[ 1] +
|
||||
om[ 8] * tm[ 2] +
|
||||
om[12] * tm[ 3];
|
||||
|
||||
if (Determinant != 0)
|
||||
Determinant = 1 / Determinant;
|
||||
|
||||
tm[ 0] *= Determinant;
|
||||
tm[ 1] *= Determinant;
|
||||
tm[ 2] *= Determinant;
|
||||
tm[ 4] *= Determinant;
|
||||
tm[ 5] *= Determinant;
|
||||
tm[ 6] *= Determinant;
|
||||
tm[ 8] *= Determinant;
|
||||
tm[ 9] *= Determinant;
|
||||
tm[10] *= Determinant;
|
||||
tm[12] *= Determinant;
|
||||
tm[13] *= Determinant;
|
||||
tm[14] *= Determinant;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::scale(const Vector3f& _scale)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* sv = reinterpret_cast<const float*>(&_scale);
|
||||
|
||||
tm[ 0] *= sv[0];
|
||||
tm[ 1] *= sv[0];
|
||||
tm[ 2] *= sv[0];
|
||||
tm[ 4] *= sv[1];
|
||||
tm[ 5] *= sv[1];
|
||||
tm[ 6] *= sv[1];
|
||||
tm[ 8] *= sv[2];
|
||||
tm[ 9] *= sv[2];
|
||||
tm[10] *= sv[2];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::rotate(const float _angle, const Vector3f& _axis)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* av = reinterpret_cast<const float*>(&_axis);
|
||||
const float s = sinf(-_angle);
|
||||
const float c = cosf(-_angle);
|
||||
const float t = 1 - c;
|
||||
const float x = av[0];
|
||||
const float y = av[1];
|
||||
const float z = av[2];
|
||||
const float tx = t * x;
|
||||
const float ty = t * y;
|
||||
const float tz = t * z;
|
||||
const float sx = s * x;
|
||||
const float sy = s * y;
|
||||
const float sz = s * z;
|
||||
const float r[9] = { tx * x + c,
|
||||
tx * y - sz,
|
||||
tx * z + sy,
|
||||
ty * x + sz,
|
||||
ty * y + c,
|
||||
ty * z - sx,
|
||||
tz * x - sy,
|
||||
tz * y + sx,
|
||||
tz * z + c };
|
||||
const float temp[9] = { tm[ 0] * r[0] + tm[ 4] * r[1] + tm[ 8] * r[2],
|
||||
tm[ 1] * r[0] + tm[ 5] * r[1] + tm[ 9] * r[2],
|
||||
tm[ 2] * r[0] + tm[ 6] * r[1] + tm[10] * r[2],
|
||||
tm[ 0] * r[3] + tm[ 4] * r[4] + tm[ 8] * r[5],
|
||||
tm[ 1] * r[3] + tm[ 5] * r[4] + tm[ 9] * r[5],
|
||||
tm[ 2] * r[3] + tm[ 6] * r[4] + tm[ 0] * r[5],
|
||||
tm[ 0] * r[6] + tm[ 4] * r[7] + tm[ 8] * r[8],
|
||||
tm[ 1] * r[6] + tm[ 5] * r[7] + tm[ 9] * r[8],
|
||||
tm[ 2] * r[6] + tm[ 6] * r[7] + tm[10] * r[8] };
|
||||
|
||||
tm[ 0] = temp[0];
|
||||
tm[ 1] = temp[1];
|
||||
tm[ 2] = temp[2];
|
||||
tm[ 4] = temp[3];
|
||||
tm[ 5] = temp[4];
|
||||
tm[ 6] = temp[5];
|
||||
tm[ 8] = temp[6];
|
||||
tm[ 9] = temp[7];
|
||||
tm[10] = temp[8];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::rotateX(const float _angle)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float s = sinf(-_angle);
|
||||
const float c = cosf(-_angle);
|
||||
const float temp[6] = { tm[ 4] * c + tm[ 8] * -s,
|
||||
tm[ 5] * c + tm[ 9] * -c,
|
||||
tm[ 6] * c + tm[10] * -s,
|
||||
tm[ 4] * s + tm[ 8] * c,
|
||||
tm[ 5] * s + tm[ 9] * c,
|
||||
tm[ 6] * s + tm[10] * c };
|
||||
|
||||
tm[ 4] = temp[0];
|
||||
tm[ 5] = temp[1];
|
||||
tm[ 6] = temp[2];
|
||||
tm[ 8] = temp[3];
|
||||
tm[ 9] = temp[4];
|
||||
tm[10] = temp[5];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::rotateY(const float _angle)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float s = sinf(-_angle);
|
||||
const float c = cosf(-_angle);
|
||||
const float temp[6] = { tm[ 0] * c + tm[ 8] * s,
|
||||
tm[ 1] * c + tm[ 9] * s,
|
||||
tm[ 2] * c + tm[10] * s,
|
||||
tm[ 0] * -s + tm[ 8] * c,
|
||||
tm[ 1] * -s + tm[ 9] * c,
|
||||
tm[ 2] * -s + tm[10] * c };
|
||||
|
||||
tm[ 0] = temp[0];
|
||||
tm[ 1] = temp[1];
|
||||
tm[ 2] = temp[2];
|
||||
tm[ 8] = temp[3];
|
||||
tm[ 9] = temp[4];
|
||||
tm[10] = temp[5];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::rotateZ(const float _angle)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float s = sinf(-_angle);
|
||||
const float c = cosf(-_angle);
|
||||
const float temp[6] = { tm[ 0] * c + tm[ 4] * -s,
|
||||
tm[ 1] * c + tm[ 5] * -s,
|
||||
tm[ 2] * c + tm[ 6] * -s,
|
||||
tm[ 0] * s + tm[ 4] * c,
|
||||
tm[ 1] * s + tm[ 5] * c,
|
||||
tm[ 2] * s + tm[ 6] * c };
|
||||
|
||||
tm[ 0] = temp[0];
|
||||
tm[ 1] = temp[1];
|
||||
tm[ 2] = temp[2];
|
||||
tm[ 4] = temp[3];
|
||||
tm[ 5] = temp[4];
|
||||
tm[ 6] = temp[5];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::translate(const Vector3f& _translation)
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* tv = reinterpret_cast<const float*>(&_translation);
|
||||
|
||||
tm[12] += tm[ 0] * tv[0] + tm[ 4] * tv[1] + tm[ 8] * tv[2];
|
||||
tm[13] += tm[ 1] * tv[0] + tm[ 5] * tv[1] + tm[ 9] * tv[2];
|
||||
tm[14] += tm[ 2] * tv[0] + tm[ 6] * tv[1] + tm[10] * tv[2];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform4x4f& Transform4x4f::round()
|
||||
{
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
|
||||
tm[12] = std::round(tm[12]);
|
||||
tm[13] = std::round(tm[13]);
|
||||
tm[14] = std::round(tm[14]);
|
||||
|
||||
return *this;
|
||||
}
|
||||
// clang-format on
|
|
@ -1,73 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Transform4x4f.h
|
||||
//
|
||||
// 4x4 matrix functions.
|
||||
//
|
||||
|
||||
#ifndef ES_CORE_MATH_TRANSFORM4X4F_H
|
||||
#define ES_CORE_MATH_TRANSFORM4X4F_H
|
||||
|
||||
#include "math/Vector3f.h"
|
||||
#include "math/Vector4f.h"
|
||||
|
||||
class Transform4x4f
|
||||
{
|
||||
public:
|
||||
Transform4x4f() {}
|
||||
Transform4x4f(const Vector4f& _r0,
|
||||
const Vector4f& _r1,
|
||||
const Vector4f& _r2,
|
||||
const Vector4f& _r3)
|
||||
: mR0(_r0)
|
||||
, mR1(_r1)
|
||||
, mR2(_r2)
|
||||
, mR3(_r3)
|
||||
{
|
||||
}
|
||||
|
||||
const Transform4x4f operator*(const Transform4x4f& _other) const;
|
||||
const Vector3f operator*(const Vector3f& _other) const;
|
||||
Transform4x4f& operator*=(const Transform4x4f& _other)
|
||||
{
|
||||
*this = *this * _other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector4f& r0() { return mR0; }
|
||||
Vector4f& r1() { return mR1; }
|
||||
Vector4f& r2() { return mR2; }
|
||||
Vector4f& r3() { return mR3; }
|
||||
const Vector4f& r0() const { return mR0; }
|
||||
const Vector4f& r1() const { return mR1; }
|
||||
const Vector4f& r2() const { return mR2; }
|
||||
const Vector4f& r3() const { return mR3; }
|
||||
|
||||
Transform4x4f& orthoProjection(
|
||||
float _left, float _right, float _bottom, float _top, float _near, float _far);
|
||||
Transform4x4f& invert(const Transform4x4f& _other);
|
||||
Transform4x4f& scale(const Vector3f& _scale);
|
||||
Transform4x4f& rotate(const float _angle, const Vector3f& _axis);
|
||||
Transform4x4f& rotateX(const float _angle);
|
||||
Transform4x4f& rotateY(const float _angle);
|
||||
Transform4x4f& rotateZ(const float _angle);
|
||||
Transform4x4f& translate(const Vector3f& _translation);
|
||||
Transform4x4f& round();
|
||||
|
||||
Vector3f& translation() { return mR3.v3(); }
|
||||
const Vector3f& translation() const { return mR3.v3(); }
|
||||
|
||||
static const Transform4x4f Identity()
|
||||
{
|
||||
return {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
|
||||
}
|
||||
|
||||
protected:
|
||||
Vector4f mR0;
|
||||
Vector4f mR1;
|
||||
Vector4f mR2;
|
||||
Vector4f mR3;
|
||||
};
|
||||
|
||||
#endif // ES_CORE_MATH_TRANSFORM4X4F_H
|
|
@ -1,27 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector2f.cpp
|
||||
//
|
||||
// 2-dimensional floating point vector functions.
|
||||
//
|
||||
|
||||
#include "math/Vector2f.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Vector2f& Vector2f::round()
|
||||
{
|
||||
mX = std::round(mX);
|
||||
mY = std::round(mY);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2f& Vector2f::lerp(const Vector2f& _start, const Vector2f& _end, const float _fraction)
|
||||
{
|
||||
mX = Math::lerp(_start.x(), _end.x(), _fraction);
|
||||
mY = Math::lerp(_start.y(), _end.y(), _fraction);
|
||||
|
||||
return *this;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector2f.h
|
||||
//
|
||||
// 2-dimensional floating point vector functions.
|
||||
//
|
||||
|
||||
#ifndef ES_CORE_MATH_VECTOR2F_H
|
||||
#define ES_CORE_MATH_VECTOR2F_H
|
||||
|
||||
#include "math/Misc.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
class Vector3f;
|
||||
class Vector4f;
|
||||
|
||||
class Vector2f
|
||||
{
|
||||
public:
|
||||
Vector2f() {}
|
||||
Vector2f(const float _f)
|
||||
: mX(_f)
|
||||
, mY(_f)
|
||||
{
|
||||
}
|
||||
Vector2f(const float _x, const float _y)
|
||||
: mX(_x)
|
||||
, mY(_y)
|
||||
{
|
||||
}
|
||||
explicit Vector2f(const Vector3f& _v)
|
||||
: mX((reinterpret_cast<const Vector2f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector2f&>(_v)).mY)
|
||||
{
|
||||
}
|
||||
explicit Vector2f(const Vector4f& _v)
|
||||
: mX((reinterpret_cast<const Vector2f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector2f&>(_v)).mY)
|
||||
{
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
const bool operator==(const Vector2f& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY)); }
|
||||
const bool operator!=(const Vector2f& _other) const
|
||||
{ return ((mX != _other.mX) || (mY != _other.mY)); }
|
||||
|
||||
const Vector2f operator+(const Vector2f& _other) const
|
||||
{ return { mX + _other.mX, mY + _other.mY }; }
|
||||
const Vector2f operator-(const Vector2f& _other) const
|
||||
{ return { mX - _other.mX, mY - _other.mY }; }
|
||||
const Vector2f operator*(const Vector2f& _other) const
|
||||
{ return { mX * _other.mX, mY * _other.mY }; }
|
||||
const Vector2f operator/(const Vector2f& _other) const
|
||||
{ return { mX / _other.mX, mY / _other.mY }; }
|
||||
|
||||
const Vector2f operator+(const float& _other) const { return { mX + _other, mY + _other }; }
|
||||
const Vector2f operator-(const float& _other) const { return { mX - _other, mY - _other }; }
|
||||
const Vector2f operator*(const float& _other) const { return { mX * _other, mY * _other }; }
|
||||
const Vector2f operator/(const float& _other) const { return { mX / _other, mY / _other }; }
|
||||
|
||||
const Vector2f operator-() const { return { -mX , -mY }; }
|
||||
|
||||
Vector2f& operator+=(const Vector2f& _other) { *this = *this + _other; return *this; }
|
||||
Vector2f& operator-=(const Vector2f& _other) { *this = *this - _other; return *this; }
|
||||
Vector2f& operator*=(const Vector2f& _other) { *this = *this * _other; return *this; }
|
||||
Vector2f& operator/=(const Vector2f& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
Vector2f& operator+=(const float& _other) { *this = *this + _other; return *this; }
|
||||
Vector2f& operator-=(const float& _other) { *this = *this - _other; return *this; }
|
||||
Vector2f& operator*=(const float& _other) { *this = *this * _other; return *this; }
|
||||
Vector2f& operator/=(const float& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
float& operator[](const int _index)
|
||||
{ assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||
const float& operator[](const int _index) const
|
||||
{ assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||
// clang-format on
|
||||
|
||||
float& x() { return mX; }
|
||||
float& y() { return mY; }
|
||||
const float& x() const { return mX; }
|
||||
const float& y() const { return mY; }
|
||||
|
||||
Vector2f& round();
|
||||
Vector2f& lerp(const Vector2f& _start, const Vector2f& _end, const float _fraction);
|
||||
|
||||
static const Vector2f Zero() { return {0.0f, 0.0f}; }
|
||||
static const Vector2f UnitX() { return {1.0f, 0.0f}; }
|
||||
static const Vector2f UnitY() { return {0.0f, 1.0f}; }
|
||||
|
||||
private:
|
||||
float mX;
|
||||
float mY;
|
||||
};
|
||||
|
||||
#endif // ES_CORE_MATH_VECTOR2F_H
|
|
@ -1,9 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector2i.cpp
|
||||
//
|
||||
// 2-dimensional integer vector functions.
|
||||
//
|
||||
|
||||
#include "math/Vector2i.h"
|
|
@ -1,81 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector2i.h
|
||||
//
|
||||
// 2-dimensional integer vector functions.
|
||||
//
|
||||
|
||||
#ifndef ES_CORE_MATH_VECTOR2I_H
|
||||
#define ES_CORE_MATH_VECTOR2I_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
class Vector2i
|
||||
{
|
||||
public:
|
||||
Vector2i() {}
|
||||
Vector2i(const int _i)
|
||||
: mX(_i)
|
||||
, mY(_i)
|
||||
{
|
||||
}
|
||||
Vector2i(const int _x, const int _y)
|
||||
: mX(_x)
|
||||
, mY(_y)
|
||||
{
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
const bool operator==(const Vector2i& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY)); }
|
||||
const bool operator!=(const Vector2i& _other) const
|
||||
{ return ((mX != _other.mX) || (mY != _other.mY)); }
|
||||
|
||||
const Vector2i operator+(const Vector2i& _other) const
|
||||
{ return { mX + _other.mX, mY + _other.mY }; }
|
||||
const Vector2i operator-(const Vector2i& _other) const
|
||||
{ return { mX - _other.mX, mY - _other.mY }; }
|
||||
const Vector2i operator*(const Vector2i& _other) const
|
||||
{ return { mX * _other.mX, mY * _other.mY }; }
|
||||
const Vector2i operator/(const Vector2i& _other) const
|
||||
{ return { mX / _other.mX, mY / _other.mY }; }
|
||||
|
||||
const Vector2i operator+(const int& _other) const { return { mX + _other, mY + _other }; }
|
||||
const Vector2i operator-(const int& _other) const { return { mX - _other, mY - _other }; }
|
||||
const Vector2i operator*(const int& _other) const { return { mX * _other, mY * _other }; }
|
||||
const Vector2i operator/(const int& _other) const { return { mX / _other, mY / _other }; }
|
||||
|
||||
const Vector2i operator-() const { return { -mX , -mY }; }
|
||||
|
||||
Vector2i& operator+=(const Vector2i& _other) { *this = *this + _other; return *this; }
|
||||
Vector2i& operator-=(const Vector2i& _other) { *this = *this - _other; return *this; }
|
||||
Vector2i& operator*=(const Vector2i& _other) { *this = *this * _other; return *this; }
|
||||
Vector2i& operator/=(const Vector2i& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
Vector2i& operator+=(const int& _other) { *this = *this + _other; return *this; }
|
||||
Vector2i& operator-=(const int& _other) { *this = *this - _other; return *this; }
|
||||
Vector2i& operator*=(const int& _other) { *this = *this * _other; return *this; }
|
||||
Vector2i& operator/=(const int& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
int& operator[](const int _index)
|
||||
{ assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||
const int& operator[](const int _index) const
|
||||
{ assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||
// clang-format on
|
||||
|
||||
int& x() { return mX; }
|
||||
int& y() { return mY; }
|
||||
const int& x() const { return mX; }
|
||||
const int& y() const { return mY; }
|
||||
|
||||
static const Vector2i Zero() { return {0, 0}; }
|
||||
static const Vector2i UnitX() { return {1, 0}; }
|
||||
static const Vector2i UnitY() { return {0, 1}; }
|
||||
|
||||
private:
|
||||
int mX;
|
||||
int mY;
|
||||
};
|
||||
|
||||
#endif // ES_CORE_MATH_VECTOR2I_H
|
|
@ -1,29 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector3f.cpp
|
||||
//
|
||||
// 3-dimensional floating point vector functions.
|
||||
//
|
||||
|
||||
#include "math/Vector3f.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Vector3f& Vector3f::round()
|
||||
{
|
||||
mX = std::round(mX);
|
||||
mY = std::round(mY);
|
||||
mZ = std::round(mZ);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3f& Vector3f::lerp(const Vector3f& _start, const Vector3f& _end, const float _fraction)
|
||||
{
|
||||
mX = Math::lerp(_start.x(), _end.x(), _fraction);
|
||||
mY = Math::lerp(_start.y(), _end.y(), _fraction);
|
||||
mZ = Math::lerp(_start.z(), _end.z(), _fraction);
|
||||
|
||||
return *this;
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector3f.h
|
||||
//
|
||||
// 3-dimensional floating point vector functions.
|
||||
//
|
||||
|
||||
#ifndef ES_CORE_MATH_VECTOR3F_H
|
||||
#define ES_CORE_MATH_VECTOR3F_H
|
||||
|
||||
#include "math/Misc.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
class Vector2f;
|
||||
class Vector4f;
|
||||
|
||||
class Vector3f
|
||||
{
|
||||
public:
|
||||
Vector3f() {}
|
||||
Vector3f(const float _f)
|
||||
: mX(_f)
|
||||
, mY(_f)
|
||||
, mZ(_f)
|
||||
{
|
||||
}
|
||||
Vector3f(const float _x, const float _y, const float _z)
|
||||
: mX(_x)
|
||||
, mY(_y)
|
||||
, mZ(_z)
|
||||
{
|
||||
}
|
||||
explicit Vector3f(const Vector2f& _v)
|
||||
: mX((reinterpret_cast<const Vector3f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector3f&>(_v)).mY)
|
||||
, mZ(0)
|
||||
{
|
||||
}
|
||||
explicit Vector3f(const Vector2f& _v, const float _z)
|
||||
: mX((reinterpret_cast<const Vector3f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector3f&>(_v)).mY)
|
||||
, mZ(_z)
|
||||
{
|
||||
}
|
||||
explicit Vector3f(const Vector4f& _v)
|
||||
: mX((reinterpret_cast<const Vector3f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector3f&>(_v)).mY)
|
||||
, mZ((reinterpret_cast<const Vector3f&>(_v)).mZ)
|
||||
{
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
const bool operator==(const Vector3f& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY) && (mZ == _other.mZ)); }
|
||||
const bool operator!=(const Vector3f& _other) const
|
||||
{ return ((mX != _other.mX) || (mY != _other.mY) || (mZ != _other.mZ)); }
|
||||
|
||||
const Vector3f operator+(const Vector3f& _other) const
|
||||
{ return { mX + _other.mX, mY + _other.mY, mZ + _other.mZ }; }
|
||||
const Vector3f operator-(const Vector3f& _other) const
|
||||
{ return { mX - _other.mX, mY - _other.mY, mZ - _other.mZ }; }
|
||||
const Vector3f operator*(const Vector3f& _other) const
|
||||
{ return { mX * _other.mX, mY * _other.mY, mZ * _other.mZ }; }
|
||||
const Vector3f operator/(const Vector3f& _other) const
|
||||
{ return { mX / _other.mX, mY / _other.mY, mZ / _other.mZ }; }
|
||||
|
||||
const Vector3f operator+(const float& _other) const
|
||||
{ return { mX + _other, mY + _other, mZ + _other }; }
|
||||
const Vector3f operator-(const float& _other) const
|
||||
{ return { mX - _other, mY - _other, mZ - _other }; }
|
||||
const Vector3f operator*(const float& _other) const
|
||||
{ return { mX * _other, mY * _other, mZ * _other }; }
|
||||
const Vector3f operator/(const float& _other) const
|
||||
{ return { mX / _other, mY / _other, mZ / _other }; }
|
||||
|
||||
const Vector3f operator-() const { return { -mX , -mY, -mZ }; }
|
||||
|
||||
Vector3f& operator+=(const Vector3f& _other) { *this = *this + _other; return *this; }
|
||||
Vector3f& operator-=(const Vector3f& _other) { *this = *this - _other; return *this; }
|
||||
Vector3f& operator*=(const Vector3f& _other) { *this = *this * _other; return *this; }
|
||||
Vector3f& operator/=(const Vector3f& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
Vector3f& operator+=(const float& _other) { *this = *this + _other; return *this; }
|
||||
Vector3f& operator-=(const float& _other) { *this = *this - _other; return *this; }
|
||||
Vector3f& operator*=(const float& _other) { *this = *this * _other; return *this; }
|
||||
Vector3f& operator/=(const float& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
float& operator[](const int _index)
|
||||
{ assert(_index < 3 && "index out of range"); return (&mX)[_index]; }
|
||||
const float& operator[](const int _index) const
|
||||
{ assert(_index < 3 && "index out of range"); return (&mX)[_index]; }
|
||||
// clang-format on
|
||||
|
||||
float& x() { return mX; }
|
||||
float& y() { return mY; }
|
||||
float& z() { return mZ; }
|
||||
const float& x() const { return mX; }
|
||||
const float& y() const { return mY; }
|
||||
const float& z() const { return mZ; }
|
||||
|
||||
Vector2f& v2() { return *reinterpret_cast<Vector2f*>(this); }
|
||||
const Vector2f& v2() const { return *reinterpret_cast<const Vector2f*>(this); }
|
||||
|
||||
Vector3f& round();
|
||||
Vector3f& lerp(const Vector3f& _start, const Vector3f& _end, const float _fraction);
|
||||
|
||||
static const Vector3f Zero() { return {0.0f, 0.0f, 0.0f}; }
|
||||
static const Vector3f UnitX() { return {1.0f, 0.0f, 0.0f}; }
|
||||
static const Vector3f UnitY() { return {0.0f, 1.0f, 0.0f}; }
|
||||
static const Vector3f UnitZ() { return {0.0f, 0.0f, 1.0f}; }
|
||||
|
||||
private:
|
||||
float mX;
|
||||
float mY;
|
||||
float mZ;
|
||||
};
|
||||
|
||||
#endif // ES_CORE_MATH_VECTOR3F_H
|
|
@ -1,31 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector4f.cpp
|
||||
//
|
||||
// 4-dimensional floating point vector functions.
|
||||
//
|
||||
|
||||
#include "math/Vector4f.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Vector4f& Vector4f::round()
|
||||
{
|
||||
mX = std::round(mX);
|
||||
mY = std::round(mY);
|
||||
mZ = std::round(mZ);
|
||||
mW = std::round(mW);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector4f& Vector4f::lerp(const Vector4f& _start, const Vector4f& _end, const float _fraction)
|
||||
{
|
||||
mX = Math::lerp(_start.x(), _end.x(), _fraction);
|
||||
mY = Math::lerp(_start.y(), _end.y(), _fraction);
|
||||
mZ = Math::lerp(_start.z(), _end.z(), _fraction);
|
||||
mW = Math::lerp(_start.w(), _end.w(), _fraction);
|
||||
|
||||
return *this;
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// EmulationStation Desktop Edition
|
||||
// Vector4f.h
|
||||
//
|
||||
// 4-dimensional floating point vector functions.
|
||||
//
|
||||
|
||||
#ifndef ES_CORE_MATH_VECTOR4F_H
|
||||
#define ES_CORE_MATH_VECTOR4F_H
|
||||
|
||||
#include "math/Misc.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
class Vector2f;
|
||||
class Vector3f;
|
||||
|
||||
class Vector4f
|
||||
{
|
||||
public:
|
||||
Vector4f() {}
|
||||
Vector4f(const float _f)
|
||||
: mX(_f)
|
||||
, mY(_f)
|
||||
, mZ(_f)
|
||||
, mW(_f)
|
||||
{
|
||||
}
|
||||
Vector4f(const float _x, const float _y, const float _z, const float _w)
|
||||
: mX(_x)
|
||||
, mY(_y)
|
||||
, mZ(_z)
|
||||
, mW(_w)
|
||||
{
|
||||
}
|
||||
explicit Vector4f(const Vector2f& _v)
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector4f&>(_v)).mY)
|
||||
, mZ(0)
|
||||
, mW(0)
|
||||
{
|
||||
}
|
||||
explicit Vector4f(const Vector2f& _v, const float _z)
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector4f&>(_v)).mY)
|
||||
, mZ(_z)
|
||||
, mW(0)
|
||||
{
|
||||
}
|
||||
explicit Vector4f(const Vector2f& _v, const float _z, const float _w)
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector4f&>(_v)).mY)
|
||||
, mZ(_z)
|
||||
, mW(_w)
|
||||
{
|
||||
}
|
||||
explicit Vector4f(const Vector3f& _v)
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector4f&>(_v)).mY)
|
||||
, mZ((reinterpret_cast<const Vector4f&>(_v)).mZ)
|
||||
, mW(0)
|
||||
{
|
||||
}
|
||||
explicit Vector4f(const Vector3f& _v, const float _w)
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX)
|
||||
, mY((reinterpret_cast<const Vector4f&>(_v)).mY)
|
||||
, mZ((reinterpret_cast<const Vector4f&>(_v)).mZ)
|
||||
, mW(_w)
|
||||
{
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
const bool operator==(const Vector4f& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY) &&
|
||||
(mZ == _other.mZ) && (mW == _other.mW)); }
|
||||
const bool operator!=(const Vector4f& _other) const
|
||||
{ return ((mX != _other.mX) || (mY != _other.mY) ||
|
||||
(mZ != _other.mZ) || (mW != _other.mW)); }
|
||||
|
||||
const Vector4f operator+(const Vector4f& _other) const
|
||||
{ return { mX + _other.mX, mY + _other.mY, mZ + _other.mZ, mW + _other.mW }; }
|
||||
const Vector4f operator-(const Vector4f& _other) const
|
||||
{ return { mX - _other.mX, mY - _other.mY, mZ - _other.mZ, mW - _other.mW }; }
|
||||
const Vector4f operator*(const Vector4f& _other) const
|
||||
{ return { mX * _other.mX, mY * _other.mY, mZ * _other.mZ, mW * _other.mW }; }
|
||||
const Vector4f operator/(const Vector4f& _other) const
|
||||
{ return { mX / _other.mX, mY / _other.mY, mZ / _other.mZ, mW / _other.mW }; }
|
||||
|
||||
const Vector4f operator+(const float& _other) const
|
||||
{ return { mX + _other, mY + _other, mZ + _other, mW + _other }; }
|
||||
const Vector4f operator-(const float& _other) const
|
||||
{ return { mX - _other, mY - _other, mZ - _other, mW - _other }; }
|
||||
const Vector4f operator*(const float& _other) const
|
||||
{ return { mX * _other, mY * _other, mZ * _other, mW * _other }; }
|
||||
const Vector4f operator/(const float& _other) const
|
||||
{ return { mX / _other, mY / _other, mZ / _other, mW / _other }; }
|
||||
|
||||
const Vector4f operator-() const { return {-mX , -mY, -mZ, -mW }; }
|
||||
|
||||
Vector4f& operator+=(const Vector4f& _other) { *this = *this + _other; return *this; }
|
||||
Vector4f& operator-=(const Vector4f& _other) { *this = *this - _other; return *this; }
|
||||
Vector4f& operator*=(const Vector4f& _other) { *this = *this * _other; return *this; }
|
||||
Vector4f& operator/=(const Vector4f& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
Vector4f& operator+=(const float& _other) { *this = *this + _other; return *this; }
|
||||
Vector4f& operator-=(const float& _other) { *this = *this - _other; return *this; }
|
||||
Vector4f& operator*=(const float& _other) { *this = *this * _other; return *this; }
|
||||
Vector4f& operator/=(const float& _other) { *this = *this / _other; return *this; }
|
||||
|
||||
float& operator[](const int _index)
|
||||
{ assert(_index < 4 && "index out of range"); return (&mX)[_index]; }
|
||||
const float& operator[](const int _index) const
|
||||
{ assert(_index < 4 && "index out of range"); return (&mX)[_index]; }
|
||||
// clang-format on
|
||||
|
||||
float& x() { return mX; }
|
||||
float& y() { return mY; }
|
||||
float& z() { return mZ; }
|
||||
float& w() { return mW; }
|
||||
const float& x() const { return mX; }
|
||||
const float& y() const { return mY; }
|
||||
const float& z() const { return mZ; }
|
||||
const float& w() const { return mW; }
|
||||
|
||||
Vector2f& v2() { return *reinterpret_cast<Vector2f*>(this); }
|
||||
const Vector2f& v2() const { return *reinterpret_cast<const Vector2f*>(this); }
|
||||
|
||||
Vector3f& v3() { return *reinterpret_cast<Vector3f*>(this); }
|
||||
const Vector3f& v3() const { return *reinterpret_cast<const Vector3f*>(this); }
|
||||
|
||||
Vector4f& round();
|
||||
Vector4f& lerp(const Vector4f& _start, const Vector4f& _end, const float _fraction);
|
||||
|
||||
static const Vector4f Zero() { return {0.0f, 0.0f, 0.0f, 0.0f}; }
|
||||
static const Vector4f UnitX() { return {1.0f, 0.0f, 0.0f, 0.0f}; }
|
||||
static const Vector4f UnitY() { return {0.0f, 1.0f, 0.0f, 0.0f}; }
|
||||
static const Vector4f UnitZ() { return {0.0f, 0.0f, 1.0f, 0.0f}; }
|
||||
static const Vector4f UnitW() { return {0.0f, 0.0f, 0.0f, 1.0f}; }
|
||||
|
||||
private:
|
||||
float mX;
|
||||
float mY;
|
||||
float mZ;
|
||||
float mW;
|
||||
};
|
||||
|
||||
#endif // ES_CORE_MATH_VECTOR4F_H
|
Loading…
Reference in a new issue