fixed bug, added full rotation

This commit is contained in:
h4570
2020-12-24 10:32:51 +01:00
parent 7dd8947612
commit 5a932b35ca
2 changed files with 23 additions and 9 deletions
+19 -7
View File
@@ -52,13 +52,6 @@ public:
// Operators // Operators
// ---- // ----
Matrix operator*(const Matrix &v) const
{
Matrix result;
cross(result.data, this->data, v.data);
return result;
}
Vector3 operator*(const Vector3 &v) const; Vector3 operator*(const Vector3 &v) const;
Matrix operator*(const Matrix &v) const Matrix operator*(const Matrix &v) const
@@ -99,6 +92,25 @@ public:
translate(t_val); translate(t_val);
} }
/** Create rotation matrix. */
inline void rotation(const Vector3 &t_val)
{
identity();
Matrix temp = Matrix();
temp.identity();
temp.rotateX(t_val.x);
operator*=(temp);
temp.identity();
temp.rotateY(t_val.y);
operator*=(temp);
temp.identity();
temp.rotateZ(t_val.z);
operator*=(temp);
}
/** Create X rotation matrix. */ /** Create X rotation matrix. */
inline void rotationX(const float &t_radians) inline void rotationX(const float &t_radians)
{ {
+4 -2
View File
@@ -55,7 +55,8 @@ Matrix::Matrix(const float &m11, const float &m12, const float &m13, const float
Vector3 Matrix::operator*(const Vector3 &v) const Vector3 Matrix::operator*(const Vector3 &v) const
{ {
Vector3 result; float a[4] = {v.x, v.y, v.z, 1.0F};
float res[4];
asm volatile( asm volatile(
"lqc2 vf4, 0x00(%1) \n\t" "lqc2 vf4, 0x00(%1) \n\t"
"lqc2 vf5, 0x10(%1) \n\t" "lqc2 vf5, 0x10(%1) \n\t"
@@ -68,7 +69,8 @@ Vector3 Matrix::operator*(const Vector3 &v) const
"vmaddw.xyzw vf9, vf7, vf8 \n\t" "vmaddw.xyzw vf9, vf7, vf8 \n\t"
"sqc2 vf9, 0x00(%0) \n\t" "sqc2 vf9, 0x00(%0) \n\t"
: :
: "r"(result.xyz), "r"(this->data), "r"(v.xyz)); : "r"(res), "r"(this->data), "r"(a));
return Vector3(res[0], res[1], res[2]);
} }
// ---- // ----