diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-21 11:58:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-21 11:58:38 +0400 |
commit | d599b643b7a1882ea79851e334d7ed133f362bb3 (patch) | |
tree | 4e4640c1b2e7cc82d9db81dbd98a39777dcbce7c /source/gameengine/Ketsji | |
parent | f3ece5a108db0bdbefb4663ef4ebd9a7e039e263 (diff) |
style cleanup: bge, switch statements mostly.
also left bmesh decimator on in previous commit.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/BL_Action.cpp | 44 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Shader.cpp | 80 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Texture.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Dome.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 8 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Light.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_ObjectActuator.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonSeq.cpp | 44 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_RayCast.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SoundActuator.cpp | 17 |
13 files changed, 119 insertions, 109 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index a21c3965be9..5b7a2313f43 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -352,29 +352,27 @@ void BL_Action::Update(float curtime) } // Handle wrap around - if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) - { - switch(m_playmode) - { - case ACT_MODE_PLAY: - // Clamp - m_localtime = m_endframe; - m_done = true; - break; - case ACT_MODE_LOOP: - // Put the time back to the beginning - m_localtime = m_startframe; - m_starttime = curtime; - break; - case ACT_MODE_PING_PONG: - // Swap the start and end frames - float temp = m_startframe; - m_startframe = m_endframe; - m_endframe = temp; - - m_starttime = curtime; - - break; + if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) { + switch (m_playmode) { + case ACT_MODE_PLAY: + // Clamp + m_localtime = m_endframe; + m_done = true; + break; + case ACT_MODE_LOOP: + // Put the time back to the beginning + m_localtime = m_startframe; + m_starttime = curtime; + break; + case ACT_MODE_PING_PONG: + // Swap the start and end frames + float temp = m_startframe; + m_startframe = m_endframe; + m_endframe = temp; + + m_starttime = curtime; + + break; } } diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index e0ad1539b4a..144ad61212d 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -52,51 +52,70 @@ void BL_Uniform::Apply(class BL_Shader *shader) #ifdef SORT_UNIFORMS MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData); - if (!mDirty) + if (!mDirty) return; - switch(mType) - { - case UNI_FLOAT: { + switch (mType) { + case UNI_FLOAT: + { float *f = (float*)mData; glUniform1fARB(mLoc,(GLfloat)*f); - }break; - case UNI_INT: { + break; + } + case UNI_INT: + { int *f = (int*)mData; glUniform1iARB(mLoc, (GLint)*f); - }break; - case UNI_FLOAT2: { + break; + } + case UNI_FLOAT2: + { float *f = (float*)mData; glUniform2fvARB(mLoc,1, (GLfloat*)f); - }break; - case UNI_FLOAT3: { + break; + } + case UNI_FLOAT3: + { float *f = (float*)mData; glUniform3fvARB(mLoc,1,(GLfloat*)f); - }break; - case UNI_FLOAT4: { + break; + } + case UNI_FLOAT4: + { float *f = (float*)mData; glUniform4fvARB(mLoc,1,(GLfloat*)f); - }break; - case UNI_INT2: { + break; + } + case UNI_INT2: + { int *f = (int*)mData; glUniform2ivARB(mLoc,1,(GLint*)f); - }break; - case UNI_INT3: { + break; + } + case UNI_INT3: + { int *f = (int*)mData; glUniform3ivARB(mLoc,1,(GLint*)f); - }break; - case UNI_INT4: { + break; + } + case UNI_INT4: + { int *f = (int*)mData; glUniform4ivARB(mLoc,1,(GLint*)f); - }break; - case UNI_MAT4: { + break; + } + case UNI_MAT4: + { float *f = (float*)mData; glUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); - }break; - case UNI_MAT3: { + break; + } + case UNI_MAT3: + { float *f = (float*)mData; glUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); - }break; + break; + } } mDirty = false; #endif @@ -157,7 +176,7 @@ BL_Shader::~BL_Shader() void BL_Shader::ClearUniforms() { BL_UniformVec::iterator it = mUniforms.begin(); - while(it != mUniforms.end()) { + while (it != mUniforms.end()) { delete (*it); it++; } @@ -165,7 +184,7 @@ void BL_Shader::ClearUniforms() BL_UniformVecDef::iterator itp = mPreDef.begin(); - while(itp != mPreDef.end()) { + while (itp != mPreDef.end()) { delete (*itp); itp++; } @@ -178,7 +197,7 @@ BL_Uniform *BL_Shader::FindUniform(const int location) { #ifdef SORT_UNIFORMS BL_UniformVec::iterator it = mUniforms.begin(); - while(it != mUniforms.end()) { + while (it != mUniforms.end()) { if ((*it)->GetLocation() == location) return (*it); it++; @@ -1134,7 +1153,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list Py_DECREF(item); } - switch(list_size) + switch (list_size) { case 2: { @@ -1218,7 +1237,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 /* Sanity checks done! */ - switch(list_size) + switch (list_size) { case 2: { @@ -1394,15 +1413,14 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" ) { bool defined = false; BL_UniformVecDef::iterator it = mPreDef.begin(); - while(it != mPreDef.end()) { + while (it != mPreDef.end()) { if ((*it)->mLoc == loc) { defined = true; break; } it++; } - if (defined) - { + if (defined) { Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 7196c1ec664..d129fc88714 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -562,7 +562,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) using_alpha = true; } - switch( mat->blend_mode[mUnit] ) { + switch (mat->blend_mode[mUnit]) { case BLEND_MIX: { // ------------------------------ diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 87b0cfc1269..fca407f6398 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -94,7 +94,7 @@ KX_Dome::KX_Dome ( SetViewPort(viewport); - switch(m_mode) { + switch (m_mode) { case DOME_FISHEYE: if (m_angle <= 180) { cubetop.resize(1); @@ -1620,7 +1620,7 @@ void KX_Dome::Draw(void) glScissor(0,0,warp.imagesize, warp.imagesize); } - switch(m_mode) { + switch (m_mode) { case DOME_FISHEYE: DrawDomeFisheye(); break; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6979af10e0a..6c581dae210 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1442,7 +1442,7 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype) #define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller") - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeGetLocalPosition().getValue(bmo->data); break; @@ -1492,7 +1492,7 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype) if (self==NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeSetLocalPosition(MT_Point3(bmo->data)); self->NodeUpdateGS(0.f); @@ -1571,7 +1571,7 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype) if (self==NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_MAT_CB_ORI_LOCAL: self->NodeGetLocalOrientation().getValue3x3(bmo->data); break; @@ -1591,7 +1591,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype) return -1; MT_Matrix3x3 mat3x3; - switch(subtype) { + switch (subtype) { case MATHUTILS_MAT_CB_ORI_LOCAL: mat3x3.setValue3x3(bmo->data); self->NodeSetLocalOrientation(mat3x3); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 479e63a1f24..a85575d4f55 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -334,8 +334,7 @@ void KX_KetsjiEngine::RenderDome() // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if ((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) @@ -889,8 +888,7 @@ void KX_KetsjiEngine::Render() // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if ((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) @@ -939,8 +937,7 @@ void KX_KetsjiEngine::Render() // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if ((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) @@ -1327,8 +1324,7 @@ void KX_KetsjiEngine::RenderFonts(KX_Scene* scene) list<class KX_FontObject*>* fonts = scene->GetFonts(); list<KX_FontObject*>::iterator it = fonts->begin(); - while(it != fonts->end()) - { + while (it != fonts->end()) { (*it)->DrawText(); ++it; } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 0e45684d2d0..13074fca537 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -402,7 +402,7 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr return PY_SET_ATTR_FAIL; } - switch(val) { + switch (val) { case 0: self->m_lightobj.m_type = self->m_lightobj.LIGHT_SPOT; break; diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index ce63d6e2753..0d25cd0ffc1 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -308,8 +308,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus() list<class KX_Camera*>* cameras = m_kxscene->GetCameras(); list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if (((*it) != cam) && (*it)->GetViewport()) if (ParentObjectHasFocusCamera(*it)) return true; diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index f35090f9e9b..c57cb7b55b7 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -402,7 +402,7 @@ static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype) if (self==NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_LINV: self->m_linear_velocity.getValue(bmo->data); break; @@ -420,7 +420,7 @@ static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype) if (self==NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_LINV: self->m_linear_velocity.setValue(bmo->data); break; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 7ec84cfa6b7..3bb657e2b87 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1796,7 +1796,7 @@ static void initPySysObjects(Main *maggie) Library *lib= (Library *)maggie->library.first; - while(lib) { + while (lib) { /* lib->name wont work in some cases (on win32), * even when expanding with gp_GamePythonPath, using lib->filename is less trouble */ initPySysObjects__append(sys_path, lib->filepath); diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index 5ab3de15fb3..6b4d88709e8 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -72,31 +72,31 @@ static void KX_PythonSeq_dealloc(KX_PythonSeq * self) static Py_ssize_t KX_PythonSeq_len( PyObject *self ) { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); - + if (self_plus==NULL) { PyErr_SetString(PyExc_SystemError, "len(seq): "BGE_PROXY_ERROR_MSG); return -1; } - switch(((KX_PythonSeq *)self)->type) { - case KX_PYGENSEQ_CONT_TYPE_SENSORS: - return ((SCA_IController *)self_plus)->GetLinkedSensors().size(); - case KX_PYGENSEQ_CONT_TYPE_ACTUATORS: - return ((SCA_IController *)self_plus)->GetLinkedActuators().size(); - case KX_PYGENSEQ_OB_TYPE_SENSORS: - return ((KX_GameObject *)self_plus)->GetSensors().size(); - case KX_PYGENSEQ_OB_TYPE_CONTROLLERS: - return ((KX_GameObject *)self_plus)->GetControllers().size(); - case KX_PYGENSEQ_OB_TYPE_ACTUATORS: - return ((KX_GameObject *)self_plus)->GetActuators().size(); - case KX_PYGENSEQ_OB_TYPE_CONSTRAINTS: - return ((BL_ArmatureObject *)self_plus)->GetConstraintNumber(); - case KX_PYGENSEQ_OB_TYPE_CHANNELS: - return ((BL_ArmatureObject *)self_plus)->GetChannelNumber(); - default: - /* Should never happen */ - PyErr_SetString(PyExc_SystemError, "invalid type, internal error"); - return -1; + switch (((KX_PythonSeq *)self)->type) { + case KX_PYGENSEQ_CONT_TYPE_SENSORS: + return ((SCA_IController *)self_plus)->GetLinkedSensors().size(); + case KX_PYGENSEQ_CONT_TYPE_ACTUATORS: + return ((SCA_IController *)self_plus)->GetLinkedActuators().size(); + case KX_PYGENSEQ_OB_TYPE_SENSORS: + return ((KX_GameObject *)self_plus)->GetSensors().size(); + case KX_PYGENSEQ_OB_TYPE_CONTROLLERS: + return ((KX_GameObject *)self_plus)->GetControllers().size(); + case KX_PYGENSEQ_OB_TYPE_ACTUATORS: + return ((KX_GameObject *)self_plus)->GetActuators().size(); + case KX_PYGENSEQ_OB_TYPE_CONSTRAINTS: + return ((BL_ArmatureObject *)self_plus)->GetConstraintNumber(); + case KX_PYGENSEQ_OB_TYPE_CHANNELS: + return ((BL_ArmatureObject *)self_plus)->GetChannelNumber(); + default: + /* Should never happen */ + PyErr_SetString(PyExc_SystemError, "invalid type, internal error"); + return -1; } } @@ -109,7 +109,7 @@ static PyObject *KX_PythonSeq_getIndex(PyObject *self, int index) return NULL; } - switch(((KX_PythonSeq *)self)->type) { + switch (((KX_PythonSeq *)self)->type) { case KX_PYGENSEQ_CONT_TYPE_SENSORS: { vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors(); @@ -193,7 +193,7 @@ static PyObjectPlus * KX_PythonSeq_subscript__internal(PyObject *self, const cha { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); - switch(((KX_PythonSeq *)self)->type) { + switch (((KX_PythonSeq *)self)->type) { case KX_PYGENSEQ_CONT_TYPE_SENSORS: { vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors(); diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 459600f2e34..2a6b7d122b5 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -76,9 +76,9 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ PHY_IPhysicsController* hit_controller; - while((hit_controller = physics_environment->rayTest(callback, - frompoint.x(),frompoint.y(),frompoint.z(), - topoint.x(),topoint.y(),topoint.z())) != NULL) + while ((hit_controller = physics_environment->rayTest(callback, + frompoint.x(),frompoint.y(),frompoint.z(), + topoint.x(),topoint.y(),topoint.z())) != NULL) { KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(hit_controller->getNewClientInfo()); diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index c0191db640a..f76f94aa81d 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -325,15 +325,14 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, "startSound()\n" "\tStarts the sound.\n") { - switch(m_handle.isNull() ? AUD_STATUS_INVALID : m_handle->getStatus()) - { - case AUD_STATUS_PLAYING: - break; - case AUD_STATUS_PAUSED: - m_handle->resume(); - break; - default: - play(); + switch (m_handle.isNull() ? AUD_STATUS_INVALID : m_handle->getStatus()) { + case AUD_STATUS_PLAYING: + break; + case AUD_STATUS_PAUSED: + m_handle->resume(); + break; + default: + play(); } Py_RETURN_NONE; } |