[Bf-blender-cvs] [6329e20] master: BGE: Use float as default instead of double in Moto library.
Porteries Tristan
noreply at git.blender.org
Sun Dec 13 02:10:10 CET 2015
Commit: 6329e20cbb64910d0d9de357df76473f93399975
Author: Porteries Tristan
Date: Sun Dec 13 02:01:28 2015 +0100
Branches: master
https://developer.blender.org/rB6329e20cbb64910d0d9de357df76473f93399975
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
===================================================================
M intern/moto/include/MT_CmMatrix4x4.h
M intern/moto/include/MT_Scalar.h
M intern/moto/intern/MT_CmMatrix4x4.cpp
M source/gameengine/Ketsji/KX_FontObject.cpp
M source/gameengine/Ketsji/KX_GameObject.cpp
M source/gameengine/Ketsji/KX_GameObject.h
M source/gameengine/Ketsji/KX_Scene.cpp
M source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
M source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
M source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
M source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
M source/gameengine/Rasterizer/RAS_IRasterizer.h
M source/gameengine/Rasterizer/RAS_MaterialBucket.h
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
===================================================================
diff --git a/intern/moto/include/MT_CmMatrix4x4.h b/intern/moto/include/MT_CmMatrix4x4.h
index 2b710c6..53fdd41 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 5e51629..6082e2d 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 7a04864..7eae14c 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;
}
diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
index 420f1f7..13a5ec6 100644
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ b/source/gameengine/Ketsji/KX_FontObject.cpp
@@ -194,7 +194,10 @@ void KX_FontObject::DrawFontText()
/* Get a working copy of the OpenGLMatrix to use */
double mat[16];
- memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16);
+ float *origmat = GetOpenGLMatrix();
+ for (unsigned short i = 0; i < 16; ++i) {
+ mat[i] = (double)origmat[i];
+ }
/* Account for offset */
MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset * this->NodeGetWorldScaling();
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 412a112..38d8a30 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -700,10 +700,10 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
/**
* GetOpenGL Matrix, returns an OpenGL 'compatible' matrix
*/
-double* KX_GameObject::GetOpenGLMatrix()
+float *KX_GameObject::GetOpenGLMatrix()
{
// todo: optimize and only update if necessary
- double* fl = m_OpenGL_4x4Matrix.getPointer();
+ float *fl = m_OpenGL_4x4Matrix.getPointer();
if (GetSGNode()) {
MT_Transform trans;
@@ -742,7 +742,7 @@ void KX_GameObject::AddMeshUser()
m_meshes[i]->AddMeshUser(this, &m_meshSlots, GetDeformer());
}
// set the part of the mesh slot that never change
- double* fl = GetOpenGLMatrixPtr()->getPointer();
+ float *fl = GetOpenGLMatrixPtr()->getPointer();
SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
// RAS_MeshSlot* ms;
@@ -2768,7 +2768,7 @@ PyObject *KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTR
{
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- double mat[16];
+ float mat[16];
MT_Transform trans;
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index c2c455d..a25f999 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -175,7 +175,7 @@ public:
* side effect of storing the result internally. The
* memory for the matrix remains the property of this class.
*/
- double *
+ float *
GetOpenGLMatrix(
);
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 16d1fdd..350bad0 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -1557,9 +1557,9 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int
planes[5].setValue(cplanes[3].getValue()); // bottom
CullingInfo info(layer);
- double mvmat[16] = {0};
+ float mvmat[16] = {0};
cam->GetModelviewMatrix().getValue(mvmat);
- double pmat[16] = {0};
+ float pmat[16] = {0};
cam->GetProjectionMatrix().getValue(pmat);
dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index d7b0436..9f0fc6d 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1472,7 +1472,7 @@ struct OcclusionBuffer
m[15] = btScalar(m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]);
}
- void setup(int size, const int *view, double modelview[16], double projection[16])
+ void setup(int size, const int *view, float modelview[16], float projection[16])
{
m_initialized = false;
m_occlusion = false;
@@ -1519,7 +1519,7 @@ struct OcclusionBuffer
m_occlusion = false;
}
- void SetModelMatrix(double *fl)
+ void SetModelMatrix(float *fl)
{
CMmat4mul(m_mtc,m_wtc,fl);
if (!m_initialized) {
@@ -1969,7 +1969,7 @@ struct DbvtCullingCallback : btDbvt::ICollide
KX_GameObject* gameobj = KX_GameObject::GetClientObject(info);
if (gameobj && gameobj->GetOccluder())
{
- double* fl = gameobj->GetOpenGLMatrixPtr()->getPointer();
+ float *fl = gameobj->GetOpenGLMatrixPtr()->getPointer();
// this will create the occlusion buffer if not already done
// and compute the transformation from model local space to clip space
m_ocb->SetModelMatrix(fl);
@@ -2010,7 +2010,7 @@ struct DbvtCullingCallback : btDbvt::ICollide
};
static OcclusionBuffer gOcb;
-bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16])
+bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16])
{
if (!m_cullingTree)
return false;
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 86f6639..a64d2c8 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -211,7 +211,7 @@ protected:
btTypedConstraint* GetConstraintById(int constraintId);
virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]);
+ virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]);
//Methods for gamelogic collision/physics callbacks
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 929345d..3e9379d 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -83,7 +83,7 @@ public:
}
virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
+ virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) { return false; }
//gamelogic callbacks
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index 4b8d362..2997048 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -183,7 +183,7 @@ class PHY_IPhysicsEnvironment
//culling based on physical broad phase
// the plane number must be set as follow: near, far, left, right, top, botton
// the near plane must be the first one and must always be present, it is used to get the direction of the view
- virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0;
+ virtual bool CullingTest(PHY_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list