Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-10-31 14:34:40 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-11-01 00:43:11 +0300
commit5c1f4beb639ba4ab6ab62a34b83d035d10d12afa (patch)
tree59b58b59878c4fda87889060b4f73fb2134f05e9
parenta501eb51e280251b4ec99efacade6de261f4373b (diff)
BGE: Moto: Use float for MT_Scalar.temp_bge_moto
Test: 4104 rotating spheres. Without moto modifications: Logic : 5.15 : 5% SceneGraph : 8.50 : 8% Rasterizer : 20.90 : 21% With: Logic : 5.00 : 4% SceneGraph : 8.00 : 8% Rasterizer : 20.25 : 20%
-rw-r--r--intern/moto/include/MT_Scalar.h2
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp8
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h2
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp8
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp44
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h4
14 files changed, 45 insertions, 43 deletions
diff --git a/intern/moto/include/MT_Scalar.h b/intern/moto/include/MT_Scalar.h
index 5c4a5c2a44a..fe613d929db 100644
--- a/intern/moto/include/MT_Scalar.h
+++ b/intern/moto/include/MT_Scalar.h
@@ -53,7 +53,7 @@
#include "MT_random.h"
#include "NM_Scalar.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/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
index 420f1f7eb98..366da3fc074 100644
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ b/source/gameengine/Ketsji/KX_FontObject.cpp
@@ -194,7 +194,9 @@ void KX_FontObject::DrawFontText()
/* Get a working copy of the OpenGLMatrix to use */
double mat[16];
- memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16);
+ for (unsigned short i = 0; i < 16; ++i) {
+ mat[i] = m_OpenGL_4x4Matrix.getPointer()[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 014d00a07d7..cbd4e3dc4b7 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 b5190a56c4a..a2f127d54c8 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 abf6b639fef..f616b287d8b 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 bf81a18fa78..83e5fa74919 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1455,7 +1455,7 @@ struct OcclusionBuffer
m[14] = btScalar(m1[ 2]*m2[12]+m1[ 6]*m2[13]+m1[10]*m2[14]+m1[14]*m2[15]);
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;
@@ -1505,7 +1505,7 @@ struct OcclusionBuffer
m_initialized = true;
m_occlusion = false;
}
- void SetModelMatrix(double *fl)
+ void SetModelMatrix(float *fl)
{
CMmat4mul(m_mtc,m_wtc,fl);
if (!m_initialized)
@@ -1896,7 +1896,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);
@@ -1937,7 +1937,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 86f663959f1..a64d2c8f15f 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 929345d7161..3e9379dd60d 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 4b8d36285be..2997048805f 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_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) = 0;
//Methods for gamelogic collision/physics callbacks
//todo:
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index b95a20f91ab..8d90ddd95ff 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -423,7 +423,7 @@ public:
/**
* Render Tools
*/
- virtual void applyTransform(double *oglmatrix, int drawingmode) = 0;
+ virtual void applyTransform(float *oglmatrix, int drawingmode) = 0;
/**
* Renders 2D boxes.
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
index 1eee99f896b..75cc382c78c 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
@@ -128,7 +128,7 @@ public:
void* m_clientObj;
RAS_Deformer* m_pDeformer;
DerivedMesh* m_pDerivedMesh;
- double* m_OpenGLMatrix;
+ float* m_OpenGLMatrix;
// visibility
bool m_bVisible;
bool m_bCulled;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
index 4ac1c9c4ebb..c6d9981cb3c 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
@@ -262,7 +262,7 @@ void RAS_OpenGLLight::Update()
// lights don't get their openGL matrix updated, do it now
if (kxlight->GetSGNode()->IsDirty())
kxlight->GetOpenGLMatrix();
- double *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();
+ float *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();
for (int i=0; i<4; i++)
for (int j=0; j<4; j++, dobmat++)
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index ff4a51b7e61..820bcf2c2cd 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -379,8 +379,8 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
const MT_Scalar *fromPtr = &debugShapes[i].m_pos.x();
const MT_Scalar *toPtr= &debugShapes[i].m_param.x();
- glVertex3dv(fromPtr);
- glVertex3dv(toPtr);
+ glVertex3fv(fromPtr);
+ glVertex3fv(toPtr);
}
glEnd();
@@ -416,7 +416,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
pos = pos*tr;
pos += debugShapes[i].m_pos;
const MT_Scalar* posPtr = &pos.x();
- glVertex3dv(posPtr);
+ glVertex3fv(posPtr);
}
glEnd();
}
@@ -751,8 +751,8 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
{
glMatrixMode(GL_PROJECTION);
- double* matrix = &mat(0, 0);
- glLoadMatrixd(matrix);
+ float* matrix = &mat(0, 0);
+ glLoadMatrixf(matrix);
m_camortho = (mat(3, 3) != 0.0);
}
@@ -760,11 +760,11 @@ void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat)
{
glMatrixMode(GL_PROJECTION);
- double matrix[16];
+ float matrix[16];
/* Get into argument. Looks a bit dodgy, but it's ok. */
mat.getValue(matrix);
/* Internally, MT_Matrix4x4 uses doubles (MT_Scalar). */
- glLoadMatrixd(matrix);
+ glLoadMatrixf(matrix);
m_camortho= (mat[3][3] != 0.0);
}
@@ -780,7 +780,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
bool
) {
MT_Matrix4x4 result;
- double mat[16];
+ float mat[16];
// correction for stereo
if (Stereo())
@@ -819,7 +819,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
glLoadIdentity();
glFrustum(left, right, bottom, top, frustnear, frustfar);
- glGetDoublev(GL_PROJECTION_MATRIX, mat);
+ glGetFloatv(GL_PROJECTION_MATRIX, mat);
result.setValue(mat);
return result;
@@ -834,14 +834,14 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
float frustfar
) {
MT_Matrix4x4 result;
- double mat[16];
+ float mat[16];
// stereo is meaning less for orthographic, disable it
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(left, right, bottom, top, frustnear, frustfar);
- glGetDoublev(GL_PROJECTION_MATRIX, mat);
+ glGetFloatv(GL_PROJECTION_MATRIX, mat);
result.setValue(mat);
return result;
@@ -902,7 +902,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
m_viewmatrix.getValue(glviewmat);
glMatrixMode(GL_MODELVIEW);
- glLoadMatrixd(glviewmat);
+ glLoadMatrixf(glviewmat);
m_campos = pos;
}
@@ -1215,7 +1215,7 @@ void RAS_OpenGLRasterizer::RemoveLight(RAS_ILightObject* lightobject)
m_lights.erase(lit);
}
-bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, double *oglmatrix)
+bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, float *oglmatrix)
{
if (result->m_hitMesh) {
@@ -1229,14 +1229,14 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast
left = (dir.cross(resultnormal)).safe_normalized();
// for the up vector, we take the 'resultnormal' returned by the physics
- double maat[16] = {left[0], left[1], left[2], 0,
+ float maat[16] = {left[0], left[1], left[2], 0,
dir[0], dir[1], dir[2], 0,
resultnormal[0], resultnormal[1], resultnormal[2], 0,
0, 0, 0, 1};
- glTranslated(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
//glMultMatrixd(oglmatrix);
- glMultMatrixd(maat);
+ glMultMatrixf(maat);
return true;
}
else {
@@ -1244,7 +1244,7 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast
}
}
-void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
+void RAS_OpenGLRasterizer::applyTransform(float* oglmatrix,int objectdrawmode )
{
/* FIXME:
blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
@@ -1297,13 +1297,13 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
dir *= size[1];
up *= size[2];
- double maat[16] = {left[0], left[1], left[2], 0,
+ float maat[16] = {left[0], left[1], left[2], 0,
dir[0], dir[1], dir[2], 0,
up[0], up[1], up[2], 0,
0, 0, 0, 1};
glTranslatef(objpos[0],objpos[1],objpos[2]);
- glMultMatrixd(maat);
+ glMultMatrixf(maat);
}
else {
@@ -1327,11 +1327,11 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
if (!physics_controller && parent)
physics_controller = parent->GetPhysicsController();
- KX_RayCast::Callback<RAS_OpenGLRasterizer, double> callback(this, physics_controller, oglmatrix);
+ KX_RayCast::Callback<RAS_OpenGLRasterizer, float> callback(this, physics_controller, oglmatrix);
if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
{
// couldn't find something to cast the shadow on...
- glMultMatrixd(oglmatrix);
+ glMultMatrixf(oglmatrix);
}
else
{ // we found the "ground", but the cast matrix doesn't take
@@ -1343,7 +1343,7 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
{
// 'normal' object
- glMultMatrixd(oglmatrix);
+ glMultMatrixf(oglmatrix);
}
}
}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index 80b1528b161..c7d2940c934 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -303,13 +303,13 @@ public:
void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text,
int xco, int yco, int width, int height);
- void applyTransform(double *oglmatrix, int objectdrawmode);
+ void applyTransform(float *oglmatrix, int objectdrawmode);
void PushMatrix();
void PopMatrix();
/// \see KX_RayCast
- bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, double *oglmatrix);
+ bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, float *oglmatrix);
/// \see KX_RayCast
bool NeedRayCast(struct KX_ClientObjectInfo *, void *UNUSED(data)) { return true; }