Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2015-02-22 15:20:16 +0000
committerStijn Buys <ingar@osirion.org>2015-02-22 15:20:16 +0000
commitf14bfe36478e7d581eba54a678b3da5863706b37 (patch)
tree504658f00b60aeb0602be835d411cbde76e52a12
parent1e6411e7a9798d043f2c8f7bb7582ece5d5f1e9a (diff)
Small optimizations.
-rw-r--r--src/math/matrix4f.cc26
-rw-r--r--src/math/matrix4f.h13
2 files changed, 26 insertions, 13 deletions
diff --git a/src/math/matrix4f.cc b/src/math/matrix4f.cc
index caccae6..4602190 100644
--- a/src/math/matrix4f.cc
+++ b/src/math/matrix4f.cc
@@ -29,28 +29,32 @@ Matrix4f::Matrix4f(const Axis & axis)
void Matrix4f::clear()
{
- memset(matrix, 0, sizeof(matrix));
+ memset(_matrix, 0, sizeof(float) * 16);
}
void Matrix4f::unity()
{
- memset(matrix, 0, sizeof(matrix));
+ memset(_matrix, 0, sizeof(float) * 16);
for (int i = 0; i < 4; i++)
- matrix[i][i] = 1;
+ {
+ _matrix[i][i] = 1;
+ }
}
void Matrix4f::assign(const Matrix4f & other)
{
- memcpy(matrix, other.matrix, sizeof(matrix));
+ memcpy(_matrix, other._matrix, sizeof(float) * 16);
}
void Matrix4f::assign(const Axis & axis)
{
- memset(matrix, 0, sizeof(matrix));
for (int i = 0; i < 3; i++) {
- memcpy(&matrix[i][0], axis[i].ptr(), sizeof(float) * 3);
+ memcpy(&_matrix[i][0], axis[i].ptr(), sizeof(float) * 3);
}
- matrix[3][3] = 1;
+ _matrix[3][0] = 0;
+ _matrix[3][1] = 0;
+ _matrix[3][2] = 0;
+ _matrix[3][3] = 1;
}
Matrix4f & Matrix4f::operator=(const Matrix4f &other)
@@ -65,13 +69,17 @@ Matrix4f & Matrix4f::operator=(const Axis & axis)
return(*this);
}
-Matrix4f const Matrix4f::transpose()
+const Matrix4f Matrix4f::transpose() const
{
Matrix4f t;
for (size_t i = 0; i < 4; i++)
+ {
for (size_t j = 0; j < 4; j++)
- t.matrix[j][i] = matrix[i][j];
+ {
+ t._matrix[j][i] = _matrix[i][j];
+ }
+ }
return t;
}
diff --git a/src/math/matrix4f.h b/src/math/matrix4f.h
index 5442cb9..0ac0f68 100644
--- a/src/math/matrix4f.h
+++ b/src/math/matrix4f.h
@@ -16,8 +16,12 @@ namespace math
class Matrix4f
{
public:
+ /// default constructor
Matrix4f();
+
+ /// copy constructor
Matrix4f(const Matrix4f & other);
+
Matrix4f(const Axis & axis);
/// set all values to zero
@@ -39,15 +43,16 @@ public:
Matrix4f & operator=(const Axis & axis);
/// return a pointer to the internal data
- inline float * ptr() const {
- return (float *) matrix;
+ inline float * ptr() const
+ {
+ return (float *) _matrix;
}
/// return the transpose matrix
- Matrix4f const transpose();
+ const Matrix4f transpose() const;
private:
- float matrix[4][4];
+ float _matrix[4][4];
};
}