diff options
Diffstat (limited to 'source/gameengine/Ketsji')
37 files changed, 886 insertions, 924 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 89d8ec0d4ca..45946f30827 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -342,7 +342,7 @@ void BL_Action::SetTimes(float start, float end) void BL_Action::SetLocalTime(float curtime) { - float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate()*m_speed; + float dt = (curtime-m_starttime)*(float)KX_KetsjiEngine::GetAnimFrameRate()*m_speed; if (m_endframe < m_startframe) dt = -dt; @@ -354,7 +354,7 @@ void BL_Action::ResetStartTime(float curtime) { float dt = (m_localframe > m_startframe) ? m_localframe - m_startframe : m_startframe - m_localframe; - m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed); + m_starttime = curtime - dt / ((float)KX_KetsjiEngine::GetAnimFrameRate()*m_speed); SetLocalTime(curtime); } @@ -365,7 +365,7 @@ void BL_Action::IncrementBlending(float curtime) m_blendstart = curtime; // Bump the blend frame - m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate(); + m_blendframe = (curtime - m_blendstart)*(float)KX_KetsjiEngine::GetAnimFrameRate(); // Clamp if (m_blendframe>m_blendin) @@ -398,7 +398,7 @@ void BL_Action::Update(float curtime) if (m_done) return; - curtime -= KX_KetsjiEngine::GetSuspendedDelta(); + curtime -= (float)KX_KetsjiEngine::GetSuspendedDelta(); // Grab the start time here so we don't end up with a negative m_localframe when // suspending and resuming scenes. diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index 491be035d66..35f605f1a5f 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -28,7 +28,7 @@ #include "BL_ActionManager.h" #include "DNA_ID.h" -#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT)) +#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT)) BL_ActionManager::BL_ActionManager(class KX_GameObject *obj): m_obj(obj), diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 831843480a8..2f6b019c0e0 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -35,8 +35,8 @@ #include "BL_BlenderShader.h" #include "BL_Material.h" -#include "GPU_extensions.h" #include "GPU_material.h" +#include "GPU_shader.h" #include "RAS_BucketManager.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 4b229f53d77..6613780a0f8 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -34,7 +34,6 @@ #include "KX_PyMath.h" #include "MEM_guardedalloc.h" -#include "RAS_GLExtensionManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 8f717c05c0f..0b0a0f5d403 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -38,7 +38,6 @@ #include "BKE_image.h" #include "BLI_blenlib.h" -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" #include "RAS_ICanvas.h" #include "RAS_Rect.h" @@ -196,7 +195,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) { - if (!GPU_non_power_of_two_support() && (!is_power_of_2_i(x) || !is_power_of_2_i(y)) ) { + if (!GPU_full_non_power_of_two_support() && (!is_power_of_2_i(x) || !is_power_of_2_i(y)) ) { InitNonPow2Tex(pix, x,y,mipmap); return; } @@ -686,7 +685,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand); } break; } - glTexEnvf( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0); + glTexEnvf( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f); glEndList(); } diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript deleted file mode 100644 index ab03e03e74d..00000000000 --- a/source/gameengine/Ketsji/KXNetwork/SConscript +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -Import ('env') - -sources = env.Glob('*.cpp') - -incs = [ - '.', - '#intern/container', - '#intern/string', - '#intern/moto/include', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Network', - '#source/gameengine/SceneGraph', - '../../../blender/blenlib', - ] -incs = ' '.join(incs) - -defs = [] - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -env.BlenderLib ( 'bf_network', Split(sources), Split(incs), defines=defs,libtype=['core','player'], priority=[400,125], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index d85d33d9834..1d185d52dc8 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -39,7 +39,6 @@ #include "RAS_BucketManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" #include "GPU_draw.h" @@ -676,13 +675,13 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const mMaterial->matcolor[0]*mMaterial->emit, mMaterial->matcolor[1]*mMaterial->emit, mMaterial->matcolor[2]*mMaterial->emit, - 1.0 ); + 1.0f ); rasty->SetAmbient(mMaterial->amb); } if (mMaterial->material) - rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0); + rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0f); } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 644c71a68e4..6988d563808 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -294,7 +294,7 @@ void KX_Camera::NormalizeClipPlanes() for (unsigned int p = 0; p < 6; p++) { - MT_Scalar factor = sqrt(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]); + MT_Scalar factor = sqrtf(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]); if (!MT_fuzzyZero(factor)) m_planes[p] /= factor; } @@ -318,21 +318,21 @@ void KX_Camera::ExtractFrustumSphere() MT_Matrix4x4 clip_camcs_matrix = m_projection_matrix; clip_camcs_matrix.invert(); - if (m_projection_matrix[3][3] == MT_Scalar(0.0)) + if (m_projection_matrix[3][3] == MT_Scalar(0.0f)) { // frustrum projection // detect which of the corner of the far clipping plane is the farthest to the origin MT_Vector4 nfar; // far point in device normalized coordinate MT_Point3 farpoint; // most extreme far point in camera coordinate MT_Point3 nearpoint;// most extreme near point in camera coordinate - MT_Point3 farcenter(0.0, 0.0, 0.0);// center of far cliping plane in camera coordinate - MT_Scalar F=-1.0, N; // square distance of far and near point to origin + MT_Point3 farcenter(0.0f, 0.0f, 0.0f);// center of far cliping plane in camera coordinate + MT_Scalar F=-1.0f, N; // square distance of far and near point to origin MT_Scalar f, n; // distance of far and near point to z axis. f is always > 0 but n can be < 0 MT_Scalar e, s; // far and near clipping distance (<0) MT_Scalar c; // slope of center line = distance of far clipping center to z axis / far clipping distance MT_Scalar z; // projection of sphere center on z axis (<0) // tmp value - MT_Vector4 npoint(1.0, 1.0, 1.0, 1.0); + MT_Vector4 npoint(1.0f, 1.0f, 1.0f, 1.0f); MT_Vector4 hpoint; MT_Point3 point; MT_Scalar len; @@ -354,9 +354,9 @@ void KX_Camera::ExtractFrustumSphere() farcenter += point; } // the far center is the average of the far clipping points - farcenter *= 0.25; + farcenter *= 0.25f; // the extreme near point is the opposite point on the near clipping plane - nfar.setValue(-nfar[0], -nfar[1], -1.0, 1.0); + nfar.setValue(-nfar[0], -nfar[1], -1.0f, 1.0f); nfar = clip_camcs_matrix*nfar; nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]); // this is a frustrum projection @@ -373,7 +373,7 @@ void KX_Camera::ExtractFrustumSphere() n = f*s/e - MT_Point2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length(); c = MT_Point2(farcenter[0], farcenter[1]).length()/e; // the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case - z = (F-N)/(2.0*(e-s+c*(f-n))); + z = (F-N)/(2.0f*(e-s+c*(f-n))); m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z); m_frustum_radius = m_frustum_center.distance(farpoint); } @@ -381,7 +381,7 @@ void KX_Camera::ExtractFrustumSphere() { // orthographic projection // The most extreme points on the near and far plane. (normalized device coords) - MT_Vector4 hnear(1.0, 1.0, 1.0, 1.0), hfar(-1.0, -1.0, -1.0, 1.0); + MT_Vector4 hnear(1.0f, 1.0f, 1.0f, 1.0f), hfar(-1.0f, -1.0f, -1.0f, 1.0f); // Transform to hom camera local space hnear = clip_camcs_matrix*hnear; @@ -392,12 +392,12 @@ void KX_Camera::ExtractFrustumSphere() MT_Point3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]); // just use mediant point - m_frustum_center = (farpoint + nearpoint)*0.5; + m_frustum_center = (farpoint + nearpoint)*0.5f; m_frustum_radius = m_frustum_center.distance(farpoint); } // Transform to world space. m_frustum_center = GetCameraToWorld()(m_frustum_center); - m_frustum_radius /= fabs(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]); + m_frustum_radius /= fabsf(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]); m_set_frustum_center = true; } @@ -408,7 +408,7 @@ bool KX_Camera::PointInsideFrustum(const MT_Point3& x) for ( unsigned int i = 0; i < 6 ; i++ ) { - if (m_planes[i][0] * x[0] + m_planes[i][1] * x[1] + m_planes[i][2] * x[2] + m_planes[i][3] < 0.0) + if (m_planes[i][0] * x[0] + m_planes[i][1] * x[1] + m_planes[i][2] * x[2] + m_planes[i][3] < 0.0f) return false; } return true; @@ -426,7 +426,7 @@ int KX_Camera::BoxInsideFrustum(const MT_Point3 *box) // 8 box vertices. for (unsigned int v = 0; v < 8 ; v++) { - if (m_planes[p][0] * box[v][0] + m_planes[p][1] * box[v][1] + m_planes[p][2] * box[v][2] + m_planes[p][3] < 0.0) + if (m_planes[p][0] * box[v][0] + m_planes[p][1] * box[v][1] + m_planes[p][2] * box[v][2] + m_planes[p][3] < 0.0f) behindCount++; } @@ -463,7 +463,7 @@ int KX_Camera::SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &rad for (p = 0; p < 6; p++) { distance = m_planes[p][0]*center[0] + m_planes[p][1]*center[1] + m_planes[p][2]*center[2] + m_planes[p][3]; - if (fabs(distance) <= radius) + if (fabsf(distance) <= radius) intersect = INTERSECT; else if (distance < -radius) return OUTSIDE; @@ -781,7 +781,7 @@ PyObject *KX_Camera::pyattr_get_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attr float lens = self->m_camdata.m_lens; float width = self->m_camdata.m_sensor_x; - float fov = 2.0 * atan(0.5 * width / lens); + float fov = 2.0f * atanf(0.5f * width / lens); return PyFloat_FromDouble(fov * MT_DEGS_PER_RAD); } @@ -790,14 +790,14 @@ int KX_Camera::pyattr_set_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P { KX_Camera* self = static_cast<KX_Camera*>(self_v); float fov = PyFloat_AsDouble(value); - if (fov <= 0.0) { + if (fov <= 0.0f) { PyErr_SetString(PyExc_AttributeError, "camera.fov = float: KX_Camera, expected a float greater than zero"); return PY_SET_ATTR_FAIL; } fov *= MT_RADS_PER_DEG; float width = self->m_camdata.m_sensor_x; - float lens = width / (2.0 * tan(0.5 * fov)); + float lens = width / (2.0f * tanf(0.5f * fov)); self->m_camdata.m_lens= lens; self->m_set_projection_matrix = false; @@ -1065,7 +1065,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition, vect[0] = (win[0] - viewport[0]) / viewport[2]; vect[1] = (win[1] - viewport[1]) / viewport[3]; - vect[1] = 1.0 - vect[1]; //to follow Blender window coordinate system (Top-Down) + vect[1] = 1.0f - vect[1]; //to follow Blender window coordinate system (Top-Down) PyObject *ret = PyTuple_New(2); if (ret) { diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index fecd60eb212..27c074393b4 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -96,10 +96,10 @@ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, m_refDirection[2] /= len; m_refDirVector /= len; } - m_minimumBound = cos(minBound); - m_maximumBound = cos(maxBound); - m_minimumSine = sin(minBound); - m_maximumSine = sin(maxBound); + m_minimumBound = cosf(minBound); + m_maximumBound = cosf(maxBound); + m_minimumSine = sinf(minBound); + m_maximumSine = sinf(maxBound); } break; default: @@ -188,9 +188,9 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) int axis, sign; if (m_posDampTime) { - filter = m_posDampTime/(1.0+m_posDampTime); + filter = m_posDampTime/(1.0f+m_posDampTime); } else { - filter = 0.0; + filter = 0.0f; } switch (m_locrot) { case KX_ACT_CONSTRAINT_ORIX: @@ -232,10 +232,10 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) if (MT_fuzzyZero2(zaxis.length2())) { // direction and refDirection are identical, // choose any other direction to define plane - if (direction[0] < 0.9999) - zaxis = m_refDirVector.cross(MT_Vector3(1.0,0.0,0.0)); + if (direction[0] < 0.9999f) + zaxis = m_refDirVector.cross(MT_Vector3(1.0f,0.0f,0.0f)); else - zaxis = m_refDirVector.cross(MT_Vector3(0.0,1.0,0.0)); + zaxis = m_refDirVector.cross(MT_Vector3(0.0f,1.0f,0.0f)); } MT_Vector3 yaxis = zaxis.cross(m_refDirVector); yaxis.normalize(); @@ -251,7 +251,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) refDirection = m_refDirVector; } // apply damping on the direction - direction = filter*direction + (1.0-filter)*refDirection; + direction = filter*direction + (1.0f-filter)*refDirection; obj->AlignAxisToVect(direction, axis); result = true; goto CHECK_TIME; @@ -312,22 +312,22 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } else { switch (m_locrot) { case KX_ACT_CONSTRAINT_DIRPX: - direction = MT_Vector3(1.0,0.0,0.0); + direction = MT_Vector3(1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRPY: - direction = MT_Vector3(0.0,1.0,0.0); + direction = MT_Vector3(0.0f,1.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRPZ: - direction = MT_Vector3(0.0,0.0,1.0); + direction = MT_Vector3(0.0f,0.0f,1.0f); break; case KX_ACT_CONSTRAINT_DIRNX: - direction = MT_Vector3(-1.0,0.0,0.0); + direction = MT_Vector3(-1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRNY: - direction = MT_Vector3(0.0,-1.0,0.0); + direction = MT_Vector3(0.0f,-1.0f,0.0f); break; case KX_ACT_CONSTRAINT_DIRNZ: - direction = MT_Vector3(0.0,0.0,-1.0); + direction = MT_Vector3(0.0f,0.0f,-1.0f); break; } } @@ -361,11 +361,11 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) MT_Scalar rotFilter; // apply damping on the direction if (m_rotDampTime) { - rotFilter = m_rotDampTime/(1.0+m_rotDampTime); + rotFilter = m_rotDampTime/(1.0f+m_rotDampTime); } else { rotFilter = filter; } - newnormal = rotFilter*normal - (1.0-rotFilter)*newnormal; + newnormal = rotFilter*normal - (1.0f-rotFilter)*newnormal; obj->AlignAxisToVect((sign)?-newnormal:newnormal, axis); if (m_option & KX_ACT_CONSTRAINT_LOCAL) { direction = newnormal; @@ -374,7 +374,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } if (m_option & KX_ACT_CONSTRAINT_DISTANCE) { if (m_posDampTime) { - newdistance = filter*(position-callback.m_hitPoint).length()+(1.0-filter)*m_minimumBound; + newdistance = filter*(position-callback.m_hitPoint).length()+(1.0f-filter)*m_minimumBound; } else { newdistance = m_minimumBound; } @@ -410,37 +410,37 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) normal[0] = -rotation[0][0]; normal[1] = -rotation[1][0]; normal[2] = -rotation[2][0]; - direction = MT_Vector3(1.0,0.0,0.0); + direction = MT_Vector3(1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHPY: normal[0] = -rotation[0][1]; normal[1] = -rotation[1][1]; normal[2] = -rotation[2][1]; - direction = MT_Vector3(0.0,1.0,0.0); + direction = MT_Vector3(0.0f,1.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHPZ: normal[0] = -rotation[0][2]; normal[1] = -rotation[1][2]; normal[2] = -rotation[2][2]; - direction = MT_Vector3(0.0,0.0,1.0); + direction = MT_Vector3(0.0f,0.0f,1.0f); break; case KX_ACT_CONSTRAINT_FHNX: normal[0] = rotation[0][0]; normal[1] = rotation[1][0]; normal[2] = rotation[2][0]; - direction = MT_Vector3(-1.0,0.0,0.0); + direction = MT_Vector3(-1.0f,0.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHNY: normal[0] = rotation[0][1]; normal[1] = rotation[1][1]; normal[2] = rotation[2][1]; - direction = MT_Vector3(0.0,-1.0,0.0); + direction = MT_Vector3(0.0f,-1.0f,0.0f); break; case KX_ACT_CONSTRAINT_FHNZ: normal[0] = rotation[0][2]; normal[1] = rotation[1][2]; normal[2] = rotation[2][2]; - direction = MT_Vector3(0.0,0.0,-1.0); + direction = MT_Vector3(0.0f,0.0f,-1.0f); break; } normal.normalize(); @@ -475,7 +475,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) MT_Vector3 velocityHitPoint = m_hitObject->GetVelocity(relativeHitPoint); MT_Vector3 relativeVelocity = spc->GetLinearVelocity() - velocityHitPoint; MT_Scalar relativeVelocityRay = direction.dot(relativeVelocity); - MT_Scalar springExtent = 1.0 - distance/m_minimumBound; + MT_Scalar springExtent = 1.0f - distance/m_minimumBound; // Fh force is stored in m_maximum MT_Scalar springForce = springExtent * m_maximumBound; // damping is stored in m_refDirection [0] = damping, [1] = rot damping @@ -520,7 +520,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } result = true; if (m_posDampTime) { - newposition = filter*position + (1.0-filter)*newposition; + newposition = filter*position + (1.0f-filter)*newposition; } obj->NodeSetLocalPosition(newposition); goto CHECK_TIME; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 07bed647b29..818a46531c9 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -400,19 +400,19 @@ void KX_Dome::GLDrawWarpQuads(void) glColor3f(warp.nodes[i][j+1].i, warp.nodes[i][j+1].i, warp.nodes[i][j+1].i); glTexCoord2f((warp.nodes[i][j+1].u * uv_width), (warp.nodes[i][j+1].v * uv_height)); - glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0); + glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0f); glColor3f(warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i); glTexCoord2f((warp.nodes[i+1][j+1].u * uv_width), (warp.nodes[i+1][j+1].v * uv_height)); - glVertex3f(warp.nodes[i+1][j+1].x, warp.nodes[i+1][j+1].y,0.0); + glVertex3f(warp.nodes[i+1][j+1].x, warp.nodes[i+1][j+1].y,0.0f); glColor3f(warp.nodes[i+1][j].i, warp.nodes[i+1][j].i, warp.nodes[i+1][j].i); glTexCoord2f((warp.nodes[i+1][j].u * uv_width), (warp.nodes[i+1][j].v * uv_height)); - glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0); + glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0f); glColor3f(warp.nodes[i][j].i, warp.nodes[i][j].i, warp.nodes[i][j].i); glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height)); - glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0); + glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0f); } } glEnd(); @@ -428,19 +428,19 @@ void KX_Dome::GLDrawWarpQuads(void) glColor3f(warp.nodes[i][j].i,warp.nodes[i][j].i,warp.nodes[i][j].i); glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height)); - glVertex3f(warp.nodes[i][j].x,warp.nodes[i][j].y,0.0); + glVertex3f(warp.nodes[i][j].x,warp.nodes[i][j].y,0.0f); glColor3f(warp.nodes[i2][j].i,warp.nodes[i2][j].i,warp.nodes[i2][j].i); glTexCoord2f((warp.nodes[i2][j].u * uv_width), (warp.nodes[i2][j].v * uv_height)); - glVertex3f(warp.nodes[i2][j].x,warp.nodes[i2][j].y,0.0); + glVertex3f(warp.nodes[i2][j].x,warp.nodes[i2][j].y,0.0f); glColor3f(warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i); glTexCoord2f((warp.nodes[i2][j+1].u * uv_width), (warp.nodes[i2][j+1].v * uv_height)); - glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0); + glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0f); glColor3f(warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i); glTexCoord2f((warp.nodes[i2][j+1].u * uv_width), (warp.nodes[i2][j+1].v * uv_height)); - glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0); + glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0f); } } @@ -551,42 +551,42 @@ void KX_Dome::CreateMeshDome180(void) //creating faces for the env mapcube 180deg Dome // Top Face - just a triangle - cubetop[0].verts[0][0] = -M_SQRT2 / 2.0; - cubetop[0].verts[0][1] = 0.0; - cubetop[0].verts[0][2] = 0.5; + cubetop[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubetop[0].verts[0][1] = 0.0f; + cubetop[0].verts[0][2] = 0.5f; cubetop[0].u[0] = 0.0; cubetop[0].v[0] = uv_ratio; - cubetop[0].verts[1][0] = 0.0; - cubetop[0].verts[1][1] = M_SQRT2 / 2.0; - cubetop[0].verts[1][2] = 0.5; + cubetop[0].verts[1][0] = 0.0f; + cubetop[0].verts[1][1] = (float)M_SQRT2 / 2.0f; + cubetop[0].verts[1][2] = 0.5f; cubetop[0].u[1] = 0.0; cubetop[0].v[1] = 0.0; - cubetop[0].verts[2][0] = M_SQRT2 / 2.0; - cubetop[0].verts[2][1] = 0.0; - cubetop[0].verts[2][2] = 0.5; + cubetop[0].verts[2][0] = (float)M_SQRT2 / 2.0f; + cubetop[0].verts[2][1] = 0.0f; + cubetop[0].verts[2][2] = 0.5f; cubetop[0].u[2] = uv_ratio; cubetop[0].v[2] = 0.0; nfacestop = 1; /* Bottom face - just a triangle */ - cubebottom[0].verts[0][0] = -M_SQRT2 / 2.0; - cubebottom[0].verts[0][1] = 0.0; - cubebottom[0].verts[0][2] = -0.5; + cubebottom[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubebottom[0].verts[0][1] = 0.0f; + cubebottom[0].verts[0][2] = -0.5f; cubebottom[0].u[0] = uv_ratio; cubebottom[0].v[0] = 0.0; - cubebottom[0].verts[1][0] = M_SQRT2 / 2.0; + cubebottom[0].verts[1][0] = (float)M_SQRT2 / 2.0f; cubebottom[0].verts[1][1] = 0; - cubebottom[0].verts[1][2] = -0.5; + cubebottom[0].verts[1][2] = -0.5f; cubebottom[0].u[1] = 0.0; cubebottom[0].v[1] = uv_ratio; - cubebottom[0].verts[2][0] = 0.0; - cubebottom[0].verts[2][1] = M_SQRT2 / 2.0; - cubebottom[0].verts[2][2] = -0.5; + cubebottom[0].verts[2][0] = 0.0f; + cubebottom[0].verts[2][1] = (float)M_SQRT2 / 2.0f; + cubebottom[0].verts[2][2] = -0.5f; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = 0.0; @@ -594,80 +594,80 @@ void KX_Dome::CreateMeshDome180(void) /* Left face - two triangles */ - cubeleft[0].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[0][1] = 0.0; - cubeleft[0].verts[0][2] = -0.5; + cubeleft[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubeleft[0].verts[0][1] = 0.0f; + cubeleft[0].verts[0][2] = -0.5f; cubeleft[0].u[0] = 0.0; cubeleft[0].v[0] = 0.0; - cubeleft[0].verts[1][0] = 0.0; - cubeleft[0].verts[1][1] = M_SQRT2 / 2.0; - cubeleft[0].verts[1][2] = -0.5; + cubeleft[0].verts[1][0] = 0.0f; + cubeleft[0].verts[1][1] = (float)M_SQRT2 / 2.0f; + cubeleft[0].verts[1][2] = -0.5f; cubeleft[0].u[1] = uv_ratio; cubeleft[0].v[1] = 0.0; - cubeleft[0].verts[2][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[2][1] = 0.0; - cubeleft[0].verts[2][2] = 0.5; + cubeleft[0].verts[2][0] = (float)(-M_SQRT2) / 2.0f; + cubeleft[0].verts[2][1] = 0.0f; + cubeleft[0].verts[2][2] = 0.5f; cubeleft[0].u[2] = 0.0; cubeleft[0].v[2] = uv_ratio; //second triangle - cubeleft[1].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[1].verts[0][1] = 0.0; - cubeleft[1].verts[0][2] = 0.5; + cubeleft[1].verts[0][0] = (float)(-M_SQRT2) / 2.0f; + cubeleft[1].verts[0][1] = 0.0f; + cubeleft[1].verts[0][2] = 0.5f; cubeleft[1].u[0] = 0.0; cubeleft[1].v[0] = uv_ratio; - cubeleft[1].verts[1][0] = 0.0; - cubeleft[1].verts[1][1] = M_SQRT2 / 2.0; - cubeleft[1].verts[1][2] = -0.5; + cubeleft[1].verts[1][0] = 0.0f; + cubeleft[1].verts[1][1] = (float)M_SQRT2 / 2.0f; + cubeleft[1].verts[1][2] = -0.5f; cubeleft[1].u[1] = uv_ratio; cubeleft[1].v[1] = 0.0; - cubeleft[1].verts[2][0] = 0.0; - cubeleft[1].verts[2][1] = M_SQRT2 / 2.0; - cubeleft[1].verts[2][2] = 0.5; + cubeleft[1].verts[2][0] = 0.0f; + cubeleft[1].verts[2][1] = (float)M_SQRT2 / 2.0f; + cubeleft[1].verts[2][2] = 0.5f; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; /* Right face - two triangles */ - cuberight[0].verts[0][0] = 0.0; - cuberight[0].verts[0][1] = M_SQRT2 / 2.0; - cuberight[0].verts[0][2] = -0.5; + cuberight[0].verts[0][0] = 0.0f; + cuberight[0].verts[0][1] = (float)M_SQRT2 / 2.0f; + cuberight[0].verts[0][2] = -0.5f; cuberight[0].u[0] = 0.0; cuberight[0].v[0] = 0.0; - cuberight[0].verts[1][0] = M_SQRT2 / 2.0; - cuberight[0].verts[1][1] = 0.0; - cuberight[0].verts[1][2] = -0.5; + cuberight[0].verts[1][0] = (float)M_SQRT2 / 2.0f; + cuberight[0].verts[1][1] = 0.0f; + cuberight[0].verts[1][2] = -0.5f; cuberight[0].u[1] = uv_ratio; cuberight[0].v[1] = 0.0; - cuberight[0].verts[2][0] = M_SQRT2 / 2.0; - cuberight[0].verts[2][1] = 0.0; - cuberight[0].verts[2][2] = 0.5; + cuberight[0].verts[2][0] = (float)M_SQRT2 / 2.0f; + cuberight[0].verts[2][1] = 0.0f; + cuberight[0].verts[2][2] = 0.5f; cuberight[0].u[2] = uv_ratio; cuberight[0].v[2] = uv_ratio; //second triangle - cuberight[1].verts[0][0] = 0.0; - cuberight[1].verts[0][1] = M_SQRT2 / 2.0; - cuberight[1].verts[0][2] = -0.5; + cuberight[1].verts[0][0] = 0.0f; + cuberight[1].verts[0][1] = (float)M_SQRT2 / 2.0f; + cuberight[1].verts[0][2] = -0.5f; cuberight[1].u[0] = 0.0; cuberight[1].v[0] = 0.0; - cuberight[1].verts[1][0] = M_SQRT2 / 2.0; - cuberight[1].verts[1][1] = 0.0; - cuberight[1].verts[1][2] = 0.5; + cuberight[1].verts[1][0] = (float)M_SQRT2 / 2.0f; + cuberight[1].verts[1][1] = 0.0f; + cuberight[1].verts[1][2] = 0.5f; cuberight[1].u[1] = uv_ratio; cuberight[1].v[1] = uv_ratio; - cuberight[1].verts[2][0] = 0.0; - cuberight[1].verts[2][1] = M_SQRT2 / 2.0; - cuberight[1].verts[2][2] = 0.5; + cuberight[1].verts[2][0] = 0.0f; + cuberight[1].verts[2][1] = (float)M_SQRT2 / 2.0f; + cuberight[1].verts[2][2] = 0.5f; cuberight[1].u[2] = 0.0; cuberight[1].v[2] = uv_ratio; @@ -728,10 +728,10 @@ void KX_Dome::CreateMeshDome250(void) float uv_height, uv_base; float verts_height; - float rad_ang = m_angle * MT_PI / 180.0; + float rad_ang = m_angle * MT_PI / 180.0f; float uv_ratio = (float)(m_buffersize-1) / m_imagesize; - m_radangle = m_angle * M_PI/180.0;//calculates the radians angle, used for flattening + m_radangle = m_angle * (float)M_PI/180.0f;//calculates the radians angle, used for flattening /* * verts_height is the exactly needed height of the cube faces (not always 1.0). * When we want some horizontal information (e.g. for horizontal 220deg domes) we don't need to create and tessellate the whole cube. @@ -746,207 +746,207 @@ void KX_Dome::CreateMeshDome250(void) * Once we take the tangent of that angle, you have the verts coordinate corresponding to the verts on the side faces. * Then we need to multiply it by sqrt(2.0) to get the coordinate of the verts on the diagonal of the original cube. */ - verts_height = tanf((rad_ang / 2.0f) - (float)(MT_PI / 2.0)) * (float)M_SQRT2; + verts_height = tanf((rad_ang / 2.0f) - (MT_PI / 2.0f)) * (float)M_SQRT2; uv_height = uv_ratio * ( (verts_height / 2.0f) + 0.5f); - uv_base = uv_ratio * (1.0 - ((verts_height / 2.0f) + 0.5f)); + uv_base = uv_ratio * (1.0f - ((verts_height / 2.0f) + 0.5f)); //creating faces for the env mapcube 180deg Dome // Front Face - 2 triangles - cubefront[0].verts[0][0] =-1.0; - cubefront[0].verts[0][1] = 1.0; - cubefront[0].verts[0][2] =-1.0; + cubefront[0].verts[0][0] =-1.0f; + cubefront[0].verts[0][1] = 1.0f; + cubefront[0].verts[0][2] =-1.0f; cubefront[0].u[0] = 0.0; cubefront[0].v[0] = 0.0; - cubefront[0].verts[1][0] = 1.0; - cubefront[0].verts[1][1] = 1.0; - cubefront[0].verts[1][2] = 1.0; + cubefront[0].verts[1][0] = 1.0f; + cubefront[0].verts[1][1] = 1.0f; + cubefront[0].verts[1][2] = 1.0f; cubefront[0].u[1] = uv_ratio; cubefront[0].v[1] = uv_ratio; - cubefront[0].verts[2][0] =-1.0; - cubefront[0].verts[2][1] = 1.0; - cubefront[0].verts[2][2] = 1.0; + cubefront[0].verts[2][0] =-1.0f; + cubefront[0].verts[2][1] = 1.0f; + cubefront[0].verts[2][2] = 1.0f; cubefront[0].u[2] = 0.0; cubefront[0].v[2] = uv_ratio; //second triangle - cubefront[1].verts[0][0] = 1.0; - cubefront[1].verts[0][1] = 1.0; - cubefront[1].verts[0][2] = 1.0; + cubefront[1].verts[0][0] = 1.0f; + cubefront[1].verts[0][1] = 1.0f; + cubefront[1].verts[0][2] = 1.0f; cubefront[1].u[0] = uv_ratio; cubefront[1].v[0] = uv_ratio; - cubefront[1].verts[1][0] =-1.0; - cubefront[1].verts[1][1] = 1.0; - cubefront[1].verts[1][2] =-1.0; + cubefront[1].verts[1][0] =-1.0f; + cubefront[1].verts[1][1] = 1.0f; + cubefront[1].verts[1][2] =-1.0f; cubefront[1].u[1] = 0.0; cubefront[1].v[1] = 0.0; - cubefront[1].verts[2][0] = 1.0; - cubefront[1].verts[2][1] = 1.0; - cubefront[1].verts[2][2] =-1.0; + cubefront[1].verts[2][0] = 1.0f; + cubefront[1].verts[2][1] = 1.0f; + cubefront[1].verts[2][2] =-1.0f; cubefront[1].u[2] = uv_ratio; cubefront[1].v[2] = 0.0; nfacesfront = 2; // Left Face - 2 triangles - cubeleft[0].verts[0][0] =-1.0; - cubeleft[0].verts[0][1] = 1.0; - cubeleft[0].verts[0][2] =-1.0; + cubeleft[0].verts[0][0] =-1.0f; + cubeleft[0].verts[0][1] = 1.0f; + cubeleft[0].verts[0][2] =-1.0f; cubeleft[0].u[0] = uv_ratio; cubeleft[0].v[0] = 0.0; - cubeleft[0].verts[1][0] =-1.0; + cubeleft[0].verts[1][0] =-1.0f; cubeleft[0].verts[1][1] =-verts_height; - cubeleft[0].verts[1][2] = 1.0; + cubeleft[0].verts[1][2] = 1.0f; cubeleft[0].u[1] = uv_base; cubeleft[0].v[1] = uv_ratio; - cubeleft[0].verts[2][0] =-1.0; + cubeleft[0].verts[2][0] =-1.0f; cubeleft[0].verts[2][1] =-verts_height; - cubeleft[0].verts[2][2] =-1.0; + cubeleft[0].verts[2][2] =-1.0f; cubeleft[0].u[2] = uv_base; cubeleft[0].v[2] = 0.0; //second triangle - cubeleft[1].verts[0][0] =-1.0; + cubeleft[1].verts[0][0] =-1.0f; cubeleft[1].verts[0][1] =-verts_height; - cubeleft[1].verts[0][2] = 1.0; + cubeleft[1].verts[0][2] = 1.0f; cubeleft[1].u[0] = uv_base; cubeleft[1].v[0] = uv_ratio; - cubeleft[1].verts[1][0] =-1.0; - cubeleft[1].verts[1][1] = 1.0; - cubeleft[1].verts[1][2] =-1.0; + cubeleft[1].verts[1][0] =-1.0f; + cubeleft[1].verts[1][1] = 1.0f; + cubeleft[1].verts[1][2] =-1.0f; cubeleft[1].u[1] = uv_ratio; cubeleft[1].v[1] = 0.0; - cubeleft[1].verts[2][0] =-1.0; - cubeleft[1].verts[2][1] = 1.0; - cubeleft[1].verts[2][2] = 1.0; + cubeleft[1].verts[2][0] =-1.0f; + cubeleft[1].verts[2][1] = 1.0f; + cubeleft[1].verts[2][2] = 1.0f; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; // right Face - 2 triangles - cuberight[0].verts[0][0] = 1.0; - cuberight[0].verts[0][1] = 1.0; - cuberight[0].verts[0][2] = 1.0; + cuberight[0].verts[0][0] = 1.0f; + cuberight[0].verts[0][1] = 1.0f; + cuberight[0].verts[0][2] = 1.0f; cuberight[0].u[0] = 0.0; cuberight[0].v[0] = uv_ratio; - cuberight[0].verts[1][0] = 1.0; + cuberight[0].verts[1][0] = 1.0f; cuberight[0].verts[1][1] =-verts_height; - cuberight[0].verts[1][2] =-1.0; + cuberight[0].verts[1][2] =-1.0f; cuberight[0].u[1] = uv_height; cuberight[0].v[1] = 0.0; - cuberight[0].verts[2][0] = 1.0; + cuberight[0].verts[2][0] = 1.0f; cuberight[0].verts[2][1] =-verts_height; - cuberight[0].verts[2][2] = 1.0; + cuberight[0].verts[2][2] = 1.0f; cuberight[0].u[2] = uv_height; cuberight[0].v[2] = uv_ratio; //second triangle - cuberight[1].verts[0][0] = 1.0; + cuberight[1].verts[0][0] = 1.0f; cuberight[1].verts[0][1] =-verts_height; - cuberight[1].verts[0][2] =-1.0; + cuberight[1].verts[0][2] =-1.0f; cuberight[1].u[0] = uv_height; cuberight[1].v[0] = 0.0; - cuberight[1].verts[1][0] = 1.0; - cuberight[1].verts[1][1] = 1.0; - cuberight[1].verts[1][2] = 1.0; + cuberight[1].verts[1][0] = 1.0f; + cuberight[1].verts[1][1] = 1.0f; + cuberight[1].verts[1][2] = 1.0f; cuberight[1].u[1] = 0.0; cuberight[1].v[1] = uv_ratio; - cuberight[1].verts[2][0] = 1.0; - cuberight[1].verts[2][1] = 1.0; - cuberight[1].verts[2][2] =-1.0; + cuberight[1].verts[2][0] = 1.0f; + cuberight[1].verts[2][1] = 1.0f; + cuberight[1].verts[2][2] =-1.0f; cuberight[1].u[2] = 0.0; cuberight[1].v[2] = 0.0; nfacesright = 2; // top Face - 2 triangles - cubetop[0].verts[0][0] =-1.0; - cubetop[0].verts[0][1] = 1.0; - cubetop[0].verts[0][2] = 1.0; + cubetop[0].verts[0][0] =-1.0f; + cubetop[0].verts[0][1] = 1.0f; + cubetop[0].verts[0][2] = 1.0f; cubetop[0].u[0] = 0.0; cubetop[0].v[0] = 0.0; - cubetop[0].verts[1][0] = 1.0; + cubetop[0].verts[1][0] = 1.0f; cubetop[0].verts[1][1] =-verts_height; - cubetop[0].verts[1][2] = 1.0; + cubetop[0].verts[1][2] = 1.0f; cubetop[0].u[1] = uv_ratio; cubetop[0].v[1] = uv_height; - cubetop[0].verts[2][0] =-1.0; + cubetop[0].verts[2][0] =-1.0f; cubetop[0].verts[2][1] =-verts_height; - cubetop[0].verts[2][2] = 1.0; + cubetop[0].verts[2][2] = 1.0f; cubetop[0].u[2] = 0.0; cubetop[0].v[2] = uv_height; //second triangle - cubetop[1].verts[0][0] = 1.0; + cubetop[1].verts[0][0] = 1.0f; cubetop[1].verts[0][1] =-verts_height; - cubetop[1].verts[0][2] = 1.0; + cubetop[1].verts[0][2] = 1.0f; cubetop[1].u[0] = uv_ratio; cubetop[1].v[0] = uv_height; - cubetop[1].verts[1][0] =-1.0; - cubetop[1].verts[1][1] = 1.0; - cubetop[1].verts[1][2] = 1.0; + cubetop[1].verts[1][0] =-1.0f; + cubetop[1].verts[1][1] = 1.0f; + cubetop[1].verts[1][2] = 1.0f; cubetop[1].u[1] = 0.0; cubetop[1].v[1] = 0.0; - cubetop[1].verts[2][0] = 1.0; - cubetop[1].verts[2][1] = 1.0; - cubetop[1].verts[2][2] = 1.0; + cubetop[1].verts[2][0] = 1.0f; + cubetop[1].verts[2][1] = 1.0f; + cubetop[1].verts[2][2] = 1.0f; cubetop[1].u[2] = uv_ratio; cubetop[1].v[2] = 0.0; nfacestop = 2; // bottom Face - 2 triangles - cubebottom[0].verts[0][0] =-1.0; + cubebottom[0].verts[0][0] =-1.0f; cubebottom[0].verts[0][1] =-verts_height; - cubebottom[0].verts[0][2] =-1.0; + cubebottom[0].verts[0][2] =-1.0f; cubebottom[0].u[0] = 0.0; cubebottom[0].v[0] = uv_base; - cubebottom[0].verts[1][0] = 1.0; - cubebottom[0].verts[1][1] = 1.0; - cubebottom[0].verts[1][2] =-1.0; + cubebottom[0].verts[1][0] = 1.0f; + cubebottom[0].verts[1][1] = 1.0f; + cubebottom[0].verts[1][2] =-1.0f; cubebottom[0].u[1] = uv_ratio; cubebottom[0].v[1] = uv_ratio; - cubebottom[0].verts[2][0] =-1.0; - cubebottom[0].verts[2][1] = 1.0; - cubebottom[0].verts[2][2] =-1.0; + cubebottom[0].verts[2][0] =-1.0f; + cubebottom[0].verts[2][1] = 1.0f; + cubebottom[0].verts[2][2] =-1.0f; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = uv_ratio; //second triangle - cubebottom[1].verts[0][0] = 1.0; - cubebottom[1].verts[0][1] = 1.0; - cubebottom[1].verts[0][2] =-1.0; + cubebottom[1].verts[0][0] = 1.0f; + cubebottom[1].verts[0][1] = 1.0f; + cubebottom[1].verts[0][2] =-1.0f; cubebottom[1].u[0] = uv_ratio; cubebottom[1].v[0] = uv_ratio; - cubebottom[1].verts[1][0] =-1.0; + cubebottom[1].verts[1][0] =-1.0f; cubebottom[1].verts[1][1] =-verts_height; - cubebottom[1].verts[1][2] =-1.0; + cubebottom[1].verts[1][2] =-1.0f; cubebottom[1].u[1] = 0.0; cubebottom[1].v[1] = uv_base; - cubebottom[1].verts[2][0] = 1.0; + cubebottom[1].verts[2][0] = 1.0f; cubebottom[1].verts[2][1] =-verts_height; - cubebottom[1].verts[2][2] =-1.0; + cubebottom[1].verts[2][2] =-1.0f; cubebottom[1].u[2] = uv_ratio; cubebottom[1].v[2] = uv_base; @@ -1012,80 +1012,80 @@ void KX_Dome::CreateMeshPanorama(void) float uv_ratio = (float)(m_buffersize-1) / m_imagesize; /* Top face - two triangles */ - cubetop[0].verts[0][0] = -M_SQRT2; - cubetop[0].verts[0][1] = 0.0; - cubetop[0].verts[0][2] = 1.0; + cubetop[0].verts[0][0] = (float)(-M_SQRT2); + cubetop[0].verts[0][1] = 0.0f; + cubetop[0].verts[0][2] = 1.0f; cubetop[0].u[0] = 0.0; cubetop[0].v[0] = uv_ratio; - cubetop[0].verts[1][0] = 0.0; - cubetop[0].verts[1][1] = M_SQRT2; - cubetop[0].verts[1][2] = 1.0; + cubetop[0].verts[1][0] = 0.0f; + cubetop[0].verts[1][1] = (float)M_SQRT2; + cubetop[0].verts[1][2] = 1.0f; cubetop[0].u[1] = 0.0; cubetop[0].v[1] = 0.0; //second triangle - cubetop[0].verts[2][0] = M_SQRT2; - cubetop[0].verts[2][1] = 0.0; - cubetop[0].verts[2][2] = 1.0; + cubetop[0].verts[2][0] = (float)M_SQRT2; + cubetop[0].verts[2][1] = 0.0f; + cubetop[0].verts[2][2] = 1.0f; cubetop[0].u[2] = uv_ratio; cubetop[0].v[2] = 0.0; - cubetop[1].verts[0][0] = M_SQRT2; - cubetop[1].verts[0][1] = 0.0; - cubetop[1].verts[0][2] = 1.0; + cubetop[1].verts[0][0] = (float)M_SQRT2; + cubetop[1].verts[0][1] = 0.0f; + cubetop[1].verts[0][2] = 1.0f; cubetop[1].u[0] = uv_ratio; cubetop[1].v[0] = 0.0; - cubetop[1].verts[1][0] = 0.0; - cubetop[1].verts[1][1] = -M_SQRT2; - cubetop[1].verts[1][2] = 1.0; + cubetop[1].verts[1][0] = 0.0f; + cubetop[1].verts[1][1] = (float)(-M_SQRT2); + cubetop[1].verts[1][2] = 1.0f; cubetop[1].u[1] = uv_ratio; cubetop[1].v[1] = uv_ratio; - cubetop[1].verts[2][0] = -M_SQRT2; - cubetop[1].verts[2][1] = 0.0; - cubetop[1].verts[2][2] = 1.0; + cubetop[1].verts[2][0] = (float)(-M_SQRT2); + cubetop[1].verts[2][1] = 0.0f; + cubetop[1].verts[2][2] = 1.0f; cubetop[1].u[2] = 0.0; cubetop[1].v[2] = uv_ratio; nfacestop = 2; /* Bottom face - two triangles */ - cubebottom[0].verts[0][0] = -M_SQRT2; - cubebottom[0].verts[0][1] = 0.0; - cubebottom[0].verts[0][2] = -1.0; + cubebottom[0].verts[0][0] = (float)(-M_SQRT2); + cubebottom[0].verts[0][1] = 0.0f; + cubebottom[0].verts[0][2] = -1.0f; cubebottom[0].u[0] = uv_ratio; cubebottom[0].v[0] = 0.0; - cubebottom[0].verts[1][0] = M_SQRT2; - cubebottom[0].verts[1][1] = 0.0; - cubebottom[0].verts[1][2] = -1.0; + cubebottom[0].verts[1][0] = (float)M_SQRT2; + cubebottom[0].verts[1][1] = 0.0f; + cubebottom[0].verts[1][2] = -1.0f; cubebottom[0].u[1] = 0.0; cubebottom[0].v[1] = uv_ratio; - cubebottom[0].verts[2][0] = 0.0; - cubebottom[0].verts[2][1] = M_SQRT2; - cubebottom[0].verts[2][2] = -1.0; + cubebottom[0].verts[2][0] = 0.0f; + cubebottom[0].verts[2][1] = (float)M_SQRT2; + cubebottom[0].verts[2][2] = -1.0f; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = 0.0; //second triangle - cubebottom[1].verts[0][0] = M_SQRT2; - cubebottom[1].verts[0][1] = 0.0; - cubebottom[1].verts[0][2] = -1.0; + cubebottom[1].verts[0][0] = (float)M_SQRT2; + cubebottom[1].verts[0][1] = 0.0f; + cubebottom[1].verts[0][2] = -1.0f; cubebottom[1].u[0] = 0.0; cubebottom[1].v[0] = uv_ratio; - cubebottom[1].verts[1][0] = -M_SQRT2; - cubebottom[1].verts[1][1] = 0.0; - cubebottom[1].verts[1][2] = -1.0; + cubebottom[1].verts[1][0] = (float)(-M_SQRT2); + cubebottom[1].verts[1][1] = 0.0f; + cubebottom[1].verts[1][2] = -1.0f; cubebottom[1].u[1] = uv_ratio; cubebottom[1].v[1] = 0.0; - cubebottom[1].verts[2][0] = 0.0; - cubebottom[1].verts[2][1] = -M_SQRT2; - cubebottom[1].verts[2][2] = -1.0; + cubebottom[1].verts[2][0] = 0.0f; + cubebottom[1].verts[2][1] = (float)(-M_SQRT2); + cubebottom[1].verts[2][2] = -1.0f; cubebottom[1].u[2] = uv_ratio; cubebottom[1].v[2] = uv_ratio; @@ -1093,40 +1093,40 @@ void KX_Dome::CreateMeshPanorama(void) /* Left Back (135deg) face - two triangles */ - cubeleftback[0].verts[0][0] = 0; - cubeleftback[0].verts[0][1] = -M_SQRT2; - cubeleftback[0].verts[0][2] = -1.0; - cubeleftback[0].u[0] = 0; - cubeleftback[0].v[0] = 0; + cubeleftback[0].verts[0][0] = 0.0f; + cubeleftback[0].verts[0][1] = (float)(-M_SQRT2); + cubeleftback[0].verts[0][2] = -1.0f; + cubeleftback[0].u[0] = 0.0; + cubeleftback[0].v[0] = 0.0; - cubeleftback[0].verts[1][0] = -M_SQRT2; - cubeleftback[0].verts[1][1] = 0; - cubeleftback[0].verts[1][2] = -1.0; + cubeleftback[0].verts[1][0] = (float)(-M_SQRT2); + cubeleftback[0].verts[1][1] = 0.0f; + cubeleftback[0].verts[1][2] = -1.0f; cubeleftback[0].u[1] = uv_ratio; - cubeleftback[0].v[1] = 0; + cubeleftback[0].v[1] = 0.0; - cubeleftback[0].verts[2][0] = 0; - cubeleftback[0].verts[2][1] = -M_SQRT2; - cubeleftback[0].verts[2][2] = 1.0; - cubeleftback[0].u[2] = 0; + cubeleftback[0].verts[2][0] = 0.0f; + cubeleftback[0].verts[2][1] = (float)(-M_SQRT2); + cubeleftback[0].verts[2][2] = 1.0f; + cubeleftback[0].u[2] = 0.0; cubeleftback[0].v[2] = uv_ratio; //second triangle - cubeleftback[1].verts[0][0] = 0; - cubeleftback[1].verts[0][1] = -M_SQRT2; - cubeleftback[1].verts[0][2] = 1.0; - cubeleftback[1].u[0] = 0; + cubeleftback[1].verts[0][0] = 0.0f; + cubeleftback[1].verts[0][1] = (float)(-M_SQRT2); + cubeleftback[1].verts[0][2] = 1.0f; + cubeleftback[1].u[0] = 0.0; cubeleftback[1].v[0] = uv_ratio; - cubeleftback[1].verts[1][0] = -M_SQRT2; - cubeleftback[1].verts[1][1] = 0; - cubeleftback[1].verts[1][2] = -1.0; + cubeleftback[1].verts[1][0] = (float)(-M_SQRT2); + cubeleftback[1].verts[1][1] = 0.0f; + cubeleftback[1].verts[1][2] = -1.0f; cubeleftback[1].u[1] = uv_ratio; - cubeleftback[1].v[1] = 0; + cubeleftback[1].v[1] = 0.0; - cubeleftback[1].verts[2][0] = -M_SQRT2; - cubeleftback[1].verts[2][1] = 0; - cubeleftback[1].verts[2][2] = 1.0; + cubeleftback[1].verts[2][0] = (float)(-M_SQRT2); + cubeleftback[1].verts[2][1] = 0.0f; + cubeleftback[1].verts[2][2] = 1.0f; cubeleftback[1].u[2] = uv_ratio; cubeleftback[1].v[2] = uv_ratio; @@ -1134,121 +1134,121 @@ void KX_Dome::CreateMeshPanorama(void) /* Left face - two triangles */ - cubeleft[0].verts[0][0] = -M_SQRT2; - cubeleft[0].verts[0][1] = 0; - cubeleft[0].verts[0][2] = -1.0; - cubeleft[0].u[0] = 0; - cubeleft[0].v[0] = 0; - - cubeleft[0].verts[1][0] = 0; - cubeleft[0].verts[1][1] = M_SQRT2; - cubeleft[0].verts[1][2] = -1.0; + cubeleft[0].verts[0][0] = (float)(-M_SQRT2); + cubeleft[0].verts[0][1] = 0.0f; + cubeleft[0].verts[0][2] = -1.0f; + cubeleft[0].u[0] = 0.0; + cubeleft[0].v[0] = 0.0; + + cubeleft[0].verts[1][0] = 0.0f; + cubeleft[0].verts[1][1] = (float)M_SQRT2; + cubeleft[0].verts[1][2] = -1.0f; cubeleft[0].u[1] = uv_ratio; - cubeleft[0].v[1] = 0; + cubeleft[0].v[1] = 0.0; - cubeleft[0].verts[2][0] = -M_SQRT2; - cubeleft[0].verts[2][1] = 0; - cubeleft[0].verts[2][2] = 1.0; - cubeleft[0].u[2] = 0; + cubeleft[0].verts[2][0] = (float)(-M_SQRT2); + cubeleft[0].verts[2][1] = 0.0f; + cubeleft[0].verts[2][2] = 1.0f; + cubeleft[0].u[2] = 0.0; cubeleft[0].v[2] = uv_ratio; //second triangle - cubeleft[1].verts[0][0] = -M_SQRT2; - cubeleft[1].verts[0][1] = 0; - cubeleft[1].verts[0][2] = 1.0; - cubeleft[1].u[0] = 0; + cubeleft[1].verts[0][0] = (float)(-M_SQRT2); + cubeleft[1].verts[0][1] = 0.0f; + cubeleft[1].verts[0][2] = 1.0f; + cubeleft[1].u[0] = 0.0; cubeleft[1].v[0] = uv_ratio; - cubeleft[1].verts[1][0] = 0; - cubeleft[1].verts[1][1] = M_SQRT2; - cubeleft[1].verts[1][2] = -1.0; + cubeleft[1].verts[1][0] = 0.0f; + cubeleft[1].verts[1][1] = (float)M_SQRT2; + cubeleft[1].verts[1][2] = -1.0f; cubeleft[1].u[1] = uv_ratio; - cubeleft[1].v[1] = 0; + cubeleft[1].v[1] = 0.0; - cubeleft[1].verts[2][0] = 0; - cubeleft[1].verts[2][1] = M_SQRT2; - cubeleft[1].verts[2][2] = 1.0; + cubeleft[1].verts[2][0] = 0.0f; + cubeleft[1].verts[2][1] = (float)M_SQRT2; + cubeleft[1].verts[2][2] = 1.0f; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; /* Right face - two triangles */ - cuberight[0].verts[0][0] = 0; - cuberight[0].verts[0][1] = M_SQRT2; - cuberight[0].verts[0][2] = -1.0; - cuberight[0].u[0] = 0; - cuberight[0].v[0] = 0; - - cuberight[0].verts[1][0] = M_SQRT2; - cuberight[0].verts[1][1] = 0; - cuberight[0].verts[1][2] = -1.0; + cuberight[0].verts[0][0] = 0.0f; + cuberight[0].verts[0][1] = (float)M_SQRT2; + cuberight[0].verts[0][2] = -1.0f; + cuberight[0].u[0] = 0.0; + cuberight[0].v[0] = 0.0; + + cuberight[0].verts[1][0] = (float)M_SQRT2; + cuberight[0].verts[1][1] = 0.0f; + cuberight[0].verts[1][2] = -1.0f; cuberight[0].u[1] = uv_ratio; - cuberight[0].v[1] = 0; + cuberight[0].v[1] = 0.0; - cuberight[0].verts[2][0] = M_SQRT2; - cuberight[0].verts[2][1] = 0; - cuberight[0].verts[2][2] = 1.0; + cuberight[0].verts[2][0] = (float)M_SQRT2; + cuberight[0].verts[2][1] = 0.0f; + cuberight[0].verts[2][2] = 1.0f; cuberight[0].u[2] = uv_ratio; cuberight[0].v[2] = uv_ratio; //second triangle - cuberight[1].verts[0][0] = 0; - cuberight[1].verts[0][1] = M_SQRT2; - cuberight[1].verts[0][2] = -1.0; - cuberight[1].u[0] = 0; - cuberight[1].v[0] = 0; - - cuberight[1].verts[1][0] = M_SQRT2; - cuberight[1].verts[1][1] = 0; - cuberight[1].verts[1][2] = 1.0; + cuberight[1].verts[0][0] = 0.0f; + cuberight[1].verts[0][1] = (float)M_SQRT2; + cuberight[1].verts[0][2] = -1.0f; + cuberight[1].u[0] = 0.0; + cuberight[1].v[0] = 0.0; + + cuberight[1].verts[1][0] = (float)M_SQRT2; + cuberight[1].verts[1][1] = 0.0f; + cuberight[1].verts[1][2] = 1.0f; cuberight[1].u[1] = uv_ratio; cuberight[1].v[1] = uv_ratio; - cuberight[1].verts[2][0] = 0; - cuberight[1].verts[2][1] = M_SQRT2; - cuberight[1].verts[2][2] = 1.0; - cuberight[1].u[2] = 0; + cuberight[1].verts[2][0] = 0.0f; + cuberight[1].verts[2][1] = (float)M_SQRT2; + cuberight[1].verts[2][2] = 1.0f; + cuberight[1].u[2] = 0.0f; cuberight[1].v[2] = uv_ratio; nfacesright = 2; /* Right Back (-135deg) face - two triangles */ - cuberightback[0].verts[0][0] = M_SQRT2; - cuberightback[0].verts[0][1] = 0; - cuberightback[0].verts[0][2] = -1.0; - cuberightback[0].u[0] = 0; - cuberightback[0].v[0] = 0; - - cuberightback[0].verts[1][0] = 0; - cuberightback[0].verts[1][1] = -M_SQRT2; - cuberightback[0].verts[1][2] = -1.0; + cuberightback[0].verts[0][0] = (float)M_SQRT2; + cuberightback[0].verts[0][1] = 0.0f; + cuberightback[0].verts[0][2] = -1.0f; + cuberightback[0].u[0] = 0.0; + cuberightback[0].v[0] = 0.0; + + cuberightback[0].verts[1][0] = 0.0f; + cuberightback[0].verts[1][1] = (float)(-M_SQRT2); + cuberightback[0].verts[1][2] = -1.0f; cuberightback[0].u[1] = uv_ratio; - cuberightback[0].v[1] = 0; + cuberightback[0].v[1] = 0.0; - cuberightback[0].verts[2][0] = 0; - cuberightback[0].verts[2][1] = -M_SQRT2; - cuberightback[0].verts[2][2] = 1.0; + cuberightback[0].verts[2][0] = 0.0f; + cuberightback[0].verts[2][1] = (float)(-M_SQRT2); + cuberightback[0].verts[2][2] = 1.0f; cuberightback[0].u[2] = uv_ratio; cuberightback[0].v[2] = uv_ratio; //second triangle - cuberightback[1].verts[0][0] = M_SQRT2; - cuberightback[1].verts[0][1] = 0; - cuberightback[1].verts[0][2] = -1.0; - cuberightback[1].u[0] = 0; - cuberightback[1].v[0] = 0; - - cuberightback[1].verts[1][0] = 0; - cuberightback[1].verts[1][1] = -M_SQRT2; - cuberightback[1].verts[1][2] = 1.0; + cuberightback[1].verts[0][0] = (float)M_SQRT2; + cuberightback[1].verts[0][1] = 0.0f; + cuberightback[1].verts[0][2] = -1.0f; + cuberightback[1].u[0] = 0.0; + cuberightback[1].v[0] = 0.0; + + cuberightback[1].verts[1][0] = 0.0f; + cuberightback[1].verts[1][1] = (float)(-M_SQRT2); + cuberightback[1].verts[1][2] = 1.0f; cuberightback[1].u[1] = uv_ratio; cuberightback[1].v[1] = uv_ratio; - cuberightback[1].verts[2][0] = M_SQRT2; - cuberightback[1].verts[2][1] = 0; - cuberightback[1].verts[2][2] = 1.0; - cuberightback[1].u[2] = 0; + cuberightback[1].verts[2][0] = (float)M_SQRT2; + cuberightback[1].verts[2][1] = 0.0f; + cuberightback[1].verts[2][2] = 1.0f; + cuberightback[1].u[2] = 0.0; cuberightback[1].v[2] = uv_ratio; nfacesrightback = 2; @@ -1328,13 +1328,13 @@ void KX_Dome::FlattenDome(MT_Vector3 verts[3]) phi = atan2(verts[i][2], verts[i][0]); verts[i][0] = r * cos(phi); - verts[i][1] = 0; + verts[i][1] = 0.0f; verts[i][2] = r * sin(phi); if (r > 1.0) { //round the border verts[i][0] = cos(phi); - verts[i][1] = -3.0; + verts[i][1] = -3.0f; verts[i][2] = sin(phi); } } @@ -1355,7 +1355,7 @@ void KX_Dome::FlattenPanorama(MT_Vector3 verts[3]) edge=true; verts[i][0] = phi / MT_PI; - verts[i][1] = 0; + verts[i][1] = 0.0f; theta = asin(verts[i][2]); verts[i][2] = theta / MT_PI; @@ -1364,15 +1364,15 @@ void KX_Dome::FlattenPanorama(MT_Vector3 verts[3]) bool right=false; for (i=0;i<3;i++) { - if (fmod(verts[i][0],1.0) > 0.0) { + if (fmodf(verts[i][0],1.0f) > 0.0f) { right=true; break; } } if (right) { for (i=0;i<3;i++) { - if (verts[i][0] < 0.0) - verts[i][0] *= -1.0; + if (verts[i][0] < 0.0f) + verts[i][0] *= -1.0f; } } } @@ -1438,8 +1438,8 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) // manually creating a 90deg Field of View Frustum // the original formula: - top = tan(fov*3.14159/360.0) * near [for fov in degrees] - fov*0.5 = arctan ((top-bottom)*0.5 / near) [for fov in radians] + top = tan(fov*3.14159f/30.0f)) * near [for fov in degrees] + fov*0.5f = arctan ((top-bottom)*0.5f / near) [for fov in radians] bottom = -top left = aspect * bottom right = aspect * top @@ -1447,7 +1447,7 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) // the equivalent GLU call is: glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(90.0,1.0,cam->GetCameraNear(),cam->GetCameraFar()); + gluPerspective(90.0f,1.0f,cam->GetCameraNear(),cam->GetCameraFar()); #endif RAS_FrameFrustum m_frustrum; //90 deg. Frustum @@ -1455,7 +1455,7 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) m_frustrum.camnear = cam->GetCameraNear(); m_frustrum.camfar = cam->GetCameraFar(); -// float top = tan(90.0*MT_PI/360.0) * m_frustrum.camnear; +// float top = tan(90.0f*MT_PI/360.0f) * m_frustrum.camnear; float top = m_frustrum.camnear; // for deg = 90deg, tan = 1 m_frustrum.x1 = -top; @@ -1476,112 +1476,112 @@ void KX_Dome::CalculateCameraOrientation() * Uses 6 cameras for angles up to 360deg */ int i; - float deg45 = MT_PI / 4; - MT_Scalar c = cos(deg45); - MT_Scalar s = sin(deg45); + float deg45 = MT_PI / 4.0f; + MT_Scalar c = cosf(deg45); + MT_Scalar s = sinf(deg45); if (m_angle <= 180 && (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR)) { m_locRot[0] = MT_Matrix3x3( // 90deg - Top - c, -s, 0.0, - 0.0,0.0, -1.0, - s, c, 0.0); + c, -s, 0.0f, + 0.0f,0.0f, -1.0f, + s, c, 0.0f); m_locRot[1] = MT_Matrix3x3( // 90deg - Bottom - -s, c, 0.0, - 0.0,0.0, 1.0, - s, c, 0.0); + -s, c, 0.0f, + 0.0f,0.0f, 1.0f, + s, c, 0.0f); m_locRot[2] = MT_Matrix3x3( // 45deg - Left - c, 0.0, s, - 0, 1.0, 0.0, - -s, 0.0, c); + c, 0.0f, s, + 0, 1.0f, 0.0f, + -s, 0.0f, c); m_locRot[3] = MT_Matrix3x3( // 45deg - Right - c, 0.0, -s, - 0.0, 1.0, 0.0, - s, 0.0, c); + c, 0.0f, -s, + 0.0f, 1.0f, 0.0f, + s, 0.0f, c); } else if (m_mode == DOME_ENVMAP || (m_angle > 180 && (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR))) { m_locRot[0] = MT_Matrix3x3( // 90deg - Top - 1.0, 0.0, 0.0, - 0.0, 0.0,-1.0, - 0.0, 1.0, 0.0); + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f,-1.0f, + 0.0f, 1.0f, 0.0f); m_locRot[1] = MT_Matrix3x3( // 90deg - Bottom - 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 0.0,-1.0, 0.0); + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + 0.0f,-1.0f, 0.0f); m_locRot[2] = MT_Matrix3x3( // -90deg - Left - 0.0, 0.0, 1.0, - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0); + 0.0f, 0.0f, 1.0f, + 0.0f, 1.0f, 0.0f, + -1.0f, 0.0f, 0.0f); m_locRot[3] = MT_Matrix3x3( // 90deg - Right - 0.0, 0.0,-1.0, - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0); + 0.0f, 0.0f,-1.0f, + 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f); m_locRot[4] = MT_Matrix3x3( // 0deg - Front - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0); + 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f); m_locRot[5] = MT_Matrix3x3( // 180deg - Back - USED for ENVMAP only - -1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0,-1.0); + -1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f,-1.0f); } else if (m_mode == DOME_PANORAM_SPH) { m_locRot[0] = MT_Matrix3x3( // Top - c, s, 0.0, - 0.0,0.0, -1.0, - -s, c, 0.0); + c, s, 0.0f, + 0.0f,0.0f, -1.0f, + -s, c, 0.0f); m_locRot[1] = MT_Matrix3x3( // Bottom - c, s, 0.0, - 0.0, 0.0, 1.0, - s, -c, 0.0); + c, s, 0.0f, + 0.0f, 0.0f, 1.0f, + s, -c, 0.0f); m_locRot[2] = MT_Matrix3x3( // 45deg - Left - -s, 0.0, c, - 0, 1.0, 0.0, - -c, 0.0, -s); + -s, 0.0f, c, + 0, 1.0f, 0.0f, + -c, 0.0f, -s); m_locRot[3] = MT_Matrix3x3( // 45deg - Right - c, 0.0, s, - 0, 1.0, 0.0, - -s, 0.0, c); + c, 0.0f, s, + 0, 1.0f, 0.0f, + -s, 0.0f, c); m_locRot[4] = MT_Matrix3x3( // 135deg - LeftBack - -s, 0.0, -c, - 0.0, 1.0, 0.0, - c, 0.0, -s); + -s, 0.0f, -c, + 0.0f, 1.0f, 0.0f, + c, 0.0f, -s); m_locRot[5] = MT_Matrix3x3( // 135deg - RightBack - c, 0.0, -s, - 0.0, 1.0, 0.0, - s, 0.0, c); + c, 0.0f, -s, + 0.0f, 1.0f, 0.0f, + s, 0.0f, c); } // rotating the camera in horizontal axis if (m_tilt) { float tiltdeg = ((m_tilt % 360) * 2 * MT_PI) / 360; - c = cos(tiltdeg); - s = sin(tiltdeg); + c = cosf(tiltdeg); + s = sinf(tiltdeg); MT_Matrix3x3 tilt_mat = MT_Matrix3x3( - 1.0, 0.0, 0.0, - 0.0, c, -s, - 0.0, s, c + 1.0f, 0.0f, 0.0f, + 0.0f, c, -s, + 0.0f, s, c ); for (i =0;i<6;i++) @@ -1667,11 +1667,11 @@ void KX_Dome::DrawEnvMap(void) float ortho_width, ortho_height; if (warp.usemesh) - glOrtho((-1.0), 1.0, (-0.66), 0.66, -20.0, 10.0); //stretch the image to reduce resolution lost + glOrtho((-1.0), 1.0, (-0.66), 0.66, 0.0, 0.0); //stretch the image to reduce resolution lost else { if (can_width/3 <= can_height/2) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = (float)can_height/can_width; } else { @@ -1679,14 +1679,14 @@ void KX_Dome::DrawEnvMap(void) ortho_width = (float)can_width/can_height * ortho_height; } - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0,0.0,1.0, 0.0,0.0,0.0, 0.0,1.0,0.0); + gluLookAt(0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f); glPolygonMode(GL_FRONT, GL_FILL); glShadeModel(GL_SMOOTH); @@ -1694,7 +1694,7 @@ void KX_Dome::DrawEnvMap(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); float uv_ratio = (float)(m_buffersize-1) / m_imagesize; double onebythree = 1.0f / 3; @@ -1704,11 +1704,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-onebythree,-2 * onebythree, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(onebythree,-2 * onebythree, 3.0f); glEnd(); @@ -1717,11 +1717,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f(-onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-1.0f, 0.0f, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-2 * onebythree, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(-onebythree,-2 * onebythree, 3.0f); glEnd(); @@ -1730,11 +1730,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f(-onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-1.0f, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f, 0.0f, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(-onebythree, 0.0f, 3.0f); glEnd(); @@ -1743,11 +1743,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( 1.0f, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f( onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f( onebythree, 0.0f, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(1.0f, 0.0f, 3.0f); glEnd(); @@ -1756,11 +1756,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( 1.0f, 0.0f, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f( onebythree, 0.0f, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f( onebythree,-2 * onebythree, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(1.0f, -2 * onebythree, 3.0f); glEnd(); @@ -1769,11 +1769,11 @@ void KX_Dome::DrawEnvMap(void) glBegin(GL_QUADS); glTexCoord2f(uv_ratio,uv_ratio); glVertex3f( onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,uv_ratio); + glTexCoord2f(0.0f,uv_ratio); glVertex3f(-onebythree, 2 * onebythree, 3.0f); - glTexCoord2f(0.0,0.0); + glTexCoord2f(0.0f,0.0f); glVertex3f(-onebythree, 0.0f, 3.0f); - glTexCoord2f(uv_ratio,0.0); + glTexCoord2f(uv_ratio,0.0f); glVertex3f(onebythree, 0.0f, 3.0f); glEnd(); @@ -1798,40 +1798,40 @@ void KX_Dome::DrawDomeFisheye(void) if (m_mode == DOME_FISHEYE) { if (warp.usemesh) - glOrtho((-1.0), 1.0, (-1.0), 1.0, -20.0, 10.0); //stretch the image to reduce resolution lost + glOrtho((-1.0f), 1.0f, (-1.0f), 1.0f, -20.0f, 10.0f); //stretch the image to reduce resolution lost else { if (can_width < can_height) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = (float)can_height/can_width; } else { ortho_width = (float)can_width/can_height; - ortho_height = 1.0; + ortho_height = 1.0f; } - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } } else if (m_mode == DOME_TRUNCATED_FRONT) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f; - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0f, 10.0f); } else { //m_mode == DOME_TRUNCATED_REAR - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f; - glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0f, 10.0f); } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0,-1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0); + gluLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f); if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME) glPolygonMode(GL_FRONT, GL_LINE); @@ -1843,7 +1843,7 @@ void KX_Dome::DrawDomeFisheye(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); if (dlistSupported) { for (i=0;i<m_numfaces;i++) { @@ -1890,16 +1890,16 @@ void KX_Dome::DrawPanorama(void) int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); - float ortho_height = 1.0; - float ortho_width = 1.0; + float ortho_height = 1.0f; + float ortho_width = 1.0f; if (warp.usemesh) - glOrtho((-1.0), 1.0, (-0.5), 0.5, -20.0, 10.0); //stretch the image to reduce resolution lost + glOrtho((-1.0f), 1.0f, (-0.5f), 0.5f, -20.0f, 10.0f); //stretch the image to reduce resolution lost else { //using all the screen if ((can_width / 2) <= (can_height)) { - ortho_width = 1.0; + ortho_width = 1.0f; ortho_height = (float)can_height/can_width; } else { @@ -1907,14 +1907,14 @@ void KX_Dome::DrawPanorama(void) ortho_height = 0.5f; } - glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0); + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0,-1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0); + gluLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f); if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME) glPolygonMode(GL_FRONT, GL_LINE); @@ -1926,7 +1926,7 @@ void KX_Dome::DrawPanorama(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); if (dlistSupported) { for (i=0;i<m_numfaces;i++) { @@ -1975,14 +1975,14 @@ void KX_Dome::DrawDomeWarped(void) double screen_ratio = can_width/ (double) can_height; - glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0); + glOrtho(-screen_ratio,screen_ratio,-1.0f,1.0f,-20.0f,10.0f); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt(0.0, 0.0, 1.0, 0.0,0.0,0.0, 0.0,1.0,0.0); + gluLookAt(0.0f, 0.0f, 1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f); if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME) glPolygonMode(GL_FRONT, GL_LINE); @@ -1994,7 +1994,7 @@ void KX_Dome::DrawDomeWarped(void) glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); - glColor3f(1.0,1.0,1.0); + glColor3f(1.0f,1.0f,1.0f); if (dlistSupported) { glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]); @@ -2036,7 +2036,7 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i) MT_Transform camtrans(cam->GetWorldToCamera()); MT_Matrix4x4 viewmat(camtrans); - m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), 1.0); + m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), 1.0f); cam->SetModelviewMatrix(viewmat); // restore the original orientation diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 420f1f7eb98..364f8d4bfc6 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -193,15 +193,14 @@ void KX_FontObject::DrawFontText() const float aspect = m_fsize / size; /* Get a working copy of the OpenGLMatrix to use */ - double mat[16]; - memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16); + float *mat = GetOpenGLMatrix(); /* Account for offset */ MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset * this->NodeGetWorldScaling(); mat[12] += offset[0]; mat[13] += offset[1]; mat[14] += offset[2]; /* Orient the spacing vector */ - MT_Vector3 spacing = MT_Vector3(0, m_fsize*m_line_spacing, 0); + MT_Vector3 spacing = MT_Vector3(0.0f, m_fsize*m_line_spacing, 0.0f); spacing = this->NodeGetWorldOrientation() * spacing * this->NodeGetWorldScaling()[1]; /* Draw each line, taking spacing into consideration */ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 5e66250bd80..ad6447778e5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -83,11 +83,11 @@ #include "BLI_math.h" -static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0); -static MT_Vector3 dummy_scaling = MT_Vector3(1.0, 1.0, 1.0); -static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0); +static MT_Point3 dummy_point= MT_Point3(0.0f, 0.0f, 0.0f); +static MT_Vector3 dummy_scaling = MT_Vector3(1.0f, 1.0f, 1.0f); +static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f); KX_GameObject::KX_GameObject( void* sgReplicationInfo, @@ -101,7 +101,7 @@ KX_GameObject::KX_GameObject( m_pBlenderGroupObject(NULL), m_bUseObjectColor(false), m_bIsNegativeScaling(false), - m_objectColor(1.0, 1.0, 1.0, 1.0), + m_objectColor(1.0f, 1.0f, 1.0f, 1.0f), m_bVisible(true), m_bCulled(true), m_bOccluder(false), @@ -354,9 +354,9 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom m_pPhysicsController->SuspendDynamics(ghost); } // Set us to our new scale, position, and orientation - scale2[0] = 1.0/scale2[0]; - scale2[1] = 1.0/scale2[1]; - scale2[2] = 1.0/scale2[2]; + scale2[0] = 1.0f/scale2[0]; + scale2[1] = 1.0f/scale2[1]; + scale2[2] = 1.0f/scale2[2]; scale1 = scale1 * scale2; MT_Matrix3x3 invori = obj->NodeGetWorldOrientation().inverse(); MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale2; @@ -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; @@ -711,7 +711,7 @@ double* KX_GameObject::GetOpenGLMatrix() trans.setBasis(GetSGNode()->GetWorldOrientation()); MT_Vector3 scaling = GetSGNode()->GetWorldScaling(); - m_bIsNegativeScaling = ((scaling[0] < 0.0) ^ (scaling[1] < 0.0) ^ (scaling[2] < 0.0)) ? true : false; + m_bIsNegativeScaling = ((scaling[0] < 0.0f) ^ (scaling[1] < 0.0f) ^ (scaling[2] < 0.0f)) ? true : false; trans.scale(scaling[0], scaling[1], scaling[2]); trans.getValue(fl); GetSGNode()->ClearDirty(); @@ -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; @@ -1214,12 +1214,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) { case 0: //x axis ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis - if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector parallel to the pivot? + if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) //is the vector parallel to the pivot? ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot! if (fac == 1.0f) { x = vect; } else { - x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1.0f - fac)); + x = (vect * fac) + ((orimat * MT_Vector3(1.0f, 0.0f, 0.0f)) * (1.0f - fac)); len = x.length(); if (MT_fuzzyZero(len)) x = vect; else x /= len; @@ -1229,12 +1229,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) break; case 1: //y axis ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]); - if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) + if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); if (fac == 1.0f) { y = vect; } else { - y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1.0f - fac)); + y = (vect * fac) + ((orimat * MT_Vector3(0.0f, 1.0f, 0.0f)) * (1.0f - fac)); len = y.length(); if (MT_fuzzyZero(len)) y = vect; else y /= len; @@ -1244,12 +1244,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) break; case 2: //z axis ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); - if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) + if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]); if (fac == 1.0f) { z = vect; } else { - z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1.0f - fac)); + z = (vect * fac) + ((orimat * MT_Vector3(0.0f, 0.0f, 1.0f)) * (1.0f - fac)); len = z.length(); if (MT_fuzzyZero(len)) z = vect; else z /= len; @@ -1284,12 +1284,12 @@ MT_Scalar KX_GameObject::GetMass() { return m_pPhysicsController->GetMass(); } - return 0.0; + return 0.0f; } MT_Vector3 KX_GameObject::GetLocalInertia() { - MT_Vector3 local_inertia(0.0,0.0,0.0); + MT_Vector3 local_inertia(0.0f,0.0f,0.0f); if (m_pPhysicsController) { local_inertia = m_pPhysicsController->GetLocalInertia(); @@ -1299,7 +1299,7 @@ MT_Vector3 KX_GameObject::GetLocalInertia() MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { - MT_Vector3 velocity(0.0,0.0,0.0), locvel; + MT_Vector3 velocity(0.0f,0.0f,0.0f), locvel; MT_Matrix3x3 ori; if (m_pPhysicsController) { @@ -1318,7 +1318,7 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) { - MT_Vector3 velocity(0.0,0.0,0.0), locvel; + MT_Vector3 velocity(0.0f,0.0f,0.0f), locvel; MT_Matrix3x3 ori; if (m_pPhysicsController) { @@ -1341,7 +1341,7 @@ MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point) { return m_pPhysicsController->GetVelocity(point); } - return MT_Vector3(0.0,0.0,0.0); + return MT_Vector3(0.0f,0.0f,0.0f); } // scenegraph node stuff @@ -1468,9 +1468,9 @@ void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans) { return; } - scale[0] = 1.0/scale[0]; - scale[1] = 1.0/scale[1]; - scale[2] = 1.0/scale[2]; + scale[0] = 1.0f/scale[0]; + scale[1] = 1.0f/scale[1]; + scale[2] = 1.0f/scale[2]; MT_Matrix3x3 invori = parent->GetWorldOrientation().inverse(); MT_Vector3 newpos = invori*(trans-parent->GetWorldPosition())*scale; NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); @@ -2421,7 +2421,7 @@ PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF CValue *life = self->GetProperty("::timebomb"); if (life) - // this convert the timebomb seconds to frames, hard coded 50.0 (assuming 50fps) + // this convert the timebomb seconds to frames, hard coded 50.0f (assuming 50fps) // value hardcoded in KX_Scene::AddReplicaObject() return PyFloat_FromDouble(life->GetNumber() * 50.0); else @@ -2432,7 +2432,7 @@ PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); - return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0); + return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0f); } int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -2440,7 +2440,7 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -2476,7 +2476,7 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -2499,7 +2499,7 @@ int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -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; @@ -2976,7 +2976,7 @@ PyObject *KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUT if (self->GetSGNode() && (sg_parent = self->GetSGNode()->GetSGParent()) != NULL && sg_parent->IsSlowParent()) { return PyFloat_FromDouble(static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->GetTimeOffset()); } else { - return PyFloat_FromDouble(0.0); + return PyFloat_FromDouble(0.0f); } } @@ -2986,7 +2986,7 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF if (self->GetSGNode()) { MT_Scalar val = PyFloat_AsDouble(value); SG_Node *sg_parent= self->GetSGNode()->GetSGParent(); - if (val < 0.0) { /* also accounts for non float */ + if (val < 0.0f) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above"); return PY_SET_ATTR_FAIL; } @@ -3366,7 +3366,7 @@ PyObject *KX_GameObject::PySetOcclusion(PyObject *args) PyObject *KX_GameObject::PyGetVelocity(PyObject *args) { // only can get the velocity if we have a physics object connected to us... - MT_Point3 point(0.0,0.0,0.0); + MT_Point3 point(0.0f,0.0f,0.0f); PyObject *pypos = NULL; if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point))) @@ -3386,7 +3386,7 @@ PyObject *KX_GameObject::PyGetReactionForce() return PyObjectFrom(dummy_point); #endif - return Py_BuildValue("fff", 0.0, 0.0, 0.0); + return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); } @@ -3619,8 +3619,8 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, if (MT_fuzzyZero(distance)) { //cout << "getVectTo() Error: Null vector!\n"; - locToDir = toDir = MT_Vector3(0.0,0.0,0.0); - distance = 0.0; + locToDir = toDir = MT_Vector3(0.0f,0.0f,0.0f); + distance = 0.0f; } else { toDir.normalize(); locToDir = toDir * NodeGetWorldOrientation(); @@ -3736,8 +3736,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, RayCastData rayData(propName, false, (1 << OB_MAX_COL_MASKS) - 1); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData); - if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback)) + if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { return rayData.m_hitObject->GetProxy(); + } Py_RETURN_NONE; } @@ -3883,8 +3884,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, RayCastData rayData(propName, xray, mask); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData, face, (poly == 2)); - if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback)) - { + if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { PyObject *returnValue = (poly == 2) ? PyTuple_New(5) : (poly) ? PyTuple_New(4) : PyTuple_New(3); if (returnValue) { // unlikely this would ever fail, if it does python sets an error PyTuple_SET_ITEM(returnValue, 0, rayData.m_hitObject->GetProxy()); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index c2c455dab6a..a25f999026c 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_IPOTransform.h b/source/gameengine/Ketsji/KX_IPOTransform.h index a68292bf9df..a81c432b01e 100644 --- a/source/gameengine/Ketsji/KX_IPOTransform.h +++ b/source/gameengine/Ketsji/KX_IPOTransform.h @@ -38,12 +38,12 @@ class KX_IPOTransform { public: KX_IPOTransform() : - m_position(0.0, 0.0, 0.0), - m_eulerAngles(0.0, 0.0, 0.0), - m_scaling(1.0, 1.0, 1.0), - m_deltaPosition(0.0, 0.0, 0.0), - m_deltaEulerAngles(0.0, 0.0, 0.0), - m_deltaScaling(0.0, 0.0, 0.0) + m_position(0.0f, 0.0f, 0.0f), + m_eulerAngles(0.0f, 0.0f, 0.0f), + m_scaling(1.0f, 1.0f, 1.0f), + m_deltaPosition(0.0f, 0.0f, 0.0f), + m_deltaEulerAngles(0.0f, 0.0f, 0.0f), + m_deltaScaling(0.0f, 0.0f, 0.0f) {} MT_Transform GetTransform() const { @@ -69,9 +69,9 @@ public: void SetScaling(const MT_Vector3& scaling) { m_scaling = scaling; } void ClearDeltaStuff() { - m_deltaPosition.setValue(0.0, 0.0, 0.0); - m_deltaEulerAngles.setValue(0.0, 0.0, 0.0); - m_deltaScaling.setValue(0.0, 0.0, 0.0); + m_deltaPosition.setValue(0.0f, 0.0f, 0.0f); + m_deltaEulerAngles.setValue(0.0f, 0.0f, 0.0f); + m_deltaScaling.setValue(0.0f, 0.0f, 0.0f); } protected: diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 5f36a980a53..cb44758c46d 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -128,6 +128,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_bInitialized(false), m_activecam(0), m_bFixedTime(false), + m_useExternalClock(false), m_firstframe(true), @@ -135,17 +136,19 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_clockTime(0.f), m_previousClockTime(0.f), m_previousAnimTime(0.f), + m_timescale(1.0f), + m_previousRealTime(0.0f), m_exitcode(KX_EXIT_REQUEST_NO_REQUEST), m_exitstring(""), - m_cameraZoom(1.0), + m_cameraZoom(1.0f), m_overrideCam(false), m_overrideCamUseOrtho(false), - m_overrideCamNear(0.0), - m_overrideCamFar(0.0), + m_overrideCamNear(0.0f), + m_overrideCamFar(0.0f), m_overrideCamZoom(1.0f), m_stereo(false), @@ -167,9 +170,9 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_hideCursor(false), m_overrideFrameColor(false), - m_overrideFrameColorR(0.0), - m_overrideFrameColorG(0.0), - m_overrideFrameColorB(0.0), + m_overrideFrameColorR(0.0f), + m_overrideFrameColorG(0.0f), + m_overrideFrameColorB(0.0f), m_usedome(false) { @@ -411,6 +414,7 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo) m_clockTime = m_kxsystem->GetTimeInSeconds(); m_frameTime = m_kxsystem->GetTimeInSeconds(); m_previousClockTime = m_kxsystem->GetTimeInSeconds(); + m_previousRealTime = m_kxsystem->GetTimeInSeconds(); m_firstframe = true; m_bInitialized = true; @@ -525,8 +529,8 @@ void KX_KetsjiEngine::EndFrame() for (int i = tc_first; i < tc_numCategories; ++i) { double time = m_logger->GetAverage((KX_TimeCategory)i); PyObject *val = PyTuple_New(2); - PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.f)); - PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.f)); + PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.0)); + PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.0)); PyDict_SetItemString(m_pyprofiledict, m_profileLabels[i], val); Py_DECREF(val); @@ -554,7 +558,7 @@ void KX_KetsjiEngine::EndFrame() bool KX_KetsjiEngine::NextFrame() { - double timestep = 1.0/m_ticrate; + double timestep = m_timescale / m_ticrate; double framestep = timestep; // static hidden::Clock sClock; @@ -563,32 +567,61 @@ bool KX_KetsjiEngine::NextFrame() //float dt = sClock.getTimeMicroseconds() * 0.000001f; //sClock.reset(); - if (m_bFixedTime) { - m_clockTime += timestep; - } - else { - // m_clockTime += dt; - m_clockTime = m_kxsystem->GetTimeInSeconds(); + /* + * Clock advancement. There is basically three case: + * - m_useExternalClock is true, the user is responsible to advance the time + * manually using setClockTime, so here, we do not do anything. + * - m_useExternalClock is false, m_bFixedTime is true, we advance for one + * timestep, which already handle the time scaling parameter + * - m_useExternalClock is false, m_bFixedTime is false, we consider how much + * time has elapsed since last call and we scale this time by the time + * scaling parameter. If m_timescale is 1.0 (default value), the clock + * corresponds to the computer clock. + * + * Once clockTime has been computed, we will compute how many logic frames + * will be executed before the next rendering phase (which will occur at "clockTime"). + * The game time elapsing between two logic frames (called framestep) + * depends on several variables: + * - ticrate + * - max_physic_frame + * - max_logic_frame + * XXX The logic over computation framestep is definitively not clear (and + * I'm not even sure it is correct). If needed frame is strictly greater + * than max_physics_frame, we are doing a jump in game time, but keeping + * framestep = 1 / ticrate, while if frames is greater than + * max_logic_frame, we increase framestep. + * + * XXX render.fps is not considred anywhere. + */ + if (!m_useExternalClock) { + if (m_bFixedTime) { + m_clockTime += timestep; + } + else { + double current_time = m_kxsystem->GetTimeInSeconds(); + double dt = current_time - m_previousRealTime; + m_previousRealTime = current_time; + // m_clockTime += dt; + m_clockTime += dt * m_timescale; + } } double deltatime = m_clockTime - m_frameTime; - if (deltatime<0.f) + if (deltatime<0.0) { // We got here too quickly, which means there is nothing todo, just return and don't render. // Not sure if this is the best fix, but it seems to stop the jumping framerate issue (#33088) return false; } - // Compute the number of logic frames to do each update (fixed tic bricks) - int frames =int(deltatime*m_ticrate+1e-6); + int frames = int(deltatime * m_ticrate / m_timescale + 1e-6); // if (frames>1) // printf("****************************************"); // printf("dt = %f, deltatime = %f, frames = %d\n",dt, deltatime,frames); // if (!frames) // PIL_sleep_ms(1); - KX_SceneList::iterator sceneit; if (frames>m_maxPhysicsFrame) @@ -1346,8 +1379,8 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) activecam->NodeSetLocalOrientation(camtrans.getBasis()); activecam->NodeUpdateGS(0); } else { - activecam->NodeSetLocalPosition(MT_Point3(0.0, 0.0, 0.0)); - activecam->NodeSetLocalOrientation(MT_Vector3(0.0, 0.0, 0.0)); + activecam->NodeSetLocalPosition(MT_Point3(0.0f, 0.0f, 0.0f)); + activecam->NodeSetLocalOrientation(MT_Vector3(0.0f, 0.0f, 0.0f)); activecam->NodeUpdateGS(0); } @@ -1412,7 +1445,7 @@ void KX_KetsjiEngine::RenderDebugProperties() m_canvas->GetWidth() /* RdV, TODO ?? */, m_canvas->GetHeight() /* RdV, TODO ?? */); - debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.f, 1.0/tottime); + debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.0f, 1.0f/tottime); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent + profile_indent, @@ -1435,14 +1468,14 @@ void KX_KetsjiEngine::RenderDebugProperties() double time = m_logger->GetAverage((KX_TimeCategory)j); - debugtxt.Format("%5.2fms | %d%%", time*1000.f, (int)(time/tottime * 100.f)); + debugtxt.Format("%5.2fms | %d%%", (float)time*1000.f, (int)((float)time/tottime * 100.f)); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent + profile_indent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); - m_rasterizer->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime); + m_rasterizer->RenderBox2D(xcoord + (int)(2.2f * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), (float)time/tottime); ycoord += const_ysize; } } @@ -1756,6 +1789,10 @@ void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime) m_bFixedTime = bUseFixedTime; } +void KX_KetsjiEngine::SetUseExternalClock(bool useExternalClock) +{ + m_useExternalClock = useExternalClock; +} void KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame) { @@ -1783,6 +1820,11 @@ bool KX_KetsjiEngine::GetUseFixedTime(void) const return m_bFixedTime; } +bool KX_KetsjiEngine::GetUseExternalClock(void) const +{ + return m_useExternalClock; +} + double KX_KetsjiEngine::GetSuspendedDelta() { return m_suspendeddelta; @@ -1798,6 +1840,16 @@ void KX_KetsjiEngine::SetTicRate(double ticrate) m_ticrate = ticrate; } +double KX_KetsjiEngine::GetTimeScale() const +{ + return m_timescale; +} + +void KX_KetsjiEngine::SetTimeScale(double timescale) +{ + m_timescale = timescale; +} + int KX_KetsjiEngine::GetMaxLogicFrame() { return m_maxLogicFrame; @@ -1838,6 +1890,11 @@ double KX_KetsjiEngine::GetClockTime(void) const return m_clockTime; } +void KX_KetsjiEngine::SetClockTime(double externalClockTime) +{ + m_clockTime = externalClockTime; +} + double KX_KetsjiEngine::GetFrameTime(void) const { return m_frameTime; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index ec855be3212..3b8cec2ac82 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -103,16 +103,19 @@ private: bool m_bInitialized; int m_activecam; bool m_bFixedTime; + bool m_useExternalClock; bool m_firstframe; int m_currentFrame; - double m_frameTime;//discrete timestamp of the 'game logic frame' - double m_clockTime;//current time - double m_previousClockTime;//previous clock time - double m_previousAnimTime; //the last time animations were updated + double m_frameTime; // current logic game time + double m_clockTime; // game time for the next rendering step + double m_previousClockTime; // game time of the previous rendering step + double m_previousAnimTime; //game time when the animations were last updated double m_remainingTime; + double m_timescale; // time scaling parameter. if > 1.0, time goes faster than real-time. If < 1.0, times goes slower than real-time. + double m_previousRealTime; static int m_maxLogicFrame; /* maximum number of consecutive logic frame */ static int m_maxPhysicsFrame; /* maximum number of consecutive physics frame */ @@ -297,15 +300,37 @@ public: bool GetUseFixedTime(void) const; /** - * Returns current render frame clock time + * Sets if the BGE relies on a external clock or its own internal clock + */ + void SetUseExternalClock(bool bUseExternalClock); + + /** + * Returns if we rely on an external clock + * \return Current setting + */ + bool GetUseExternalClock(void) const; + + /** + * Returns next render frame game time */ double GetClockTime(void) const; + + /** + * Set the next render frame game time. It will impact also frame time, as + * this one is derived from clocktime + */ + void SetClockTime(double externalClockTime); + /** - * Returns current logic frame clock time + * Returns current logic frame game time */ double GetFrameTime(void) const; + /** + * Returns the real (system) time + */ double GetRealTime(void) const; + /** * Returns the difference between the local time of the scene (when it * was running and not suspended) and the "curtime" @@ -361,6 +386,16 @@ public: */ static double GetAverageFrameRate(); + /** + * Gets the time scale multiplier + */ + double GetTimeScale() const; + + /** + * Sets the time scale multiplier + */ + void SetTimeScale(double scale); + static void SetExitKey(short key); static short GetExitKey(); diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 0dec5715588..b681f10804a 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -231,8 +231,8 @@ int KX_LightObject::pyattr_set_distance(void *self_v, const KX_PYATTRIBUTE_DEF * if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); - if (val < 0.01) - val = 0.01; + if (val < 0.01f) + val = 0.01f; else if (val > 5000.f) val = 5000.f; @@ -326,13 +326,13 @@ int KX_LightObject::pyattr_set_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF * KX_LightObject* self = static_cast<KX_LightObject*>(self_v); if (PyFloat_Check(value)) { - float val = PyFloat_AsDouble(value); - if (val < 0.f) - val = 0.f; - else if (val > 180.f) - val = 180.f; + double val = PyFloat_AsDouble(value); + if (val < 0.0) + val = 0.0; + else if (val > 180.0) + val = 180.0; - self->m_lightobj->m_spotsize = DEG2RAD(val); + self->m_lightobj->m_spotsize = (float)DEG2RAD(val); return PY_SET_ATTR_SUCCESS; } @@ -350,7 +350,7 @@ int KX_LightObject::pyattr_set_spotblend(void *self_v, const KX_PYATTRIBUTE_DEF KX_LightObject* self = static_cast<KX_LightObject*>(self_v); if (PyFloat_Check(value)) { - float val = PyFloat_AsDouble(value); + float val = (float)PyFloat_AsDouble(value); if (val < 0.f) val = 0.f; else if (val > 1.f) diff --git a/source/gameengine/Ketsji/KX_MouseActuator.cpp b/source/gameengine/Ketsji/KX_MouseActuator.cpp index 154ad1da3a1..6aa0d588b50 100644 --- a/source/gameengine/Ketsji/KX_MouseActuator.cpp +++ b/source/gameengine/Ketsji/KX_MouseActuator.cpp @@ -125,8 +125,8 @@ bool KX_MouseActuator::Update() float position[2]; float movement[2]; MT_Vector3 rotation; - float setposition[2] = {0.0}; - float center_x = 0.5, center_y = 0.5; + float setposition[2] = {0.0f}; + float center_x = 0.5f, center_y = 0.5f; getMousePosition(position); @@ -135,14 +135,14 @@ bool KX_MouseActuator::Update() //preventing undesired drifting when resolution is odd if ((m_canvas->GetWidth() % 2) != 0) { - center_x = ((m_canvas->GetWidth() - 1.0) / 2.0) / (m_canvas->GetWidth()); + center_x = ((m_canvas->GetWidth() - 1.0f) / 2.0f) / (m_canvas->GetWidth()); } if ((m_canvas->GetHeight() % 2) != 0) { - center_y = ((m_canvas->GetHeight() - 1.0) / 2.0) / (m_canvas->GetHeight()); + center_y = ((m_canvas->GetHeight() - 1.0f) / 2.0f) / (m_canvas->GetHeight()); } //preventing initial skipping. - if ((m_oldposition[0] <= -0.9) && (m_oldposition[1] <= -0.9)) { + if ((m_oldposition[0] <= -0.9f) && (m_oldposition[1] <= -0.9f)) { if (m_reset_x) { m_oldposition[0] = center_x; @@ -173,21 +173,21 @@ bool KX_MouseActuator::Update() movement[0] -= m_oldposition[0]; } - movement[0] *= -1.0; + movement[0] *= -1.0f; /* Don't apply the rotation when we are under a certain threshold for mouse movement */ - if (((movement[0] > (m_threshold[0] / 10.0)) || - ((movement[0] * (-1.0)) > (m_threshold[0] / 10.0)))) { + if (((movement[0] > (m_threshold[0] / 10.0f)) || + ((movement[0] * (-1.0f)) > (m_threshold[0] / 10.0f)))) { movement[0] *= m_sensitivity[0]; - if ((m_limit_x[0] != 0.0) && ((m_angle[0] + movement[0]) <= m_limit_x[0])) { + if ((m_limit_x[0] != 0.0f) && ((m_angle[0] + movement[0]) <= m_limit_x[0])) { movement[0] = m_limit_x[0] - m_angle[0]; } - if ((m_limit_x[1] != 0.0) && ((m_angle[0] + movement[0]) >= m_limit_x[1])) { + if ((m_limit_x[1] != 0.0f) && ((m_angle[0] + movement[0]) >= m_limit_x[1])) { movement[0] = m_limit_x[1] - m_angle[0]; } @@ -196,17 +196,17 @@ bool KX_MouseActuator::Update() switch (m_object_axis[0]) { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(movement[0], 0.0, 0.0); + rotation = MT_Vector3(movement[0], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, movement[0], 0.0); + rotation = MT_Vector3(0.0f, movement[0], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, movement[0]); + rotation = MT_Vector3(0.0f, 0.0f, movement[0]); break; } default: @@ -231,21 +231,21 @@ bool KX_MouseActuator::Update() movement[1] -= m_oldposition[1]; } - movement[1] *= -1.0; + movement[1] *= -1.0f; /* Don't apply the rotation when we are under a certain threshold for mouse movement */ - if (((movement[1] > (m_threshold[1] / 10.0)) || - ((movement[1] * (-1.0)) > (m_threshold[1] / 10.0)))) { + if (((movement[1] > (m_threshold[1] / 10.0f)) || + ((movement[1] * (-1.0f)) > (m_threshold[1] / 10.0f)))) { movement[1] *= m_sensitivity[1]; - if ((m_limit_y[0] != 0.0) && ((m_angle[1] + movement[1]) <= m_limit_y[0])) { + if ((m_limit_y[0] != 0.0f) && ((m_angle[1] + movement[1]) <= m_limit_y[0])) { movement[1] = m_limit_y[0] - m_angle[1]; } - if ((m_limit_y[1] != 0.0) && ((m_angle[1] + movement[1]) >= m_limit_y[1])) { + if ((m_limit_y[1] != 0.0f) && ((m_angle[1] + movement[1]) >= m_limit_y[1])) { movement[1] = m_limit_y[1] - m_angle[1]; } @@ -255,17 +255,17 @@ bool KX_MouseActuator::Update() { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(movement[1], 0.0, 0.0); + rotation = MT_Vector3(movement[1], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, movement[1], 0.0); + rotation = MT_Vector3(0.0f, movement[1], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, movement[1]); + rotation = MT_Vector3(0.0f, 0.0f, movement[1]); break; } default: @@ -377,7 +377,7 @@ PyAttributeDef KX_MouseActuator::Attributes[] = { KX_PYATTRIBUTE_BOOL_RW("visible", KX_MouseActuator, m_visible), KX_PYATTRIBUTE_BOOL_RW("use_axis_x", KX_MouseActuator, m_use_axis_x), KX_PYATTRIBUTE_BOOL_RW("use_axis_y", KX_MouseActuator, m_use_axis_y), - KX_PYATTRIBUTE_FLOAT_ARRAY_RW("threshold", 0.0, 0.5, KX_MouseActuator, m_threshold, 2), + KX_PYATTRIBUTE_FLOAT_ARRAY_RW("threshold", 0.0f, 0.5f, KX_MouseActuator, m_threshold, 2), KX_PYATTRIBUTE_BOOL_RW("reset_x", KX_MouseActuator, m_reset_x), KX_PYATTRIBUTE_BOOL_RW("reset_y", KX_MouseActuator, m_reset_y), KX_PYATTRIBUTE_INT_ARRAY_RW("object_axis", 0, 2, 1, KX_MouseActuator, m_object_axis, 2), @@ -393,7 +393,7 @@ PyAttributeDef KX_MouseActuator::Attributes[] = { PyObject* KX_MouseActuator::pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v); - return Py_BuildValue("[f,f]", (self->m_limit_x[0] / M_PI * 180.0), (self->m_limit_x[1] / M_PI * 180.0)); + return Py_BuildValue("[f,f]", (self->m_limit_x[0] / (float)M_PI * 180.0f), (self->m_limit_x[1] / (float)M_PI * 180.0f)); } int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -414,8 +414,8 @@ int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_FAIL; } else { - self->m_limit_x[0] = (PyFloat_AsDouble(item1) * M_PI / 180.0); - self->m_limit_x[1] = (PyFloat_AsDouble(item2) * M_PI / 180.0); + self->m_limit_x[0] = (float)((PyFloat_AsDouble(item1) * M_PI) / 180.0f); + self->m_limit_x[1] = (float)((PyFloat_AsDouble(item2) * M_PI) / 180.0f); } return PY_SET_ATTR_SUCCESS; @@ -424,7 +424,7 @@ int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF PyObject* KX_MouseActuator::pyattr_get_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v); - return Py_BuildValue("[f,f]", (self->m_limit_y[0] / M_PI * 180.0), (self->m_limit_y[1] / M_PI * 180.0)); + return Py_BuildValue("[f,f]", (self->m_limit_y[0] / (float)M_PI * 180.0f), (self->m_limit_y[1] / (float)M_PI * 180.0f)); } int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -445,8 +445,8 @@ int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_FAIL; } else { - self->m_limit_y[0] = (PyFloat_AsDouble(item1) * M_PI / 180.0); - self->m_limit_y[1] = (PyFloat_AsDouble(item2) * M_PI / 180.0); + self->m_limit_y[0] = (float)((PyFloat_AsDouble(item1) * M_PI) / 180.0f); + self->m_limit_y[1] = (float)((PyFloat_AsDouble(item2) * M_PI) / 180.0f); } return PY_SET_ATTR_SUCCESS; @@ -455,7 +455,7 @@ int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF PyObject* KX_MouseActuator::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v); - return Py_BuildValue("[f,f]", (self->m_angle[0] / M_PI * 180.0), (self->m_angle[1] / M_PI * 180.0)); + return Py_BuildValue("[f,f]", (self->m_angle[0] / (float)M_PI * 180.0f), (self->m_angle[1] / (float)M_PI * 180.0f)); } int KX_MouseActuator::pyattr_set_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -476,8 +476,8 @@ int KX_MouseActuator::pyattr_set_angle(void *self_v, const KX_PYATTRIBUTE_DEF *a return PY_SET_ATTR_FAIL; } else { - self->m_angle[0] = (PyFloat_AsDouble(item1) * M_PI / 180.0); - self->m_angle[1] = (PyFloat_AsDouble(item2) * M_PI / 180.0); + self->m_angle[0] = ((float)(PyFloat_AsDouble(item1) * M_PI) / 180.0f); + self->m_angle[1] = ((float)(PyFloat_AsDouble(item2) * M_PI) / 180.0f); } return PY_SET_ATTR_SUCCESS; @@ -491,17 +491,17 @@ PyObject* KX_MouseActuator::PyReset() switch (m_object_axis[0]) { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(-1.0 * m_angle[0], 0.0, 0.0); + rotation = MT_Vector3(-1.0f * m_angle[0], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, -1.0 * m_angle[0], 0.0); + rotation = MT_Vector3(0.0f, -1.0f * m_angle[0], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, -1.0 * m_angle[0]); + rotation = MT_Vector3(0.0f, 0.0f, -1.0f * m_angle[0]); break; } default: @@ -512,17 +512,17 @@ PyObject* KX_MouseActuator::PyReset() switch (m_object_axis[1]) { case KX_ACT_MOUSE_OBJECT_AXIS_X: { - rotation = MT_Vector3(-1.0 * m_angle[1], 0.0, 0.0); + rotation = MT_Vector3(-1.0f * m_angle[1], 0.0f, 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Y: { - rotation = MT_Vector3(0.0, -1.0 * m_angle[1], 0.0); + rotation = MT_Vector3(0.0f, -1.0f * m_angle[1], 0.0f); break; } case KX_ACT_MOUSE_OBJECT_AXIS_Z: { - rotation = MT_Vector3(0.0, 0.0, -1.0 * m_angle[1]); + rotation = MT_Vector3(0.0f, 0.0f, -1.0f * m_angle[1]); break; } default: @@ -530,8 +530,8 @@ PyObject* KX_MouseActuator::PyReset() } parent->ApplyRotation(rotation, m_local_y); - m_angle[0] = 0.0; - m_angle[1] = 0.0; + m_angle[0] = 0.0f; + m_angle[1] = 0.0f; Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index db2cb1fdcfd..451078d4a36 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -314,15 +314,15 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) * The actual z coordinates used don't have to be exact just infront and * behind of the near and far clip planes. */ - frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0, - 1.0 - (2 * (m_y_inv - y_lb) / height), - -1.0, - 1.0 ); + frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0f, + 1.0f - (2 * (m_y_inv - y_lb) / height), + -1.0f, + 1.0f ); - topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0, - 1.0 - (2 * (m_y_inv-y_lb) / height), - 1.0, - 1.0 ); + topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0f, + 1.0f - (2 * (m_y_inv-y_lb) / height), + 1.0f, + 1.0f ); /* camera to world */ MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld()); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 762148d8f76..87c2592ecfd 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -65,12 +65,12 @@ KX_ObjectActuator( m_drot(drot), m_linear_velocity(linV), m_angular_velocity(angV), - m_linear_length2(0.0), - m_current_linear_factor(0.0), - m_current_angular_factor(0.0), + m_linear_length2(0.0f), + m_current_linear_factor(0.0f), + m_current_angular_factor(0.0f), m_damping(damping), - m_previous_error(0.0,0.0,0.0), - m_error_accumulator(0.0,0.0,0.0), + m_previous_error(0.0f,0.0f,0.0f), + m_error_accumulator(0.0f,0.0f,0.0f), m_bitLocalFlag (flag), m_reference(refobj), m_active_combined_velocity (false), @@ -134,13 +134,13 @@ bool KX_ObjectActuator::Update() // Explicitly stop the movement if we're using character motion if (m_bitLocalFlag.CharacterMotion) { - character->SetWalkDirection(MT_Vector3 (0.0, 0.0, 0.0)); + character->SetWalkDirection(MT_Vector3 (0.0f, 0.0f, 0.0f)); } m_linear_damping_active = false; m_angular_damping_active = false; - m_error_accumulator.setValue(0.0,0.0,0.0); - m_previous_error.setValue(0.0,0.0,0.0); + m_error_accumulator.setValue(0.0f,0.0f,0.0f); + m_previous_error.setValue(0.0f,0.0f,0.0f); m_jumping = false; return false; @@ -299,10 +299,10 @@ bool KX_ObjectActuator::Update() m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2; m_linear_damping_active = true; } - if (m_current_linear_factor < 1.0) - m_current_linear_factor += 1.0/m_damping; - if (m_current_linear_factor > 1.0) - m_current_linear_factor = 1.0; + if (m_current_linear_factor < 1.0f) + m_current_linear_factor += 1.0f/m_damping; + if (m_current_linear_factor > 1.0f) + m_current_linear_factor = 1.0f; linV = m_current_linear_factor * m_linear_velocity; parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); } else { @@ -327,10 +327,10 @@ bool KX_ObjectActuator::Update() m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2; m_angular_damping_active = true; } - if (m_current_angular_factor < 1.0) - m_current_angular_factor += 1.0/m_damping; - if (m_current_angular_factor > 1.0) - m_current_angular_factor = 1.0; + if (m_current_angular_factor < 1.0f) + m_current_angular_factor += 1.0f/m_damping; + if (m_current_angular_factor > 1.0f) + m_current_angular_factor = 1.0f; angV = m_current_angular_factor * m_angular_velocity; parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); } else { diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index b5622d97611..919c6acf03b 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -161,9 +161,9 @@ public: m_bitLocalFlag.ZeroDLoc = MT_fuzzyZero(m_dloc); m_bitLocalFlag.ZeroDRot = MT_fuzzyZero(m_drot); m_bitLocalFlag.ZeroLinearVelocity = MT_fuzzyZero(m_linear_velocity); - m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0 : m_linear_velocity.length2(); + m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0f : m_linear_velocity.length2(); m_bitLocalFlag.ZeroAngularVelocity = MT_fuzzyZero(m_angular_velocity); - m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0 : m_angular_velocity.length2(); + m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0f : m_angular_velocity.length2(); } virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index 456f5f8af3b..239bfde4c98 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -302,7 +302,7 @@ void KX_ObstacleSimulation::DrawObstacles() if (!m_enableVisualization) return; static const MT_Vector3 bluecolor(0,0,1); - static const MT_Vector3 normal(0.0, 0.0, 1.0); + static const MT_Vector3 normal(0.0f, 0.0f, 1.0f); static const int SECTORS_NUM = 32; for (size_t i=0; i<m_obstacles.size(); i++) { @@ -362,7 +362,7 @@ static bool filterObstacle(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM //filter obstacles by position MT_Point3 p = nearestPointToObstacle(activeObst->m_pos, otherObst); - if ( fabs(activeObst->m_pos.z() - p.z()) > levelHeight) + if ( fabsf(activeObst->m_pos.z() - p.z()) > levelHeight) return false; return true; @@ -459,14 +459,14 @@ void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMes { // Calculate sample velocity const float ndir = ((float)iter/(float)m_maxSamples) - aoff; - const float dir = odir+ndir*M_PI*2; + const float dir = odir+ndir*(float)M_PI*2.0f; MT_Vector2 svel; svel.x() = cosf(dir) * vmax; svel.y() = sinf(dir) * vmax; // Find min time of impact and exit amongst all obstacles. float tmin = m_maxToi; - float tmine = 0; + float tmine = 0.0f; for (int i = 0; i < nobs; ++i) { KX_Obstacle* ob = m_obstacles[i]; diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index d2468d0317d..bcaa1e60e92 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -39,12 +39,12 @@ void KX_OrientationInterpolator::Execute(float currentTime) const MT_Vector3 eul(m_ipos[0]->GetValue(currentTime), m_ipos[1]->GetValue(currentTime), m_ipos[2]->GetValue(currentTime)); - MT_Scalar ci = cos(eul[0]); - MT_Scalar cj = cos(eul[1]); - MT_Scalar ch = cos(eul[2]); - MT_Scalar si = sin(eul[0]); - MT_Scalar sj = sin(eul[1]); - MT_Scalar sh = sin(eul[2]); + MT_Scalar ci = cosf(eul[0]); + MT_Scalar cj = cosf(eul[1]); + MT_Scalar ch = cosf(eul[2]); + MT_Scalar si = sinf(eul[0]); + MT_Scalar sj = sinf(eul[1]); + MT_Scalar sh = sinf(eul[2]); MT_Scalar cc = ci*ch; MT_Scalar cs = ci*sh; MT_Scalar sc = si*ch; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 26c6fcaa928..76eb915a30d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -197,8 +197,12 @@ void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radi #ifdef WITH_PYTHON -static PyObject *gp_OrigPythonSysPath= NULL; -static PyObject *gp_OrigPythonSysModules= NULL; + +static struct { + PyObject *path; + PyObject *meta_path; + PyObject *modules; +} gp_sys_backup = {NULL}; /* Macro for building the keyboard translation */ //#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromLong(SCA_IInputDevice::KX_##name)) @@ -548,6 +552,64 @@ static PyObject *gPyGetAverageFrameRate(PyObject *) return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate()); } +static PyObject *gPyGetUseExternalClock(PyObject *) +{ + return PyBool_FromLong(gp_KetsjiEngine->GetUseExternalClock()); +} + +static PyObject *gPySetUseExternalClock(PyObject *, PyObject *args) +{ + bool bUseExternalClock; + + if (!PyArg_ParseTuple(args, "p:setUseExternalClock", &bUseExternalClock)) + return NULL; + + gp_KetsjiEngine->SetUseExternalClock(bUseExternalClock); + Py_RETURN_NONE; +} + +static PyObject *gPyGetClockTime(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetClockTime()); +} + +static PyObject *gPySetClockTime(PyObject *, PyObject *args) +{ + double externalClockTime; + + if (!PyArg_ParseTuple(args, "d:setClockTime", &externalClockTime)) + return NULL; + + gp_KetsjiEngine->SetClockTime(externalClockTime); + Py_RETURN_NONE; +} + +static PyObject *gPyGetFrameTime(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetFrameTime()); +} + +static PyObject *gPyGetRealTime(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetRealTime()); +} + +static PyObject *gPyGetTimeScale(PyObject *) +{ + return PyFloat_FromDouble(gp_KetsjiEngine->GetTimeScale()); +} + +static PyObject *gPySetTimeScale(PyObject *, PyObject *args) +{ + double time_scale; + + if (!PyArg_ParseTuple(args, "d:setTimeScale", &time_scale)) + return NULL; + + gp_KetsjiEngine->SetTimeScale(time_scale); + Py_RETURN_NONE; +} + static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) { char cpath[sizeof(gp_GamePythonPath)]; @@ -647,71 +709,10 @@ static PyObject *pyPrintStats(PyObject *,PyObject *,PyObject *) static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) { -#define pprint(x) std::cout << x << std::endl; - bool count=0; - bool support=0; - pprint("Supported Extensions..."); - pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no.")); - count = 1; - - support= GLEW_ARB_vertex_shader; - pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no.")); - count = 1; - if (support) { - pprint(" ----------Details----------"); - int max=0; - glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max); - pprint(" Max uniform components." << max); - - glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max); - pprint(" Max varying floats." << max); - - glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max); - pprint(" Max vertex texture units." << max); - - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max); - pprint(" Max combined texture units." << max); - pprint(""); - } - - support=GLEW_ARB_fragment_shader; - pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no.")); - count = 1; - if (support) { - pprint(" ----------Details----------"); - int max=0; - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max); - pprint(" Max uniform components." << max); - pprint(""); - } - - support = GLEW_ARB_texture_cube_map; - pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no.")); - count = 1; - if (support) { - pprint(" ----------Details----------"); - int size=0; - glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size); - pprint(" Max cubemap size." << size); - pprint(""); - } - - support = GLEW_ARB_multitexture; - count = 1; - pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); - if (support) { - pprint(" ----------Details----------"); - int units=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); - pprint(" Max texture units available. " << units); - pprint(""); - } - - pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no.")); - count = 1; - - if (!count) - pprint("No extenstions are used in this build"); + if (gp_Rasterizer) + gp_Rasterizer->PrintHardwareInfo(); + else + printf("Warning: no rasterizer detected for PrintGLInfo!\n"); Py_RETURN_NONE; } @@ -908,7 +909,19 @@ static struct PyMethodDef game_methods[] = { {"setAnimRecordFrame", (PyCFunction) gPySetAnimRecordFrame, METH_VARARGS, (const char *)"Sets the current frame number used for animation recording"}, {"getExitKey", (PyCFunction) gPyGetExitKey, METH_NOARGS, (const char *)"Gets the key used to exit the game engine"}, {"setExitKey", (PyCFunction) gPySetExitKey, METH_VARARGS, (const char *)"Sets the key used to exit the game engine"}, + {"getUseExternalClock", (PyCFunction) gPyGetUseExternalClock, METH_NOARGS, (const char *)"Get if we use the time provided by an external clock"}, + {"setUseExternalClock", (PyCFunction) gPySetUseExternalClock, METH_VARARGS, (const char *)"Set if we use the time provided by an external clock"}, + {"getClockTime", (PyCFunction) gPyGetClockTime, METH_NOARGS, (const char *)"Get the last BGE render time. " + "The BGE render time is the simulated time corresponding to the next scene that will be renderered"}, + {"setClockTime", (PyCFunction) gPySetClockTime, METH_VARARGS, (const char *)"Set the BGE render time. " + "The BGE render time is the simulated time corresponding to the next scene that will be rendered"}, + {"getFrameTime", (PyCFunction) gPyGetFrameTime, METH_NOARGS, (const char *)"Get the BGE last frametime. " + "The BGE frame time is the simulated time corresponding to the last call of the logic system"}, + {"getRealTime", (PyCFunction) gPyGetRealTime, METH_NOARGS, (const char *)"Get the real system time. " + "The real-time corresponds to the system time" }, {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"}, + {"getTimeScale", (PyCFunction) gPyGetTimeScale, METH_NOARGS, (const char *)"Get the time multiplier"}, + {"setTimeScale", (PyCFunction) gPySetTimeScale, METH_VARARGS, (const char *)"Set the time multiplier"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine statistics"}, @@ -1898,11 +1911,12 @@ PyMODINIT_FUNC initGameLogicPythonBinding() return m; } -/* Explanation of +/** + * Explanation of * - * - backupPySysObjects() : stores sys.path in gp_OrigPythonSysPath - * - initPySysObjects(main) : initializes the blendfile and library paths - * - restorePySysObjects() : restores sys.path from gp_OrigPythonSysPath + * - backupPySysObjects() : stores sys.path in #gp_sys_backup + * - initPySysObjects(main) : initializes the blendfile and library paths + * - restorePySysObjects() : restores sys.path from #gp_sys_backup * * These exist so the current blend dir "//" can always be used to import modules from. * the reason we need a few functions for this is that python is not only used by the game engine @@ -1919,16 +1933,21 @@ PyMODINIT_FUNC initGameLogicPythonBinding() */ static void backupPySysObjects(void) { - PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ - PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */ + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); + PyObject *sys_mods = PySys_GetObject("modules"); /* paths */ - Py_XDECREF(gp_OrigPythonSysPath); /* just in case its set */ - gp_OrigPythonSysPath = PyList_GetSlice(sys_path, 0, INT_MAX); /* copy the list */ + Py_XDECREF(gp_sys_backup.path); /* just in case its set */ + gp_sys_backup.path = PyList_GetSlice(sys_path, 0, INT_MAX); /* copy the list */ + /* meta_paths */ + Py_XDECREF(gp_sys_backup.meta_path); /* just in case its set */ + gp_sys_backup.meta_path = PyList_GetSlice(sys_meta_path, 0, INT_MAX); /* copy the list */ + /* modules */ - Py_XDECREF(gp_OrigPythonSysModules); /* just in case its set */ - gp_OrigPythonSysModules = PyDict_Copy(sys_mods); /* copy the list */ + Py_XDECREF(gp_sys_backup.modules); /* just in case its set */ + gp_sys_backup.modules = PyDict_Copy(sys_mods); /* copy the dict */ } @@ -1958,15 +1977,17 @@ static void initPySysObjects__append(PyObject *sys_path, const char *filename) } static void initPySysObjects(Main *maggie) { - PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); - if (gp_OrigPythonSysPath==NULL) { + if (gp_sys_backup.path == NULL) { /* backup */ backupPySysObjects(); } else { /* get the original sys path when the BGE started */ - PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath); + PyList_SetSlice(sys_path, 0, INT_MAX, gp_sys_backup.path); + PyList_SetSlice(sys_meta_path, 0, INT_MAX, gp_sys_backup.meta_path); } Library *lib= (Library *)maggie->library.first; @@ -1986,22 +2007,30 @@ static void initPySysObjects(Main *maggie) static void restorePySysObjects(void) { - if (gp_OrigPythonSysPath==NULL) + if (gp_sys_backup.path == NULL) { return; - - PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ - PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */ + } + + /* will never fail */ + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); + PyObject *sys_mods = PySys_GetObject("modules"); /* paths */ - PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath); - Py_DECREF(gp_OrigPythonSysPath); - gp_OrigPythonSysPath= NULL; + PyList_SetSlice(sys_path, 0, INT_MAX, gp_sys_backup.path); + Py_DECREF(gp_sys_backup.path); + gp_sys_backup.path = NULL; + + /* meta_path */ + PyList_SetSlice(sys_meta_path, 0, INT_MAX, gp_sys_backup.meta_path); + Py_DECREF(gp_sys_backup.meta_path); + gp_sys_backup.meta_path = NULL; /* modules */ PyDict_Clear(sys_mods); - PyDict_Update(sys_mods, gp_OrigPythonSysModules); - Py_DECREF(gp_OrigPythonSysModules); - gp_OrigPythonSysModules= NULL; + PyDict_Update(sys_mods, gp_sys_backup.modules); + Py_DECREF(gp_sys_backup.modules); + gp_sys_backup.modules = NULL; // fprintf(stderr, "\nRestore Path: %d ", PyList_GET_SIZE(sys_path)); diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 732bcdc3773..861e3f70296 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -104,42 +104,42 @@ void KX_RadarSensor::SynchronizeTransform() { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_Y_AXIS: // +Y Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_Z_AXIS: // +Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_NEG_X_AXIS: // -X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_NEG_Y_AXIS: // -Y Axis { //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); //trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; case SENS_RADAR_NEG_Z_AXIS: // -Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0)); break; }; default: @@ -154,7 +154,7 @@ void KX_RadarSensor::SynchronizeTransform() m_cone_origin[1] = temp[1]; m_cone_origin[2] = temp[2]; - temp = trans(MT_Point3(0, -m_coneheight/2.0, 0)); + temp = trans(MT_Point3(0, -m_coneheight/2.0f, 0)); m_cone_target[0] = temp[0]; m_cone_target[1] = temp[1]; m_cone_target[2] = temp[2]; diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 333e7b57d67..478019c6304 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -103,11 +103,11 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ // but it would require some change in Bullet. prevpoint = callback.m_hitPoint; /* We add 0.001 of fudge, so that if the margin && radius == 0.0, we don't endless loop. */ - MT_Scalar marg = 0.001 + hit_controller->GetMargin(); + MT_Scalar marg = 0.001f + hit_controller->GetMargin(); marg *= 2.f; /* Calculate the other side of this object */ MT_Scalar h = MT_abs(todir.dot(callback.m_hitNormal)); - if (h <= 0.01) + if (h <= 0.01f) // the normal is almost orthogonal to the ray direction, cannot compute the other side break; marg /= h; diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 96e1cc29de3..a4220424c6f 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -73,7 +73,7 @@ PyMethodDef KX_SCA_DynamicActuator::Methods[] = { PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = { KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation), - KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,FLT_MAX,KX_SCA_DynamicActuator,m_setmass), + KX_PYATTRIBUTE_FLOAT_RW("mass",0.0f,FLT_MAX,KX_SCA_DynamicActuator,m_setmass), { NULL } //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp index 19b9d13087d..5a13cf5440d 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp @@ -89,7 +89,7 @@ UpdateChildCoordinates( { // Get the child's transform, and the bone matrix. MT_Matrix4x4 child_transform ( - MT_Transform(child_pos + MT_Vector3(0.0, armature->GetBoneLength(m_bone), 0.0), + MT_Transform(child_pos + MT_Vector3(0.0f, armature->GetBoneLength(m_bone), 0.0f), child_rotation.scaled( child_scale[0], child_scale[1], @@ -107,7 +107,7 @@ UpdateChildCoordinates( child_w_rotation.setValue(child_transform[0][0], child_transform[0][1], child_transform[0][2], child_transform[1][0], child_transform[1][1], child_transform[1][2], child_transform[2][0], child_transform[2][1], child_transform[2][2]); - child_w_rotation.scale(1.0/child_w_scale[0], 1.0/child_w_scale[1], 1.0/child_w_scale[2]); + child_w_rotation.scale(1.0f/child_w_scale[0], 1.0f/child_w_scale[1], 1.0f/child_w_scale[2]); child_w_pos = MT_Point3(child_transform[0][3], child_transform[1][3], child_transform[2][3]); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 16d1fdd6ea2..9eb9066d56f 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -898,7 +898,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, m_tempObjectList->Add(replica->AddRef()); // this convert the life from frames to sort-of seconds, hard coded 0.02 that assumes we have 50 frames per second // if you change this value, make sure you change it in KX_GameObject::pyattr_get_life property too - CValue *fval = new CFloatValue(lifespan*0.02); + CValue *fval = new CFloatValue(lifespan*0.02f); replica->SetProperty("::timebomb",fval); fval->Release(); } @@ -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, @@ -1588,7 +1588,7 @@ void KX_Scene::LogicBeginFrame(double curtime) if (propval) { - float timeleft = propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate(); + float timeleft = (float)(propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate()); if (timeleft > 0) { @@ -1827,9 +1827,9 @@ void KX_Scene::UpdateObjectActivity(void) * Manhattan distance. */ MT_Point3 obpos = ob->NodeGetWorldPosition(); - if ((fabs(camloc[0] - obpos[0]) > m_activity_box_radius) || - (fabs(camloc[1] - obpos[1]) > m_activity_box_radius) || - (fabs(camloc[2] - obpos[2]) > m_activity_box_radius) ) + if ((fabsf(camloc[0] - obpos[0]) > m_activity_box_radius) || + (fabsf(camloc[1] - obpos[1]) > m_activity_box_radius) || + (fabsf(camloc[2] - obpos[2]) > m_activity_box_radius) ) { ob->Suspend(); } @@ -1843,8 +1843,8 @@ void KX_Scene::UpdateObjectActivity(void) void KX_Scene::SetActivityCullingRadius(float f) { - if (f < 0.5) - f = 0.5; + if (f < 0.5f) + f = 0.5f; m_activity_box_radius = f; } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 046ad25c09c..c43b7be45dc 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -93,7 +93,7 @@ class KX_ObstacleSimulation; #endif /* for ID freeing */ -#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT)) +#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT)) /** * The KX_Scene holds all data for an independent scene. It relates diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index f6f09dd3bda..1c42d65ae75 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -379,7 +379,7 @@ PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_P { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); const char* prop = attrdef->m_name; - float result_value = 0.0; + float result_value = 0.0f; if (!strcmp(prop, "volume_maximum")) { result_value = actuator->m_3d.max_gain; @@ -416,7 +416,7 @@ PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_P PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); - float position = 0.0; + float position = 0.0f; if (actuator->m_handle) position = AUD_Handle_getPosition(actuator->m_handle); @@ -459,7 +459,7 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); const char* prop = attrdef->m_name; - float prop_value = 0.0; + float prop_value = 0.0f; if (!PyArg_Parse(value, "f", &prop_value)) return PY_SET_ATTR_FAIL; @@ -519,7 +519,7 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); - float position = 1.0; + float position = 1.0f; if (!PyArg_Parse(value, "f", &position)) return PY_SET_ATTR_FAIL; @@ -530,7 +530,7 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - float gain = 1.0; + float gain = 1.0f; KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!PyArg_Parse(value, "f", &gain)) return PY_SET_ATTR_FAIL; @@ -544,7 +544,7 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - float pitch = 1.0; + float pitch = 1.0f; KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!PyArg_Parse(value, "f", &pitch)) return PY_SET_ATTR_FAIL; diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp index cd2cd2bae0b..af2a2b30b84 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp +++ b/source/gameengine/Ketsji/KX_SteeringActuator.cpp @@ -169,8 +169,8 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) if (m_posevent && !m_isActive) { - delta = 0; - m_pathUpdateTime = -1; + delta = 0.0; + m_pathUpdateTime = -1.0; m_updateTime = curtime; m_isActive = true; } @@ -191,8 +191,8 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) const MT_Point3& targpos = m_target->NodeGetWorldPosition(); MT_Vector3 vectotarg = targpos - mypos; MT_Vector3 vectotarg2d = vectotarg; - vectotarg2d.z() = 0; - m_steerVec = MT_Vector3(0, 0, 0); + vectotarg2d.z() = 0.0f; + m_steerVec = MT_Vector3(0.0f, 0.0f, 0.0f); bool apply_steerforce = false; bool terminate = true; @@ -220,10 +220,10 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) { terminate = false; - static const MT_Scalar WAYPOINT_RADIUS(0.25); + static const MT_Scalar WAYPOINT_RADIUS(0.25f); if (m_pathUpdateTime<0 || (m_pathUpdatePeriod>=0 && - curtime - m_pathUpdateTime>((double)m_pathUpdatePeriod/1000))) + curtime - m_pathUpdateTime>((double)m_pathUpdatePeriod/1000.0))) { m_pathUpdateTime = curtime; m_pathLen = m_navmesh->FindPath(mypos, targpos, m_path, MAX_PATH_LENGTH); @@ -252,7 +252,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) if (m_enableVisualization) { //debug draw - static const MT_Vector3 PATH_COLOR(1,0,0); + static const MT_Vector3 PATH_COLOR(1.0f,0.0f,0.0f); m_navmesh->DrawPath(m_path, m_pathLen, PATH_COLOR); } } @@ -274,11 +274,11 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) if (m_simulation && m_obstacle /*&& !newvel.fuzzyZero()*/) { if (m_enableVisualization) - KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(1.0, 0.0, 0.0)); + KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(1.0f, 0.0f, 0.0f)); m_simulation->AdjustObstacleVelocity(m_obstacle, m_mode!=KX_STEERING_PATHFOLLOWING ? m_navmesh : NULL, - newvel, m_acceleration*delta, m_turnspeed/180.0f*M_PI*delta); + newvel, m_acceleration*(float)delta, m_turnspeed/(180.0f*(float)(M_PI*delta))); if (m_enableVisualization) - KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(0.0, 1.0, 0.0)); + KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(0.0f, 1.0f, 0.0f)); } HandleActorFace(newvel); diff --git a/source/gameengine/Ketsji/KX_TimeLogger.cpp b/source/gameengine/Ketsji/KX_TimeLogger.cpp index 1a0d3d28d4c..12106245c4d 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.cpp +++ b/source/gameengine/Ketsji/KX_TimeLogger.cpp @@ -109,7 +109,7 @@ double KX_TimeLogger::GetAverage(void) const for (unsigned int i = 1; i < numMeasurements; i++) { avg += m_measurements[i]; } - avg /= (float)numMeasurements - 1; + avg /= (double)numMeasurements - 1.0; } return avg; diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index eb774960d41..7f167652464 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -235,5 +235,12 @@ KX_TouchEventManager::NewCollision::NewCollision(const NewCollision &to_copy) bool KX_TouchEventManager::NewCollision::operator<(const NewCollision &other) const { - return first < other.first || second < other.second || colldata < other.colldata; + //see strict weak ordering: https://support.microsoft.com/en-us/kb/949171 + if (first == other.first) { + if (second == other.second) { + return colldata < other.colldata; + } + return second < other.second; + } + return first < other.first; } diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 3ed8eba759f..74902ab20ee 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -92,12 +92,12 @@ static MT_Matrix3x3 EulToMat3(float eul[3]) MT_Matrix3x3 mat; float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; - ci = cos(eul[0]); - cj = cos(eul[1]); - ch = cos(eul[2]); - si = sin(eul[0]); - sj = sin(eul[1]); - sh = sin(eul[2]); + ci = cosf(eul[0]); + cj = cosf(eul[1]); + ch = cosf(eul[2]); + si = sinf(eul[0]); + sj = sinf(eul[1]); + sh = sinf(eul[2]); cc = ci*ch; cs = ci*sh; sc = si*ch; @@ -131,7 +131,7 @@ static void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3]) else { eul[0] = atan2f(-mat[2][1], mat[1][1]); eul[1] = atan2f(-mat[0][2], cy); - eul[2] = 0.0; + eul[2] = 0.0f; } } @@ -196,8 +196,8 @@ static float basis_cross(int n, int m) static MT_Matrix3x3 vectomat(MT_Vector3 vec, short axis, short upflag, short threedimup) { MT_Matrix3x3 mat; - MT_Vector3 y(MT_Scalar(0.0), MT_Scalar(1.0), MT_Scalar(0.0)); - MT_Vector3 z(MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(1.0)); /* world Z axis is the global up axis */ + MT_Vector3 y(MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f)); + MT_Vector3 z(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f)); /* world Z axis is the global up axis */ MT_Vector3 proj; MT_Vector3 right; MT_Scalar mul; @@ -208,7 +208,7 @@ static MT_Matrix3x3 vectomat(MT_Vector3 vec, short axis, short upflag, short thr /* if 2D doesn't move the up vector */ if (!threedimup){ - vec.setValue(MT_Scalar(vec[0]), MT_Scalar(vec[1]), MT_Scalar(0.0)); + vec.setValue(MT_Scalar(vec[0]), MT_Scalar(vec[1]), MT_Scalar(0.0f)); vec = (vec - z.dot(vec)*z).safe_normalized_vec(z); } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index cd1c9eed91b..40f4c462801 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -198,7 +198,7 @@ PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DE KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); const unsigned char *colp = self->m_vertex->getRGBA(); MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]); - color /= 255.0; + color /= 255.0f; return PyObjectFrom(color); } @@ -321,7 +321,7 @@ int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[0] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); @@ -338,7 +338,7 @@ int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[1] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); @@ -355,7 +355,7 @@ int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[2] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); @@ -372,7 +372,7 @@ int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; - val *= 255.0; + val *= 255.0f; cp[3] = (unsigned char) val; self->m_vertex->SetRGBA(icol); self->m_mesh->SetMeshModified(true); diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript deleted file mode 100644 index d8dfd3d9bca..00000000000 --- a/source/gameengine/Ketsji/SConscript +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Nathan Letwory. -# -# ***** END GPL LICENSE BLOCK ***** - -import sys - -Import ('env') - -sources = env.Glob('*.cpp') -defs = [] -defs += env['BF_GL_DEFINITIONS'] - -incs = [ - '.', - '#intern/container', - '#intern/guardedalloc', - '#intern/string', - '#source/blender', - env['BF_GLEW_INC'], - '#/intern/glew-mx', - '#intern/moto/include', - '#source/blender/blenfont', - '#source/blender/blenkernel', - '#source/blender/blenlib', - '#source/blender/gpu', - '#source/blender/imbuf', - '#source/blender/makesdna', - '#source/blender/makesrna', - '#source/blender/misc', - '#source/blender/python', - '#source/gameengine/BlenderRoutines', - '#source/gameengine/Converter', - '#source/gameengine/Expressions', - '#source/gameengine/GameLogic', - '#source/gameengine/Ketsji', - '#source/gameengine/Network', - '#source/gameengine/Rasterizer', - '#source/gameengine/SceneGraph', - '#extern/recastnavigation/Detour/Include', - '#extern/recastnavigation/Recast/Include', - '#source/blender/editors/include', - # Only for bpy_internal_import.h, be very careful - '#source/blender/python/generic', - # Only for mathutils, be very careful - '#source/blender/python/mathutils', - '#source/gameengine/Ketsji/KXNetwork', - '#source/gameengine/Physics/Dummy', - '#source/gameengine/Physics/common', - '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - ] -incs = ' '.join(incs) - -incs += ' ' + env['BF_BULLET_INC'] -incs += ' ' + env['BF_OPENGL_INC'] -incs += ' ' + env['BF_BOOST_INC'] - -if env['WITH_BF_SDL']: - incs += ' ' + env['BF_SDL_INC'] - defs.append('WITH_SDL') - -if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - defs.append('WITH_PYTHON') - -if env['WITH_BF_AUDASPACE']: - defs += env['BF_AUDASPACE_DEF'] - incs += ' ' + env['BF_AUDASPACE_C_INC'] - incs += ' ' + env['BF_AUDASPACE_PY_INC'] - -if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') - -if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'): - if env['BF_DEBUG']: - defs.append('_DEBUG') # for Python - -if env['WITH_BF_CXX_GUARDEDALLOC']: - defs.append('WITH_CXX_GUARDEDALLOC') - -if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') - incs += ' #source/gameengine/Physics/Bullet' - -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs += ' ' + env['BF_PTHREADS_INC'] - -env.BlenderLib ( 'ge_logic_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320,45], cxx_compileflags=env['BGE_CXXFLAGS']) |