From 6329e20cbb64910d0d9de357df76473f93399975 Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Sun, 13 Dec 2015 02:01:28 +0100 Subject: BGE: Use float as default instead of double in Moto library. Use float in moto instead of double for MT_Scalar. This switch allow future optimization like SSE. Additionally, it changes the OpenGL calls to float versions as they are very bad with doubles. Reviewers: campbellbarton, moguri, lordloki Reviewed By: lordloki Subscribers: brecht, lordloki Differential Revision: https://developer.blender.org/D1610 --- intern/moto/include/MT_CmMatrix4x4.h | 16 ++++++++-------- intern/moto/include/MT_Scalar.h | 2 +- intern/moto/intern/MT_CmMatrix4x4.cpp | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'intern/moto') diff --git a/intern/moto/include/MT_CmMatrix4x4.h b/intern/moto/include/MT_CmMatrix4x4.h index 2b710c66888..53fdd41fb28 100644 --- a/intern/moto/include/MT_CmMatrix4x4.h +++ b/intern/moto/include/MT_CmMatrix4x4.h @@ -55,7 +55,7 @@ class MT_CmMatrix4x4 public : MT_CmMatrix4x4( - const float value[4][4] + const MT_Scalar value[4][4] ); MT_CmMatrix4x4( @@ -63,7 +63,7 @@ public : MT_CmMatrix4x4( - const double value[16] + const MT_Scalar value[16] ); MT_CmMatrix4x4( @@ -85,19 +85,19 @@ public : const MT_CmMatrix4x4 & other ); - double* + MT_Scalar* getPointer( ); const - double* + MT_Scalar* getPointer( ) const; void setElem( int pos, - double newvalue + MT_Scalar newvalue ); MT_Vector3 @@ -121,7 +121,7 @@ public : const MT_Vector3 & v ); - double& + MT_Scalar& operator ( ) (int row,int col) { return m_V[col][row]; } @@ -139,8 +139,8 @@ public : protected: union { - double m_V[4][4]; - double m_Vflat[16]; + MT_Scalar m_V[4][4]; + MT_Scalar m_Vflat[16]; }; }; diff --git a/intern/moto/include/MT_Scalar.h b/intern/moto/include/MT_Scalar.h index 5e516292d77..6082e2d5368 100644 --- a/intern/moto/include/MT_Scalar.h +++ b/intern/moto/include/MT_Scalar.h @@ -52,7 +52,7 @@ #include "MT_random.h" -typedef double MT_Scalar; //this should be float ! +typedef float MT_Scalar; const MT_Scalar MT_DEGS_PER_RAD(57.29577951308232286465); diff --git a/intern/moto/intern/MT_CmMatrix4x4.cpp b/intern/moto/intern/MT_CmMatrix4x4.cpp index 7a04864e48d..7eae14cb4d1 100644 --- a/intern/moto/intern/MT_CmMatrix4x4.cpp +++ b/intern/moto/intern/MT_CmMatrix4x4.cpp @@ -42,7 +42,7 @@ MT_CmMatrix4x4::MT_CmMatrix4x4() -MT_CmMatrix4x4::MT_CmMatrix4x4(const float value[4][4]) +MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Scalar value[4][4]) { for (int i=0;i<4;i++) { @@ -53,7 +53,7 @@ MT_CmMatrix4x4::MT_CmMatrix4x4(const float value[4][4]) -MT_CmMatrix4x4::MT_CmMatrix4x4(const double value[16]) +MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Scalar value[16]) { for (int i=0;i<16;i++) m_Vflat[i] = value[i]; @@ -148,21 +148,21 @@ void MT_CmMatrix4x4::SetMatrix(const MT_CmMatrix4x4& other) -double* MT_CmMatrix4x4::getPointer() +MT_Scalar* MT_CmMatrix4x4::getPointer() { return &m_V[0][0]; } -const double* MT_CmMatrix4x4::getPointer() const +const MT_Scalar* MT_CmMatrix4x4::getPointer() const { return &m_V[0][0]; } -void MT_CmMatrix4x4::setElem(int pos,double newvalue) +void MT_CmMatrix4x4::setElem(int pos,MT_Scalar newvalue) { m_Vflat[pos] = newvalue; } -- cgit v1.2.3