Browse Source

Fix some nasty static crap

Panagiotis Christopoulos Charitos 5 years ago
parent
commit
9921d4325d
3 changed files with 22 additions and 27 deletions
  1. 19 23
      src/anki/math/Mat.h
  2. 2 3
      src/anki/math/Transform.h
  3. 1 1
      src/anki/math/Vec.h

+ 19 - 23
src/anki/math/Mat.h

@@ -384,7 +384,7 @@ public:
 		{
 			m_arr1[n] = b.m_arr1[n];
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	/// Copy.
@@ -394,7 +394,7 @@ public:
 		{
 			m_simd[i] = b.m_simd[i];
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	ANKI_ENABLE_METHOD(!HAS_SIMD)
@@ -426,7 +426,7 @@ public:
 		{
 			m_arr1[n] += b.m_arr1[n];
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	ANKI_ENABLE_METHOD(HAS_SIMD)
@@ -436,7 +436,7 @@ public:
 		{
 			m_simd[i] = _mm_add_ps(m_simd[i], b.m_simd[i]);
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	ANKI_ENABLE_METHOD(!HAS_SIMD)
@@ -468,7 +468,7 @@ public:
 		{
 			m_arr1[n] -= b.m_arr1[n];
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	ANKI_ENABLE_METHOD(HAS_SIMD)
@@ -478,7 +478,7 @@ public:
 		{
 			m_simd[i] = _mm_sub_ps(m_simd[i], b.m_simd[i]);
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	ANKI_ENABLE_METHOD(J == I && !HAS_MAT4_SIMD)
@@ -528,7 +528,7 @@ public:
 	TMat& operator*=(const TMat& b)
 	{
 		(*this) = (*this) * b;
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	Bool operator==(const TMat& b) const
@@ -574,7 +574,7 @@ public:
 		{
 			m_arr1[i] += f;
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	TMat operator-(const T f) const
@@ -593,7 +593,7 @@ public:
 		{
 			m_arr1[i] -= f;
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	TMat operator*(const T f) const
@@ -612,7 +612,7 @@ public:
 		{
 			m_arr1[i] *= f;
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 
 	TMat operator/(const T f) const
@@ -633,7 +633,7 @@ public:
 		{
 			m_arr1[i] /= f;
 		}
-		return static_cast<TMat&>(*this);
+		return *this;
 	}
 	/// @}
 
@@ -1494,10 +1494,9 @@ public:
 		return ((*this) * (1.0 - t)) + (b * t);
 	}
 
-	static const TMat& getZero()
+	static TMat getZero()
 	{
-		static const TMat zero(0.0);
-		return zero;
+		return TMat(0.0);
 	}
 
 	void setZero()
@@ -1506,24 +1505,21 @@ public:
 	}
 
 	ANKI_ENABLE_METHOD(I == 3 && J == 3)
-	static const TMat& getIdentity()
+	static TMat getIdentity()
 	{
-		static const TMat ident(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
-		return ident;
+		return TMat(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
 	}
 
 	ANKI_ENABLE_METHOD(I == 4 && J == 4)
-	static const TMat& getIdentity()
+	static TMat getIdentity()
 	{
-		static const TMat ident(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
-		return ident;
+		return TMat(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
 	}
 
 	ANKI_ENABLE_METHOD(I == 4 && J == 3)
-	static const TMat& getIdentity()
+	static TMat getIdentity()
 	{
-		static const TMat ident(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
-		return ident;
+		return TMat(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
 	}
 
 	void setIdentity()

+ 2 - 3
src/anki/math/Transform.h

@@ -151,10 +151,9 @@ public:
 		(*this) = getIdentity();
 	}
 
-	static const TTransform& getIdentity()
+	static TTransform getIdentity()
 	{
-		static const TTransform ident(TVec<T, 4>(0.0), TMat<T, 3, 4>::getIdentity(), 1.0);
-		return ident;
+		return TTransform(TVec<T, 4>(0.0), TMat<T, 3, 4>::getIdentity(), 1.0);
 	}
 
 	/// @copybrief combineTTransformations

+ 1 - 1
src/anki/math/Vec.h

@@ -2942,7 +2942,7 @@ public:
 	ANKI_ENABLE_METHOD(HAS_VEC4_SIMD)
 	TVec abs() const
 	{
-		static const __m128 signMask = _mm_set1_ps(-0.0f);
+		const __m128 signMask = _mm_set1_ps(-0.0f);
 		return TVec(_mm_andnot_ps(signMask, m_simd));
 	}