summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/math')
-rw-r--r--src/math/Matrix.h24
-rw-r--r--src/math/Vector2D.h4
-rw-r--r--src/math/math.cpp13
3 files changed, 20 insertions, 21 deletions
diff --git a/src/math/Matrix.h b/src/math/Matrix.h
index d8920a65..2d721e93 100644
--- a/src/math/Matrix.h
+++ b/src/math/Matrix.h
@@ -82,7 +82,8 @@ public:
return *this;
}
- CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; }
+ const CVector &GetPosition(void) const { return *(CVector*)&m_matrix.pos; }
+ CVector& GetPosition(void) { return *(CVector*)&m_matrix.pos; }
CVector &GetRight(void) { return *(CVector*)&m_matrix.right; }
CVector &GetForward(void) { return *(CVector*)&m_matrix.up; }
CVector &GetUp(void) { return *(CVector*)&m_matrix.at; }
@@ -133,13 +134,18 @@ public:
{
float *pFloatMatrix = (float*)&m_matrix;
for (int i = 0; i < 3; i++)
-#ifdef FIX_BUGS // BUGFIX from VC
for (int j = 0; j < 3; j++)
-#else
- for (int j = 0; j < 4; j++)
-#endif
pFloatMatrix[i * 4 + j] *= scale;
}
+ void Scale(float sx, float sy, float sz)
+ {
+ float *pFloatMatrix = (float*)&m_matrix;
+ for (int i = 0; i < 3; i++){
+ pFloatMatrix[i * 4 + 0] *= sx;
+ pFloatMatrix[i * 4 + 1] *= sy;
+ pFloatMatrix[i * 4 + 2] *= sz;
+ }
+ }
void SetRotateXOnly(float angle){
@@ -259,6 +265,14 @@ public:
m_matrix.at.y = 0.0f;
m_matrix.at.z = 1.0f;
}
+ void SetTranslateOnly(float x, float y, float z) {
+ m_matrix.pos.x = x;
+ m_matrix.pos.y = y;
+ m_matrix.pos.z = z;
+ }
+ void SetTranslateOnly(const CVector& pos) {
+ SetTranslateOnly(pos.x, pos.y, pos.z);
+ }
};
diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h
index 0885a5d2..7bfccae6 100644
--- a/src/math/Vector2D.h
+++ b/src/math/Vector2D.h
@@ -11,9 +11,7 @@ public:
float Magnitude(void) const { return Sqrt(x*x + y*y); }
float MagnitudeSqr(void) const { return x*x + y*y; }
- void Normalise(void);
-
- void NormaliseSafe(void) {
+ void Normalise(void) {
float sq = MagnitudeSqr();
if(sq > 0.0f){
float invsqrt = RecipSqrt(sq);
diff --git a/src/math/math.cpp b/src/math/math.cpp
index 0cfc2ce9..0661dcac 100644
--- a/src/math/math.cpp
+++ b/src/math/math.cpp
@@ -5,19 +5,6 @@
// TODO: move more stuff into here
void
-CVector2D::Normalise(void)
-{
- float sq = MagnitudeSqr();
- assert(sq != 0.0f); // just be safe here
- //if(sq > 0.0f){
- float invsqrt = RecipSqrt(sq);
- x *= invsqrt;
- y *= invsqrt;
- //}else
- // x = 1.0f;
-}
-
-void
CMatrix::SetRotate(float xAngle, float yAngle, float zAngle)
{
float cX = Cos(xAngle);