diff options
Diffstat (limited to 'source/gameengine/Ketsji')
122 files changed, 1485 insertions, 1485 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 7175eb877dd..43ec3016f51 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -59,10 +59,10 @@ extern "C" { #include "BLI_threads.h" // for lock /* Lock to solve animation thread issues. - * A spin lock is better than a mutex in case of short wait + * A spin lock is better than a mutex in case of short wait * because spin lock stop the thread by a loop contrary to mutex * which switch all memory, process. - */ + */ static SpinLock BL_ActionLock; BL_Action::BL_Action(class KX_GameObject* gameobj) @@ -232,7 +232,7 @@ bool BL_Action::Play(const char* name, m_obj->GetSGNode()->AddSGController(sg_contr); sg_contr->SetObject(m_obj->GetSGNode()); } - + m_ipo_flags = ipo_flags; InitIPO(); @@ -246,7 +246,7 @@ bool BL_Action::Play(const char* name, { BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj; BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer()); - + if (shape_deformer && shape_deformer->GetKey()) { obj->GetShape(m_blendinshape); @@ -270,7 +270,7 @@ bool BL_Action::Play(const char* name, m_blendstart = 0.f; m_speed = playback_speed; m_layer_weight = layer_weight; - + m_done = false; m_initializedTime = false; @@ -314,7 +314,7 @@ const char *BL_Action::GetName() return ""; } - + } void BL_Action::SetFrame(float frame) @@ -324,7 +324,7 @@ void BL_Action::SetFrame(float frame) frame = min(m_startframe, m_endframe); else if (frame > max(m_startframe, m_endframe)) frame = max(m_startframe, m_endframe); - + m_localframe = frame; m_calc_localtime = false; } @@ -363,7 +363,7 @@ void BL_Action::IncrementBlending(float curtime) // Setup m_blendstart if we need to if (m_blendstart == 0.f) m_blendstart = curtime; - + // Bump the blend frame m_blendframe = (curtime - m_blendstart)*(float)KX_KetsjiEngine::GetAnimFrameRate(); @@ -378,10 +378,10 @@ void BL_Action::BlendShape(Key* key, float srcweight, std::vector<float>& blends vector<float>::const_iterator it; float dstweight; KeyBlock *kb; - + dstweight = 1.0F - srcweight; //printf("Dst: %f\tSrc: %f\n", srcweight, dstweight); - for (it=blendshape.begin(), kb = (KeyBlock *)key->block.first; + for (it=blendshape.begin(), kb = (KeyBlock *)key->block.first; kb && it != blendshape.end(); kb = (KeyBlock *)kb->next, it++) { diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h index 69c6d611df0..90fa164853e 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -81,14 +81,14 @@ public: /** * Gets the name of the current action - */ + */ const char *GetActionName(short layer); /** * Sets the current frame of an action */ void SetActionFrame(short layer, float frame); - + /** * Gets the currently running action on the given layer */ diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 9cbd61590b6..afcd6ca3a5c 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -41,7 +41,7 @@ #include "RAS_BucketManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" - + BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer) : mMat(ma), @@ -97,7 +97,7 @@ int BL_BlenderShader::GetAttribNum() for (i = 0; i < attribs.totlayer; i++) if (attribs.layer[i].glindex+1 > enabled) enabled= attribs.layer[i].glindex+1; - + if (enabled > BL_MAX_ATTRIB) enabled = BL_MAX_ATTRIB; @@ -114,7 +114,7 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) if (!VerifyShader()) return; - + gpumat = mGPUMat; if (ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED || (ras->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mat->alphablend != GEMAT_SOLID && !ras->GetUsingOverrideShader())) { diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index e03bb5a11d9..5222369c6b5 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -63,7 +63,7 @@ private: int mAlphaBlend; GPUMaterial *mGPUMat; - bool VerifyShader() + bool VerifyShader() { return (NULL != mGPUMat); } @@ -86,8 +86,8 @@ public: int GetAlphaBlend(); bool Equals(BL_BlenderShader *blshader); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_BlenderShader") #endif diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp index 4f707e6267f..aad49b418fc 100644 --- a/source/gameengine/Ketsji/BL_Material.cpp +++ b/source/gameengine/Ketsji/BL_Material.cpp @@ -108,7 +108,7 @@ void BL_Material::SetSharedMaterial(bool v) { if ((v && num_users == -1) || num_users > 1 ) share = true; - else + else share = false; } diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 9207a41f56d..14f9dfa4665 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -78,7 +78,7 @@ public: int blend_mode[MAXTEX]; int num_enabled; - + BL_Mapping mapping[MAXTEX]; STR_String imageId[MAXTEX]; @@ -93,8 +93,8 @@ public: void SetSharedMaterial(bool v); bool IsShared(); void SetUsers(int num); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Material") #endif diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index d344e18c313..660924e2e67 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -373,7 +373,7 @@ bool BL_Shader::LinkProgram() goto programError; } } - + if (!tmpFrag && !tmpVert) { spit("---- No shader given ----"); goto programError; diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index c3b799b9424..7dac7993b8c 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -56,7 +56,7 @@ extern "C" { void my_free_envmapdata(EnvMap *env); } -// (n&(n-1)) zeros the least significant bit of n +// (n&(n-1)) zeros the least significant bit of n static int is_power_of_2_i(int num) { return ((num)&(num-1))==0; @@ -122,7 +122,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) { ImBuf *ibuf; - if (!img || img->ok==0) + if (!img || img->ok==0) { mOk = false; return mOk; @@ -217,7 +217,7 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect); } IMB_freeImBuf(ibuf); - } + } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -237,7 +237,7 @@ void BL_Texture::InitGLCompressedTex(ImBuf *ibuf, bool mipmap) return; #else glBindTexture(GL_TEXTURE_2D, mTexture); - + if (GPU_upload_dxt_texture(ibuf) == 0) { InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); return; @@ -289,7 +289,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) mOk = false; return mOk; } - else if (!cubemap || cubemap->ima->ok==0) + else if (!cubemap || cubemap->ima->ok==0) { mOk = false; return mOk; @@ -336,7 +336,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) bool needs_split = false; - if (!cubemap->cube[0]) + if (!cubemap->cube[0]) { needs_split = true; spit ("Re-Generating texture buffer"); @@ -407,7 +407,7 @@ void BL_Texture::Validate() bool BL_Texture::Ok() { - return (mTexture!= 0); + return (mTexture!= 0); } @@ -518,14 +518,14 @@ void BL_Texture::SetMapping(int mode) return; } - if ( mType == GL_TEXTURE_CUBE_MAP_ARB && + if ( mType == GL_TEXTURE_CUBE_MAP_ARB && GLEW_ARB_texture_cube_map && - mode &USEREFL) + mode &USEREFL) { glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB ); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB ); glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB ); - + glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); @@ -632,7 +632,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) glTexEnvf( GL_TEXTURE_ENV, op2, alphaOp); }break; - case BLEND_MUL: + case BLEND_MUL: { // ------------------------------ glTexEnvf( GL_TEXTURE_ENV, combiner, GL_MODULATE); @@ -644,7 +644,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) else glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand); }break; - case BLEND_ADD: + case BLEND_ADD: { // ------------------------------ glTexEnvf( GL_TEXTURE_ENV, combiner, GL_ADD_SIGNED_ARB); @@ -656,7 +656,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) else glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand); }break; - case BLEND_SUB: + case BLEND_SUB: { // ------------------------------ glTexEnvf( GL_TEXTURE_ENV, combiner, GL_SUBTRACT_ARB); @@ -665,7 +665,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) glTexEnvf( GL_TEXTURE_ENV, source1, GL_TEXTURE ); glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand); }break; - case BLEND_SCR: + case BLEND_SCR: { // ------------------------------ glTexEnvf( GL_TEXTURE_ENV, combiner, GL_ADD); @@ -708,9 +708,9 @@ extern "C" { void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf) { int dx, part; - + my_free_envmapdata(env); - + dx= ibuf->y; dx/= 2; if (3*dx != ibuf->x) { @@ -722,17 +722,17 @@ void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf) for (part=0; part<6; part++) { env->cube[part] = IMB_allocImBuf(dx, dx, 24, IB_rect); } - IMB_rectcpy(env->cube[0], ibuf, + IMB_rectcpy(env->cube[0], ibuf, 0, 0, 0, 0, dx, dx); - IMB_rectcpy(env->cube[1], ibuf, + IMB_rectcpy(env->cube[1], ibuf, 0, 0, dx, 0, dx, dx); - IMB_rectcpy(env->cube[2], ibuf, + IMB_rectcpy(env->cube[2], ibuf, 0, 0, 2*dx, 0, dx, dx); - IMB_rectcpy(env->cube[3], ibuf, + IMB_rectcpy(env->cube[3], ibuf, 0, 0, 0, dx, dx, dx); - IMB_rectcpy(env->cube[4], ibuf, + IMB_rectcpy(env->cube[4], ibuf, 0, 0, dx, dx, dx, dx); - IMB_rectcpy(env->cube[5], ibuf, + IMB_rectcpy(env->cube[5], ibuf, 0, 0, 2*dx, dx, dx, dx); env->ok= 2;// ENV_OSA @@ -743,7 +743,7 @@ void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf) void my_free_envmapdata(EnvMap *env) { unsigned int part; - + for (part=0; part<6; part++) { ImBuf *ibuf= env->cube[part]; if (ibuf) { diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h index cd18ef93822..b2e17522e40 100644 --- a/source/gameengine/Ketsji/BL_Texture.h +++ b/source/gameengine/Ketsji/BL_Texture.h @@ -28,7 +28,7 @@ private: unsigned int mTexture; // Bound texture unit data bool mOk; // ... bool mNeedsDeleted; // If generated - unsigned int mType; // enum TEXTURE_2D | CUBE_MAP + unsigned int mType; // enum TEXTURE_2D | CUBE_MAP int mUnit; // Texture unit associated with mTexture unsigned int mEnvState; // cache textureEnv static unsigned int mDisableState; // speed up disabling calls diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index 325a7be9bd7..7b00129257a 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -58,8 +58,8 @@ public: virtual bool Update(); virtual CValue* GetReplica(); - virtual void Replace_NetworkScene(NG_NetworkScene *val) - { + virtual void Replace_NetworkScene(NG_NetworkScene *val) + { m_networkscene= val; }; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index a1f0692b7b3..a519ccdab22 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -67,7 +67,7 @@ public: virtual bool IsPositiveTrigger(); virtual void Init(); void EndFrame(); - + virtual void Replace_NetworkScene(NG_NetworkScene *val) { m_NetworkScene= val; diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.h b/source/gameengine/Ketsji/KX_ArmatureSensor.h index b3ea905d198..725d6f208d6 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.h +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.h @@ -52,8 +52,8 @@ public: const char *constraintname, int type, float value); - - /** + + /** * For property sensor, it is used to release the pre-calculated expression * so that self references are removed before the sensor itself is released */ diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index d26e35f8138..80ac8d9693f 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -223,7 +223,7 @@ void KX_BlenderMaterial::InitTextures() else if (!mMaterial->glslmat || mShader) { if ( mMaterial->img[i] ) { if ( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) - spit("unable to initialize image("<<i<<") in "<< + spit("unable to initialize image("<<i<<") in "<< mMaterial->matname<< ", image will not be available"); } } @@ -235,7 +235,7 @@ void KX_BlenderMaterial::OnConstruction() if (mConstructed) // when material are reused between objects return; - + if (mMaterial->glslmat) SetBlenderGLSLShader(); @@ -318,7 +318,7 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) BL_Texture::DisableAllTextures(); mShader->SetProg(true); mLastShader = mShader; - + BL_Texture::ActivateFirst(); mShader->ApplyShader(); @@ -411,7 +411,7 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) setObjectMatrixData(i, ras); else mTextures[i].SetMapping(mode); - + if (!(mode &USEOBJ)) setTexMatrixData( i ); } @@ -430,13 +430,13 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) void KX_BlenderMaterial::ActivatShaders( - RAS_IRasterizer* rasty, + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo)const { KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this); - // reset... - if (tmp->mMaterial->IsShared()) + // reset... + if (tmp->mMaterial->IsShared()) cachingInfo =0; if (mLastBlenderShader) { @@ -448,9 +448,9 @@ KX_BlenderMaterial::ActivatShaders( if (!cachingInfo) tmp->setShaderData(false, rasty); - + cachingInfo = GetCachingInfo(); - + if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) tmp->setShaderData(true, rasty); else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !rasty->GetUsingOverrideShader()) @@ -466,7 +466,7 @@ KX_BlenderMaterial::ActivatShaders( if ((mMaterial->ras_mode &WIRE) || (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) { - if (mMaterial->ras_mode &WIRE) + if (mMaterial->ras_mode &WIRE) rasty->SetCullFace(false); rasty->SetLines(true); } @@ -482,7 +482,7 @@ KX_BlenderMaterial::ActivatShaders( void KX_BlenderMaterial::ActivateBlenderShaders( - RAS_IRasterizer* rasty, + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo)const { KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this); @@ -495,9 +495,9 @@ KX_BlenderMaterial::ActivateBlenderShaders( if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) tmp->setBlenderShaderData(false, rasty); - + cachingInfo = GetCachingInfo(); - + if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) tmp->setBlenderShaderData(true, rasty); else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !rasty->GetUsingOverrideShader()) @@ -513,7 +513,7 @@ KX_BlenderMaterial::ActivateBlenderShaders( if ((mMaterial->ras_mode &WIRE) || (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) { - if (mMaterial->ras_mode &WIRE) + if (mMaterial->ras_mode &WIRE) rasty->SetCullFace(false); rasty->SetLines(true); } @@ -526,8 +526,8 @@ KX_BlenderMaterial::ActivateBlenderShaders( } void -KX_BlenderMaterial::ActivateMat( - RAS_IRasterizer* rasty, +KX_BlenderMaterial::ActivateMat( + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo )const { @@ -544,9 +544,9 @@ KX_BlenderMaterial::ActivateMat( } if (GetCachingInfo() != cachingInfo) { - if (!cachingInfo) + if (!cachingInfo) tmp->setTexData( false,rasty ); - + cachingInfo = GetCachingInfo(); if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) @@ -564,7 +564,7 @@ KX_BlenderMaterial::ActivateMat( if ((mMaterial->ras_mode &WIRE) || (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) { - if (mMaterial->ras_mode &WIRE) + if (mMaterial->ras_mode &WIRE) rasty->SetCullFace(false); rasty->SetLines(true); } @@ -578,9 +578,9 @@ KX_BlenderMaterial::ActivateMat( //ActivateTexGen(rasty); } -bool -KX_BlenderMaterial::Activate( - RAS_IRasterizer* rasty, +bool +KX_BlenderMaterial::Activate( + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo )const { @@ -666,7 +666,7 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const rasty->SetShinyness( mMaterial->hard ); rasty->SetDiffuse( - mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit, + mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit, mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit, mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit, 1.0f); @@ -687,7 +687,7 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const { - if (ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED || + if (ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED || (ras->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !ras->GetUsingOverrideShader())) { ras->SetAttribNum(0); if (mShader && GLEW_ARB_shader_objects) { @@ -713,7 +713,7 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV, i); else if (mode &USETANG) ras->SetTexCoord(RAS_IRasterizer::RAS_TEXTANGENT, i); - else + else ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_DISABLE, i); } } @@ -724,26 +724,26 @@ void KX_BlenderMaterial::setTexMatrixData(int i) glMatrixMode(GL_TEXTURE); glLoadIdentity(); - if ( GLEW_ARB_texture_cube_map && - mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB && + if ( GLEW_ARB_texture_cube_map && + mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB && mMaterial->mapping[i].mapping & USEREFL) { - glScalef( - mMaterial->mapping[i].scale[0], - -mMaterial->mapping[i].scale[1], + glScalef( + mMaterial->mapping[i].scale[0], + -mMaterial->mapping[i].scale[1], -mMaterial->mapping[i].scale[2] ); } else { - glScalef( - mMaterial->mapping[i].scale[0], - mMaterial->mapping[i].scale[1], + glScalef( + mMaterial->mapping[i].scale[0], + mMaterial->mapping[i].scale[1], mMaterial->mapping[i].scale[2] ); } glTranslatef( mMaterial->mapping[i].offsets[0], - mMaterial->mapping[i].offsets[1], + mMaterial->mapping[i].offsets[1], mMaterial->mapping[i].offsets[2] ); @@ -764,7 +764,7 @@ static void GetProjPlane(BL_Material *mat, int index,int num, float*param) void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras) { - KX_GameObject *obj = + KX_GameObject *obj = (KX_GameObject*) mScene->GetObjectList()->FindValue(mMaterial->mapping[i].objconame); @@ -780,7 +780,7 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras) float proj[4] = {0.f,0.f,0.f,0.f}; GetProjPlane(mMaterial, i, 0, proj); glTexGenfv(GL_S, plane, proj); - + GetProjPlane(mMaterial, i, 1, proj); glTexGenfv(GL_T, plane, proj); @@ -795,9 +795,9 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras) glMatrixMode(GL_TEXTURE); glLoadIdentity(); - glScalef( - mMaterial->mapping[i].scale[0], - mMaterial->mapping[i].scale[1], + glScalef( + mMaterial->mapping[i].scale[0], + mMaterial->mapping[i].scale[1], mMaterial->mapping[i].scale[2] ); @@ -968,7 +968,7 @@ void KX_BlenderMaterial_Mathutils_Callback_Init() #ifdef WITH_PYTHON -PyMethodDef KX_BlenderMaterial::Methods[] = +PyMethodDef KX_BlenderMaterial::Methods[] = { KX_PYMETHODTABLE( KX_BlenderMaterial, getShader ), KX_PYMETHODTABLE( KX_BlenderMaterial, getMaterialIndex ), @@ -1214,7 +1214,7 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") if ( !GLEW_ARB_fragment_shader) { if (!mModified) spit("Fragment shaders not supported"); - + mModified = true; Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index a3d10c0a89d..02b60913b91 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -55,30 +55,30 @@ public: return (void*) this; } - virtual + virtual bool Activate( - RAS_IRasterizer* rasty, + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo ) const; - - virtual + + virtual void ActivateMeshSlot( - const RAS_MeshSlot & ms, - RAS_IRasterizer* rasty + const RAS_MeshSlot & ms, + RAS_IRasterizer* rasty ) const; - + void ActivateMat( RAS_IRasterizer* rasty, TCachingInfo& cachingInfo )const; void ActivatShaders( - RAS_IRasterizer* rasty, + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo )const; void ActivateBlenderShaders( - RAS_IRasterizer* rasty, + RAS_IRasterizer* rasty, TCachingInfo& cachingInfo )const; @@ -86,11 +86,11 @@ public: Image* GetBlenderImage() const; MTexPoly *GetMTexPoly() const; unsigned int* GetMCol() const; - BL_Texture * getTex (unsigned int idx) { - return (idx < MAXTEX) ? mTextures + idx : NULL; + BL_Texture * getTex (unsigned int idx) { + return (idx < MAXTEX) ? mTextures + idx : NULL; } - Image * getImage (unsigned int idx) { - return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL; + Image * getImage (unsigned int idx) { + return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL; } unsigned int* getBlendFunc() { return mBlendFunc; @@ -101,7 +101,7 @@ public: MT_Scalar hard, MT_Scalar spec, MT_Scalar ref, MT_Scalar emit, MT_Scalar alpha ); - + virtual void Replace_IScene(SCA_IScene *val); BL_Material *GetBLMaterial(); diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 89aea80bb67..93f1621255d 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -30,7 +30,7 @@ * \ingroup ketsji */ - + #include "glew-mx.h" #include "KX_Camera.h" #include "KX_Scene.h" @@ -76,10 +76,10 @@ KX_Camera::~KX_Camera() CValue* KX_Camera::GetReplica() { KX_Camera* replica = new KX_Camera(*this); - + // this will copy properties and so on... replica->ProcessReplica(); - + return replica; } @@ -91,15 +91,15 @@ void KX_Camera::ProcessReplica() } MT_Transform KX_Camera::GetWorldToCamera() const -{ +{ MT_Transform camtrans; camtrans.invert(MT_Transform(NodeGetWorldPosition(), NodeGetWorldOrientation())); - + return camtrans; } - + MT_Transform KX_Camera::GetCameraToWorld() const { return MT_Transform(NodeGetWorldPosition(), NodeGetWorldOrientation()); @@ -121,7 +121,7 @@ const MT_Point3 KX_Camera::GetCameraLocation() const /* .... I want it in world coords */ //MT_Transform trans; //trans.setBasis(NodeGetWorldOrientation()); - + return NodeGetWorldPosition(); } @@ -261,7 +261,7 @@ float KX_Camera::GetFocalLength() const RAS_CameraData* KX_Camera::GetCameraData() { - return &m_camdata; + return &m_camdata; } void KX_Camera::ExtractClipPlanes() @@ -282,7 +282,7 @@ void KX_Camera::ExtractClipPlanes() m_planes[4] = m[3] + m[2]; // Far clip plane m_planes[5] = m[3] - m[2]; - + m_dirty = false; m_normalized = false; } @@ -291,14 +291,14 @@ void KX_Camera::NormalizeClipPlanes() { if (m_normalized) return; - + for (unsigned int p = 0; p < 6; p++) { 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; } - + m_normalized = true; } @@ -382,15 +382,15 @@ void KX_Camera::ExtractFrustumSphere() // orthographic projection // The most extreme points on the near and far plane. (normalized device coords) 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; hfar = clip_camcs_matrix*hfar; - + // Tranform to 3d camera local space. MT_Point3 nearpoint(hnear[0]/hnear[3], hnear[1]/hnear[3], hnear[2]/hnear[3]); 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.5f; m_frustum_radius = m_frustum_center.distance(farpoint); @@ -398,14 +398,14 @@ void KX_Camera::ExtractFrustumSphere() // Transform to world space. m_frustum_center = GetCameraToWorld()(m_frustum_center); m_frustum_radius /= fabsf(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]); - + m_set_frustum_center = true; } bool KX_Camera::PointInsideFrustum(const MT_Point3& x) { ExtractClipPlanes(); - + 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.0f) @@ -417,7 +417,7 @@ bool KX_Camera::PointInsideFrustum(const MT_Point3& x) int KX_Camera::BoxInsideFrustum(const MT_Point3 *box) { ExtractClipPlanes(); - + unsigned int insideCount = 0; // 6 view frustum planes for ( unsigned int p = 0; p < 6 ; p++ ) @@ -429,7 +429,7 @@ int KX_Camera::BoxInsideFrustum(const MT_Point3 *box) 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++; } - + // 8 points behind this plane if (behindCount == 8) return OUTSIDE; @@ -438,11 +438,11 @@ int KX_Camera::BoxInsideFrustum(const MT_Point3 *box) if (!behindCount) insideCount++; } - + // All box vertices are on the front side of all frustum planes. if (insideCount == 6) return INSIDE; - + return INTERSECT; } @@ -455,7 +455,7 @@ int KX_Camera::SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &rad unsigned int p; ExtractClipPlanes(); NormalizeClipPlanes(); - + MT_Scalar distance; int intersect = INSIDE; // distance: <-------- OUTSIDE -----|----- INTERSECT -----0----- INTERSECT -----|----- INSIDE --------> @@ -468,7 +468,7 @@ int KX_Camera::SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &rad else if (distance < -radius) return OUTSIDE; } - + return intersect; } @@ -476,7 +476,7 @@ bool KX_Camera::GetFrustumCulling() const { return m_frustum_culling; } - + void KX_Camera::EnableViewport(bool viewport) { InvalidateProjectionMatrix(false); // We need to reset projection matrix @@ -536,10 +536,10 @@ PyMethodDef KX_Camera::Methods[] = { }; PyAttributeDef KX_Camera::Attributes[] = { - + KX_PYATTRIBUTE_BOOL_RW("frustum_culling", KX_Camera, m_frustum_culling), KX_PYATTRIBUTE_RW_FUNCTION("perspective", KX_Camera, pyattr_get_perspective, pyattr_set_perspective), - + KX_PYATTRIBUTE_RW_FUNCTION("lens", KX_Camera, pyattr_get_lens, pyattr_set_lens), KX_PYATTRIBUTE_RW_FUNCTION("fov", KX_Camera, pyattr_get_fov, pyattr_set_fov), KX_PYATTRIBUTE_RW_FUNCTION("ortho_scale", KX_Camera, pyattr_get_ortho_scale, pyattr_set_ortho_scale), @@ -549,17 +549,17 @@ PyAttributeDef KX_Camera::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("shift_y", KX_Camera, pyattr_get_shift_y, pyattr_set_shift_y), KX_PYATTRIBUTE_RW_FUNCTION("useViewport", KX_Camera, pyattr_get_use_viewport, pyattr_set_use_viewport), - + KX_PYATTRIBUTE_RW_FUNCTION("projection_matrix", KX_Camera, pyattr_get_projection_matrix, pyattr_set_projection_matrix), KX_PYATTRIBUTE_RO_FUNCTION("modelview_matrix", KX_Camera, pyattr_get_modelview_matrix), KX_PYATTRIBUTE_RO_FUNCTION("camera_to_world", KX_Camera, pyattr_get_camera_to_world), KX_PYATTRIBUTE_RO_FUNCTION("world_to_camera", KX_Camera, pyattr_get_world_to_camera), - + /* Grrr, functions for constants? */ KX_PYATTRIBUTE_RO_FUNCTION("INSIDE", KX_Camera, pyattr_get_INSIDE), KX_PYATTRIBUTE_RO_FUNCTION("OUTSIDE", KX_Camera, pyattr_get_OUTSIDE), KX_PYATTRIBUTE_RO_FUNCTION("INTERSECT", KX_Camera, pyattr_get_INTERSECT), - + { NULL } //Sentinel }; @@ -621,7 +621,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum, } PyErr_SetString(PyExc_TypeError, "camera.sphereInsideFrustum(center, radius): KX_Camera, expected arguments: (center, radius)"); - + return NULL; } @@ -656,7 +656,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum, PyErr_Format(PyExc_TypeError, "camera.boxInsideFrustum(box): KX_Camera, expected eight (8) points, got %d", num_points); return NULL; } - + MT_Point3 box[8]; for (unsigned int p = 0; p < 8 ; p++) { @@ -666,7 +666,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum, if (error) return NULL; } - + return PyLong_FromLong(BoxInsideFrustum(box)); /* new ref */ } @@ -691,7 +691,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum, { return PyLong_FromLong(PointInsideFrustum(point)); /* new ref */ } - + PyErr_SetString(PyExc_TypeError, "camera.pointInsideFrustum(point): KX_Camera, expected point argument."); return NULL; } @@ -721,7 +721,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, setViewport, int left, bottom, right, top; if (!PyArg_ParseTuple(args,"iiii:setViewport",&left, &bottom, &right, &top)) return NULL; - + SetViewport(left, bottom, right, top); Py_RETURN_NONE; } @@ -749,7 +749,7 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at PyErr_SetString(PyExc_AttributeError, "camera.perspective = bool: KX_Camera, expected True/False or 0/1"); return PY_SET_ATTR_FAIL; } - + self->m_camdata.m_perspective= param; self->InvalidateProjectionMatrix(); return PY_SET_ATTR_SUCCESS; @@ -769,7 +769,7 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyErr_SetString(PyExc_AttributeError, "camera.lens = float: KX_Camera, expected a float greater than zero"); return PY_SET_ATTR_FAIL; } - + self->m_camdata.m_lens= param; self->m_set_projection_matrix = false; return PY_SET_ATTR_SUCCESS; @@ -798,7 +798,7 @@ int KX_Camera::pyattr_set_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P fov *= MT_RADS_PER_DEG; float width = self->m_camdata.m_sensor_x; float lens = width / (2.0f * tanf(0.5f * fov)); - + self->m_camdata.m_lens= lens; self->m_set_projection_matrix = false; return PY_SET_ATTR_SUCCESS; @@ -818,7 +818,7 @@ int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *at PyErr_SetString(PyExc_AttributeError, "camera.ortho_scale = float: KX_Camera, expected a float greater than zero"); return PY_SET_ATTR_FAIL; } - + self->m_camdata.m_scale= param; self->m_set_projection_matrix = false; return PY_SET_ATTR_SUCCESS; @@ -838,7 +838,7 @@ int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyErr_SetString(PyExc_AttributeError, "camera.near = float: KX_Camera, expected a float greater than zero"); return PY_SET_ATTR_FAIL; } - + self->m_camdata.m_clipstart= param; self->m_set_projection_matrix = false; return PY_SET_ATTR_SUCCESS; @@ -858,7 +858,7 @@ int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P PyErr_SetString(PyExc_AttributeError, "camera.far = float: KX_Camera, expected a float greater than zero"); return PY_SET_ATTR_FAIL; } - + self->m_camdata.m_clipend= param; self->m_set_projection_matrix = false; return PY_SET_ATTR_SUCCESS; @@ -926,16 +926,16 @@ int KX_Camera::pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *a PyObject *KX_Camera::pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self = static_cast<KX_Camera*>(self_v); - return PyObjectFrom(self->GetProjectionMatrix()); + return PyObjectFrom(self->GetProjectionMatrix()); } int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_Camera* self = static_cast<KX_Camera*>(self_v); MT_Matrix4x4 mat; - if (!PyMatTo(value, mat)) + if (!PyMatTo(value, mat)) return PY_SET_ATTR_FAIL; - + self->SetProjectionMatrix(mat); return PY_SET_ATTR_SUCCESS; } @@ -955,7 +955,7 @@ PyObject *KX_Camera::pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBU PyObject *KX_Camera::pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self = static_cast<KX_Camera*>(self_v); - return PyObjectFrom(self->GetWorldToCamera()); + return PyObjectFrom(self->GetWorldToCamera()); } @@ -974,10 +974,10 @@ bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, *object = NULL; return false; } - + if (value==Py_None) { *object = NULL; - + if (py_none_ok) { return true; } else { @@ -985,11 +985,11 @@ bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, return false; } } - + if (PyUnicode_Check(value)) { STR_String value_str = _PyUnicode_AsString(value); *object = KX_GetActiveScene()->FindCamera(value_str); - + if (*object) { return true; } else { @@ -999,27 +999,27 @@ bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, return false; } } - + if (PyObject_TypeCheck(value, &KX_Camera::Type)) { *object = static_cast<KX_Camera*>BGE_PROXY_REF(value); - + /* sets the error */ if (*object==NULL) { PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix); return false; } - + return true; } - + *object = NULL; - + if (py_none_ok) { PyErr_Format(PyExc_TypeError, "%s, expect a KX_Camera, a string or None", error_prefix); } else { PyErr_Format(PyExc_TypeError, "%s, expect a KX_Camera or a string", error_prefix); } - + return false; } diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 8addf0b7aed..3b96d7d01b8 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -82,7 +82,7 @@ protected: * Storage for the modelview matrix that is passed to the * rasterizer. */ MT_Matrix4x4 m_modelview_matrix; - + /** * true if the view frustum (modelview/projection matrix) * has changed - the clip planes (m_planes) will have to be @@ -93,23 +93,23 @@ protected: * true if the frustum planes have been normalized. */ bool m_normalized; - + /** * View Frustum clip planes. */ MT_Vector4 m_planes[6]; - + /** * This camera is frustum culling. * Some cameras (ie if the game was started from a non camera view should not cull.) */ bool m_frustum_culling; - + /** * true if this camera has a valid projection matrix. */ bool m_set_projection_matrix; - + /** * The center point of the frustum. */ @@ -150,10 +150,10 @@ public: KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, bool delete_node = false); virtual ~KX_Camera(); - - /** + + /** * Inherited from CValue -- return a new copy of this - * instance allocated on the heap. Ownership of the new + * instance allocated on the heap. Ownership of the new * object belongs with the caller. */ virtual CValue* @@ -172,26 +172,26 @@ public: /* I want the camera orientation as well. */ const MT_Quaternion GetCameraOrientation() const; - + /** Sets the projection matrix that is used by the rasterizer. */ void SetProjectionMatrix(const MT_Matrix4x4 & mat); /** Sets the modelview matrix that is used by the rasterizer. */ void SetModelviewMatrix(const MT_Matrix4x4 & mat); - + /** Gets the projection matrix that is used by the rasterizer. */ const MT_Matrix4x4& GetProjectionMatrix() const; - + /** returns true if this camera has been set a projection matrix. */ bool hasValidProjectionMatrix() const; - + /** Sets the validity of the projection matrix. Call this if you change camera * data (eg lens, near plane, far plane) and require the projection matrix to be * recalculated. */ void InvalidateProjectionMatrix(bool valid = false); - - /** Gets the modelview matrix that is used by the rasterizer. + + /** Gets the modelview matrix that is used by the rasterizer. * \warning If the Camera is a dynamic object then this method may return garbage. Use GetWorldToCamera() instead. */ const MT_Matrix4x4& GetModelviewMatrix() const; @@ -218,7 +218,7 @@ public: float GetFocalLength() const; /** Gets all camera data. */ RAS_CameraData* GetCameraData(); - + /** * Tests if the given sphere is inside this camera's view frustum. * @@ -239,42 +239,42 @@ public: * \return true if the given point is inside or on the view frustum; false if it is outside. */ bool PointInsideFrustum(const MT_Point3& x); - + /** * Gets this camera's culling status. */ bool GetFrustumCulling() const; - + /** * Sets this camera's viewport status. */ void EnableViewport(bool viewport); - + /** * Sets this camera's viewport. */ void SetViewport(int left, int bottom, int right, int top); - + /** * Gets this camera's viewport status. */ bool GetViewport() const; - + /** * Gets this camera's viewport left. */ int GetViewportLeft() const; - + /** * Gets this camera's viewport bottom. */ int GetViewportBottom() const; - + /** * Gets this camera's viewport right. */ int GetViewportRight() const; - + /** * Gets this camera's viewport top. */ @@ -286,17 +286,17 @@ public: KX_PYMETHOD_DOC_VARARGS(KX_Camera, sphereInsideFrustum); KX_PYMETHOD_DOC_O(KX_Camera, boxInsideFrustum); KX_PYMETHOD_DOC_O(KX_Camera, pointInsideFrustum); - + KX_PYMETHOD_DOC_NOARGS(KX_Camera, getCameraToWorld); KX_PYMETHOD_DOC_NOARGS(KX_Camera, getWorldToCamera); - + KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport); KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop); KX_PYMETHOD_DOC_O(KX_Camera, getScreenPosition); KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenVect); KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenRay); - + static PyObject* pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); @@ -317,14 +317,14 @@ public: static PyObject* pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - + static PyObject* pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - + static PyObject* pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + static PyObject* pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index e488bf3c30a..f71699da5d8 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -40,21 +40,21 @@ #include <float.h> #include "KX_GameObject.h" -#include "EXP_PyObjectPlus.h" +#include "EXP_PyObjectPlus.h" /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ KX_CameraActuator::KX_CameraActuator( - SCA_IObject* gameobj, + SCA_IObject* gameobj, SCA_IObject *obj, float hght, float minhght, float maxhght, short axis, float damping -): +): SCA_IActuator(gameobj, KX_ACT_CAMERA), m_ob (obj), m_height (hght), @@ -73,7 +73,7 @@ KX_CameraActuator::~KX_CameraActuator() m_ob->UnregisterActuator(this); } - CValue* + CValue* KX_CameraActuator:: GetReplica( ) { @@ -126,7 +126,7 @@ static void Kx_VecUpMat3(float vec[3], float mat[3][3], short axis) float inp; short cox = 0, coy = 0, coz = 0; - + /* up range has no meaning, is not really up! * see: VecUpMat3old */ @@ -163,7 +163,7 @@ static void Kx_VecUpMat3(float vec[3], float mat[3][3], short axis) mat[coz][1] = 0.0f; mat[coz][2] = 0.0f; } - + inp = mat[coz][2]; mat[coy][0] = - inp * mat[coz][0]; mat[coy][1] = - inp * mat[coz][1]; @@ -175,7 +175,7 @@ static void Kx_VecUpMat3(float vec[3], float mat[3][3], short axis) mat[coy][1] = 1.f; mat[coy][2] = 0.f; } - + cross_v3_v3v3(mat[cox], mat[coy], mat[coz]); } @@ -186,9 +186,9 @@ bool KX_CameraActuator::Update(double curtime, bool frame) bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); - if (bNegativeEvent || !m_ob) + if (bNegativeEvent || !m_ob) return false; - + KX_GameObject *obj = (KX_GameObject*) GetParent(); MT_Point3 from = obj->NodeGetWorldPosition(); MT_Matrix3x3 frommat = obj->NodeGetWorldOrientation(); @@ -200,7 +200,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) float inp, fac; //, factor = 0.0; /* some factor... */ float mindistsq, maxdistsq, distsq; float mat[3][3]; - + /* The rules: */ /* CONSTRAINT 1: not implemented */ /* CONSTRAINT 2: can camera see actor? */ @@ -287,7 +287,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) from[0] += fac * fp1[0]; from[1] += fac * fp1[1]; from[2] += fac * fp1[2]; - + /* only for it lies: cross test and perpendicular bites up */ if (inp < 0.0f) { /* Don't do anything if the cross product is too small. @@ -313,14 +313,14 @@ bool KX_CameraActuator::Update(double curtime, bool frame) if (distsq > maxdistsq) { distsq = 0.15f * (distsq - maxdistsq) / distsq; - + from[0] += distsq*rc[0]; from[1] += distsq*rc[1]; from[2] += distsq*rc[2]; } else if (distsq < mindistsq) { distsq = 0.15f * (mindistsq - distsq) / mindistsq; - + from[0] -= distsq*rc[0]; from[1] -= distsq*rc[1]; from[2] -= distsq*rc[2]; @@ -332,14 +332,14 @@ bool KX_CameraActuator::Update(double curtime, bool frame) rc[1] = (lookat[1]-from[1]); rc[2] = (lookat[2]-from[2]); Kx_VecUpMat3(rc, mat, 3); /* y up Track -z */ - + /* now set the camera position and rotation */ - + obj->NodeSetLocalPosition(from); - + actormat[0][0] = mat[0][0]; actormat[0][1] = mat[1][0]; actormat[0][2] = mat[2][0]; actormat[1][0] = mat[0][1]; actormat[1][1] = mat[1][1]; actormat[1][2] = mat[2][1]; actormat[2][0] = mat[0][2]; actormat[2][1] = mat[1][2]; actormat[2][2] = mat[2][2]; @@ -410,16 +410,16 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF { KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v); KX_GameObject *gameobj; - + if (!ConvertPythonToGameObject(self->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_CameraActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error - + if (self->m_ob) self->m_ob->UnregisterActuator(self); if ((self->m_ob = (SCA_IObject*)gameobj)) self->m_ob->RegisterActuator(self); - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index fb0a7d88dd9..83668d8bf40 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -60,19 +60,19 @@ private : //const MT_Scalar m_minHeight; /** max (float), */ //const MT_Scalar m_maxHeight; - + /** height (float), */ float m_height; - + /** min (float), */ float m_minHeight; - + /** max (float), */ float m_maxHeight; - + /** axis the camera tries to get behind: +x/+y/-x/-y */ short m_axis; - + /** damping (float), */ float m_damping; @@ -81,11 +81,11 @@ private : /* parse x or y to a toggle pick */ bool string2axischoice(const char *axisString); - + public: static STR_String X_AXIS_STRING; static STR_String Y_AXIS_STRING; - + /** * Set the bool toggle to true to use x lock, false for y lock */ @@ -109,7 +109,7 @@ private : /** Methods Inherited from CValue */ CValue* GetReplica(); virtual void ProcessReplica(); - + /** Methods inherited from SCA_IActuator */ virtual bool Update( diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp index a1c726209e1..70f5386fbb7 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp @@ -49,11 +49,11 @@ bool KX_CameraIpoSGController::Update(double currentTime) for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { (*i)->Execute(m_ipotime); } - + SG_Spatial* ob = (SG_Spatial*)m_pObject; KX_Camera* kxcamera = (KX_Camera*) ob->GetSGClientObject(); RAS_CameraData* camdata = kxcamera->GetCameraData(); - + if (m_modify_lens) camdata->m_lens = m_lens; @@ -62,7 +62,7 @@ bool KX_CameraIpoSGController::Update(double currentTime) if (m_modify_clipend) camdata->m_clipend = m_clipend; - + if (m_modify_lens || m_modify_clipstart || m_modify_clipend) kxcamera->InvalidateProjectionMatrix(); @@ -102,7 +102,7 @@ SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode) MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; copyipo->SetNewTarget((MT_Scalar*)blaptr); } - + return iporeplica; } @@ -113,13 +113,13 @@ KX_CameraIpoSGController::~KX_CameraIpoSGController() for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { delete (*i); } - + } void KX_CameraIpoSGController::SetOption( int option, - int value) + int value) { /* Setting options */ diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h index 1f6f211622c..211c1a4e198 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.h @@ -55,7 +55,7 @@ private: double m_ipotime; public: - KX_CameraIpoSGController() : + KX_CameraIpoSGController() : m_modify_lens(false), m_modify_clipstart(false), m_modify_clipend(false), @@ -87,8 +87,8 @@ public: m_modify_clipstart = modify; } void AddInterpolator(KX_IInterpolator* interp); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_CameraIpoSGController") #endif diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.h b/source/gameengine/Ketsji/KX_CharacterWrapper.h index dd7ba680ec7..262242b251b 100644 --- a/source/gameengine/Ketsji/KX_CharacterWrapper.h +++ b/source/gameengine/Ketsji/KX_CharacterWrapper.h @@ -23,7 +23,7 @@ public: KX_PYMETHOD_DOC_NOARGS(KX_CharacterWrapper, jump); static PyObject* pyattr_get_onground(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + static PyObject* pyattr_get_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_max_jumps(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h index 81ae5b58009..bcbf06b947c 100644 --- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h +++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h @@ -58,24 +58,24 @@ public: m_type(type), m_gameobject(gameobject) {} - + KX_ClientObjectInfo(const KX_ClientObjectInfo ©) : m_type(copy.m_type), m_gameobject(copy.m_gameobject) { } - + virtual ~KX_ClientObjectInfo() {} - - virtual bool hasCollisionCallback() + + virtual bool hasCollisionCallback() { return m_sensors.size() != 0; } - + bool isActor() { return m_type <= ACTOR; } bool isSensor() { return m_type >= SENSOR && m_type <= OBACTORSENSOR; } - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ClientObjectInfo") #endif diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 27c074393b4..a1ccd9f8bf8 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -49,7 +49,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, +KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, int posDampTime, int rotDampTime, float minBound, @@ -113,7 +113,7 @@ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, } /* End of constructor */ KX_ConstraintActuator::~KX_ConstraintActuator() -{ +{ // there's nothing to be done here, really.... } /* end of destructor */ @@ -121,7 +121,7 @@ bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo *client, KX_RayCast *resu { m_hitObject = client->m_gameobject; - + bool bFound = false; if (m_property.IsEmpty()) @@ -339,7 +339,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) if (!pe) { std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl; goto CHECK_TIME; - } + } if (!spc) { // the object is not physical, we probably want to avoid hitting its own parent KX_GameObject *parent = obj->GetParent(); @@ -353,7 +353,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) MT_Vector3 newnormal = callback.m_hitNormal; // compute new position & orientation if ((m_option & (KX_ACT_CONSTRAINT_NORMAL|KX_ACT_CONSTRAINT_DISTANCE)) == 0) { - // if none option is set, the actuator does nothing but detect ray + // if none option is set, the actuator does nothing but detect ray // (works like a sensor) goto CHECK_TIME; } @@ -398,7 +398,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) goto CHECK_TIME; } } - break; + break; case KX_ACT_CONSTRAINT_FHPX: case KX_ACT_CONSTRAINT_FHPY: case KX_ACT_CONSTRAINT_FHPZ: @@ -451,7 +451,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) if (!pe) { std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl; goto CHECK_TIME; - } + } if (!spc || !spc->IsDynamic()) { // the object is not dynamic, it won't support setting speed goto CHECK_TIME; @@ -468,7 +468,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) { MT_Vector3 newnormal = callback.m_hitNormal; // compute new position & orientation - MT_Scalar distance = (callback.m_hitPoint-position).length()-spc->GetRadius(); + MT_Scalar distance = (callback.m_hitPoint-position).length()-spc->GetRadius(); // estimate the velocity of the hit point MT_Point3 relativeHitPoint; relativeHitPoint = (callback.m_hitPoint-m_hitObject->NodeGetWorldPosition()); @@ -502,7 +502,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) // don't set the position with this constraint goto CHECK_TIME; } - break; + break; case KX_ACT_CONSTRAINT_LOCX: case KX_ACT_CONSTRAINT_LOCY: case KX_ACT_CONSTRAINT_LOCZ: @@ -541,8 +541,8 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) return result; } /* end of KX_ConstraintActuator::Update(double curtime,double deltatime) */ -void KX_ConstraintActuator::Clamp(MT_Scalar &var, - float min, +void KX_ConstraintActuator::Clamp(MT_Scalar &var, + float min, float max) { if (var < min) { var = min; @@ -552,7 +552,7 @@ void KX_ConstraintActuator::Clamp(MT_Scalar &var, } -bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE m) +bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE m) { bool res = false; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index af617655d5e..61f106321de 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -49,7 +49,7 @@ protected: // Damp time (int), int m_posDampTime; int m_rotDampTime; - // min (float) + // min (float) float m_minimumBound; // max (float) float m_maximumBound; @@ -78,7 +78,7 @@ protected: */ void Clamp(MT_Scalar &var, float min, float max); - + public: // m_locrot enum KX_CONSTRAINTTYPE { diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 2f32b5e3216..9c3ece2fb55 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -60,23 +60,23 @@ PyObject *KX_ConstraintWrapper::PyGetParam(PyObject *args, PyObject *kwds) { int dof; float value; - + if (!PyArg_ParseTuple(args,"i:getParam",&dof)) return NULL; - + value = m_physenv->GetConstraintParam(m_constraintId,dof); return PyFloat_FromDouble(value); - + } PyObject *KX_ConstraintWrapper::PySetParam(PyObject *args, PyObject *kwds) { int dof; float minLimit,maxLimit; - + if (!PyArg_ParseTuple(args,"iff:setParam",&dof,&minLimit,&maxLimit)) return NULL; - + m_physenv->SetConstraintParam(m_constraintId,dof,minLimit,maxLimit); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index 5e20b7a9aca..8c645615fe8 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -42,7 +42,7 @@ public: KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_ConstraintWrapper (); int getConstraintId() { return m_constraintId; } - + #ifdef WITH_PYTHON KX_PYMETHOD_NOARGS(KX_ConstraintWrapper,GetConstraintId); KX_PYMETHOD(KX_ConstraintWrapper,SetParam); diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index d08372e47d4..46ba00e4cb1 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -180,7 +180,7 @@ void KX_Dome::SetViewPort(const int viewport[4]) { if (canvaswidth != m_viewport.GetWidth() || canvasheight != m_viewport.GetHeight()) { - m_viewport.SetLeft(viewport[0]); + m_viewport.SetLeft(viewport[0]); m_viewport.SetBottom(viewport[1]); m_viewport.SetRight(viewport[2]); m_viewport.SetTop(viewport[3]); @@ -237,7 +237,7 @@ void KX_Dome::CalculateImageSize(void) m_buffersize = (canvaswidth > canvasheight?canvasheight:canvaswidth); m_buffersize = (int)(m_buffersize*m_resbuffer); //reduce buffer size for better performance - + int i = 0; while ((1 << i) <= m_buffersize) i++; @@ -315,7 +315,7 @@ bool KX_Dome::CreateDL() glEndList(); } - //clearing the vectors + //clearing the vectors cubetop.clear(); cubebottom.clear(); cuberight.clear(); @@ -591,9 +591,9 @@ void KX_Dome::CreateMeshDome180(void) cubebottom[0].v[2] = 0.0; nfacesbottom = 1; - + /* Left face - two triangles */ - + cubeleft[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f; cubeleft[0].verts[0][1] = 0.0f; cubeleft[0].verts[0][2] = -0.5f; @@ -632,7 +632,7 @@ void KX_Dome::CreateMeshDome180(void) cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; - + /* Right face - two triangles */ cuberight[0].verts[0][0] = 0.0f; cuberight[0].verts[0][1] = (float)M_SQRT2 / 2.0f; @@ -672,7 +672,7 @@ void KX_Dome::CreateMeshDome180(void) cuberight[1].v[2] = uv_ratio; nfacesright = 2; - + //Refine a triangular mesh by bisecting each edge forms 3 new triangles for each existing triangle on each iteration //Could be made more efficient for drawing if the triangles were ordered in a fan. Not that important since we are using DisplayLists @@ -750,7 +750,7 @@ void KX_Dome::CreateMeshDome250(void) uv_height = uv_ratio * ( (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.0f; @@ -1133,7 +1133,7 @@ void KX_Dome::CreateMeshPanorama(void) nfacesleftback = 2; /* Left face - two triangles */ - + cubeleft[0].verts[0][0] = (float)(-M_SQRT2); cubeleft[0].verts[0][1] = 0.0f; cubeleft[0].verts[0][2] = -1.0f; @@ -1172,7 +1172,7 @@ void KX_Dome::CreateMeshPanorama(void) cubeleft[1].v[2] = uv_ratio; nfacesleft = 2; - + /* Right face - two triangles */ cuberight[0].verts[0][0] = 0.0f; cuberight[0].verts[0][1] = (float)M_SQRT2; @@ -1212,7 +1212,7 @@ void KX_Dome::CreateMeshPanorama(void) cuberight[1].v[2] = uv_ratio; nfacesright = 2; - + /* Right Back (-135deg) face - two triangles */ cuberightback[0].verts[0][0] = (float)M_SQRT2; cuberightback[0].verts[0][1] = 0.0f; @@ -1435,7 +1435,7 @@ void KX_Dome::SplitFace(vector <DomeFace>& face, int *nfaces) void KX_Dome::CalculateFrustum(KX_Camera *cam) { #if 0 - // manually creating a 90deg Field of View Frustum + // manually creating a 90deg Field of View Frustum // the original formula: top = tan(fov*3.14159f/30.0f)) * near [for fov in degrees] @@ -1462,7 +1462,7 @@ void KX_Dome::CalculateFrustum(KX_Camera *cam) m_frustum.x2 = top; m_frustum.y1 = -top; m_frustum.y2 = top; - + m_projmat = m_rasterizer->GetFrustumMatrix( m_frustum.x1, m_frustum.x2, m_frustum.y1, m_frustum.y2, m_frustum.camnear, m_frustum.camfar); } @@ -1479,7 +1479,7 @@ void KX_Dome::CalculateCameraOrientation() MT_Scalar c = cosf(deg45); MT_Scalar s = sinf(deg45); - if (m_angle <= 180 && (m_mode == DOME_FISHEYE + if (m_angle <= 180 && (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR)) { @@ -1504,7 +1504,7 @@ void KX_Dome::CalculateCameraOrientation() 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_FRONT || m_mode == DOME_TRUNCATED_REAR))) { m_locRot[0] = MT_Matrix3x3( // 90deg - Top @@ -1526,7 +1526,7 @@ void KX_Dome::CalculateCameraOrientation() 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.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, @@ -1539,7 +1539,7 @@ void KX_Dome::CalculateCameraOrientation() } else if (m_mode == DOME_PANORAM_SPH) { - m_locRot[0] = MT_Matrix3x3( // Top + m_locRot[0] = MT_Matrix3x3( // Top c, s, 0.0f, 0.0f,0.0f, -1.0f, -s, c, 0.0f); @@ -1658,7 +1658,7 @@ void KX_Dome::DrawEnvMap(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // Making the viewport always square + // Making the viewport always square int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); @@ -1677,7 +1677,7 @@ void KX_Dome::DrawEnvMap(void) ortho_height = 2.0f / 3; ortho_width = (float)can_width/can_height * ortho_height; } - + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } @@ -1788,7 +1788,7 @@ void KX_Dome::DrawDomeFisheye(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // Making the viewport always square + // Making the viewport always square int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); @@ -1808,7 +1808,7 @@ void KX_Dome::DrawDomeFisheye(void) ortho_width = (float)can_width/can_height; ortho_height = 1.0f; } - + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } } @@ -1884,7 +1884,7 @@ void KX_Dome::DrawPanorama(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // Making the viewport always square + // Making the viewport always square int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); @@ -1905,7 +1905,7 @@ void KX_Dome::DrawPanorama(void) ortho_width = (float)can_width / can_height * 0.5f; ortho_height = 0.5f; } - + glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f); } @@ -1968,7 +1968,7 @@ void KX_Dome::DrawDomeWarped(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // Making the viewport always square + // Making the viewport always square int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h index 5a0c4588ae2..26079a10e1d 100644 --- a/source/gameengine/Ketsji/KX_Dome.h +++ b/source/gameengine/Ketsji/KX_Dome.h @@ -83,7 +83,7 @@ public: GLuint domefacesId[7]; /* ID of the images -- room for 7 images, using only 4 for 180deg x 360deg dome, * 6 for panoramic and +1 for warp mesh */ GLuint dlistId; /* ID of the Display Lists of the images (used as an offset) */ - + typedef struct { double u[3], v[3]; MT_Vector3 verts[3]; //three verts @@ -108,7 +108,7 @@ public: vector <DomeFace> cubetop, cubebottom, cuberight, cubeleft, cubefront, cubeback; //for fisheye vector <DomeFace> cubeleftback, cuberightback; //for panorama - + int nfacestop, nfacesbottom, nfacesleft, nfacesright, nfacesfront, nfacesback; int nfacesleftback, nfacesrightback; @@ -145,7 +145,7 @@ public: void CreateGLImages(void); void ClearGLImages(void);//called on resize bool CreateDL(void); //create Display Lists - void ClearDL(void); //remove Display Lists + void ClearDL(void); //remove Display Lists bool CreateFBO(void);//create FBO (for warp mesh) void ClearFBO(void); //remove FBO @@ -169,7 +169,7 @@ protected: float m_radangle; //the angle of the fisheye in radians float m_resbuffer; //the resolution of the buffer short m_tilt; //the dome tilt (camera rotation on horizontal axis) - + RAS_Rect m_viewport; MT_Matrix4x4 m_projmat; @@ -187,8 +187,8 @@ protected: RAS_IRenderTools* m_rendertools; /// engine KX_KetsjiEngine* m_engine; - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_Dome") #endif diff --git a/source/gameengine/Ketsji/KX_EmptyObject.h b/source/gameengine/Ketsji/KX_EmptyObject.h index 63a0782a544..80d8620894a 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.h +++ b/source/gameengine/Ketsji/KX_EmptyObject.h @@ -37,7 +37,7 @@ class KX_EmptyObject : public KX_GameObject { public: KX_EmptyObject(void* sgReplicationInfo,SG_Callbacks callbacks) : - KX_GameObject(sgReplicationInfo,callbacks) + KX_GameObject(sgReplicationInfo,callbacks) {}; virtual ~KX_EmptyObject(); diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index ae79284288d..a597b2981a2 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -92,9 +92,9 @@ KX_FontObject::KX_FontObject(void* sgReplicationInfo, m_fsize = text->fsize; m_line_spacing = text->linedist; m_offset = MT_Vector3(text->xof, text->yof, 0); - + m_fontid = GetFontId(text->vfont); - + /* initialize the color with the object color and store it in the KX_Object class * This is a workaround waiting for the fix: * [#25487] BGE: Object Color only works when it has a keyed frame */ @@ -128,19 +128,19 @@ int GetFontId(VFont *vfont) if (vfont->packedfile) { packedfile= vfont->packedfile; fontid= BLF_load_mem(vfont->name, (unsigned char*)packedfile->data, packedfile->size); - + if (fontid == -1) { printf("ERROR: packed font \"%s\" could not be loaded.\n", vfont->name); fontid = BLF_load("default"); } return fontid; } - + /* once we have packed working we can load the builtin font */ const char *filepath = vfont->name; if (BKE_vfont_is_builtin(vfont)) { fontid = BLF_load("default"); - + /* XXX the following code is supposed to work (after you add get_builtin_packedfile to BKE_font.h ) * unfortunately it's crashing on blf_glyph.c:173 because gc->glyph_width_max is 0 */ @@ -150,18 +150,18 @@ int GetFontId(VFont *vfont) return BLF_load("default"); } - + /* convert from absolute to relative */ char expanded[256]; // font names can be bigger than FILE_MAX (240) BLI_strncpy(expanded, filepath, 256); BLI_path_abs(expanded, G.main->name); - + fontid = BLF_load(expanded); /* fallback */ if (fontid == -1) fontid = BLF_load("default"); - + return fontid; } diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index bf70eedfde6..27f642f0f9b 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -47,9 +47,9 @@ public: void DrawFontText(); - /** + /** * Inherited from CValue -- return a new copy of this - * instance allocated on the heap. Ownership of the new + * instance allocated on the heap. Ownership of the new * object belongs with the caller. */ virtual CValue* GetReplica(); diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index f1bd253f8b3..8bfe6966764 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -50,7 +50,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj, +KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj, int mode, const STR_String& filename, const STR_String& loadinganimationname, @@ -68,7 +68,7 @@ KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj, KX_GameActuator::~KX_GameActuator() -{ +{ // there's nothing to be done here, really.... } /* end of destructor */ @@ -78,7 +78,7 @@ CValue* KX_GameActuator::GetReplica() { KX_GameActuator* replica = new KX_GameActuator(*this); replica->ProcessReplica(); - + return replica; } @@ -138,10 +138,10 @@ bool KX_GameActuator::Update() char *marshal_buffer = NULL; unsigned int marshal_length; FILE *fp = NULL; - + pathGamePythonConfig(mashal_path); marshal_length = saveGamePythonConfig(&marshal_buffer); - + if (marshal_length && marshal_buffer) { fp = fopen(mashal_path, "wb"); if (fp) { @@ -171,9 +171,9 @@ bool KX_GameActuator::Update() int marshal_length; FILE *fp = NULL; int result; - + pathGamePythonConfig(mashal_path); - + fp = fopen(mashal_path, "rb"); if (fp) { // obtain file size: @@ -185,17 +185,17 @@ bool KX_GameActuator::Update() break; } rewind(fp); - + marshal_buffer = (char*) malloc (sizeof(char)*marshal_length); - + result = fread (marshal_buffer, 1, marshal_length, fp); - + if (result == marshal_length) { loadGamePythonConfig(marshal_buffer, marshal_length); } else { printf("warning: could not read all of '%s'\n", mashal_path); } - + free(marshal_buffer); fclose(fp); } else { @@ -219,7 +219,7 @@ bool KX_GameActuator::Update() default: ; /* do nothing? this is an internal error !!! */ } - + return false; } diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 57472836bb2..6a3f03ea6a6 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -75,7 +75,7 @@ protected: virtual CValue* GetReplica(); virtual bool Update(); - + virtual void Replace_IScene(SCA_IScene *val) { m_scene= val; @@ -84,7 +84,7 @@ protected: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + }; /* end of class KX_GameActuator */ #endif diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 3244400e1bd..a4dc5f5c4a2 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -124,8 +124,8 @@ KX_GameObject::KX_GameObject( m_pSGNode = new SG_Node(this,sgReplicationInfo,callbacks); // define the relationship between this node and it's parent. - - KX_NormalParentRelation * parent_relation = + + KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New(); m_pSGNode->SetParentRelation(parent_relation); }; @@ -209,7 +209,7 @@ KX_GameObject* KX_GameObject::GetClientObject(KX_ClientObjectInfo *info) return info->m_gameobject; } -CValue* KX_GameObject:: Calc(VALUE_OPERATOR op, CValue *val) +CValue* KX_GameObject:: Calc(VALUE_OPERATOR op, CValue *val) { return NULL; } @@ -255,12 +255,12 @@ PHY_IPhysicsController* KX_GameObject::GetPhysicsController() } KX_GameObject* KX_GameObject::GetDupliGroupObject() -{ +{ return m_pDupliGroupObject; } CListValue* KX_GameObject::GetInstanceObjects() -{ +{ return m_pInstanceObjects; } @@ -313,7 +313,7 @@ KX_GameObject* KX_GameObject::GetParent() { KX_GameObject* result = NULL; SG_Node* node = m_pSGNode; - + while (node && !result) { node = node->GetSGParent(); @@ -322,13 +322,13 @@ KX_GameObject* KX_GameObject::GetParent() } return result; - + } void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCompound, bool ghost) { // check on valid node in case a python controller holds a reference to a deleted object - if (obj && + if (obj && GetSGNode() && // object is not zombi obj->GetSGNode() && // object is not zombi GetSGNode()->GetSGParent() != obj->GetSGNode() && // not already parented to same object @@ -377,7 +377,7 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom // step 1: find the top parent (not necessarily obj) KX_GameObject* rootobj = (KX_GameObject*)obj->GetSGNode()->GetRootSGParent()->GetSGClientObject(); // step 2: verify it has a physical controller and compound shape - if (rootobj != NULL && + if (rootobj != NULL && rootobj->m_pPhysicsController != NULL && rootobj->m_pPhysicsController->IsCompound()) { @@ -395,7 +395,7 @@ void KX_GameObject::RemoveParent(KX_Scene *scene) { // get the root object to remove us from compound object if needed KX_GameObject* rootobj = (KX_GameObject*)GetSGNode()->GetRootSGParent()->GetSGClientObject(); - // Set us to the right spot + // Set us to the right spot GetSGNode()->SetLocalScale(GetSGNode()->GetWorldScaling()); GetSGNode()->SetLocalOrientation(GetSGNode()->GetWorldOrientation()); GetSGNode()->SetLocalPosition(GetSGNode()->GetWorldPosition()); @@ -411,7 +411,7 @@ void KX_GameObject::RemoveParent(KX_Scene *scene) if (m_pPhysicsController) { // in case this controller was added as a child shape to the parent - if (rootobj != NULL && + if (rootobj != NULL && rootobj->m_pPhysicsController != NULL && rootobj->m_pPhysicsController->IsCompound()) { @@ -540,7 +540,7 @@ void KX_GameObject::ProcessReplica() if (m_attr_dict) m_attr_dict= PyDict_Copy(m_attr_dict); #endif - + } static void setGraphicController_recursive(SG_Node* node) @@ -553,7 +553,7 @@ static void setGraphicController_recursive(SG_Node* node) KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject()); if (clientgameobj != NULL) // This is a GameObject clientgameobj->ActivateGraphicController(false); - + // if the childobj is NULL then this may be an inverse parent link // so a non recursive search should still look down this node. setGraphicController_recursive(childnode); @@ -670,7 +670,7 @@ void KX_GameObject::ApplyTorque(const MT_Vector3& torque,bool local) void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local) { - if (GetSGNode()) + if (GetSGNode()) { if (m_pPhysicsController) // (IsDynamic()) { @@ -685,7 +685,7 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local) void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local) { MT_Matrix3x3 rotmat(drot); - + if (GetSGNode()) { GetSGNode()->RelativeRotate(rotmat,local); @@ -706,10 +706,10 @@ float *KX_GameObject::GetOpenGLMatrix() float *fl = m_OpenGL_4x4Matrix.getPointer(); if (GetSGNode()) { MT_Transform trans; - + trans.setOrigin(GetSGNode()->GetWorldPosition()); trans.setBasis(GetSGNode()->GetWorldOrientation()); - + MT_Vector3 scaling = GetSGNode()->GetWorldScaling(); m_bIsNegativeScaling = ((scaling[0] < 0.0f) ^ (scaling[1] < 0.0f) ^ (scaling[2] < 0.0f)) ? true : false; trans.scale(scaling[0], scaling[1], scaling[2]); @@ -763,7 +763,7 @@ static void UpdateBuckets_recursive(SG_Node* node) KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject()); if (clientgameobj != NULL) // This is a GameObject clientgameobj->UpdateBuckets(0); - + // if the childobj is NULL then this may be an inverse parent link // so a non recursive search should still look down this node. UpdateBuckets_recursive(childnode); @@ -786,15 +786,15 @@ void KX_GameObject::UpdateBuckets( bool recursive ) ms->m_RGBAcolor = m_objectColor; ms->m_bVisible = m_bVisible; ms->m_bCulled = m_bCulled || !m_bVisible; - if (!ms->m_bCulled) + if (!ms->m_bCulled) ms->m_bucket->ActivateMesh(ms); - + /* split if necessary */ #ifdef USE_SPLIT ms->Split(); #endif } - + if (recursive) { UpdateBuckets_recursive(GetSGNode()); } @@ -823,7 +823,7 @@ static float calcHysteresis(KX_Scene *kxscene, LodLevel *lod) if (!kxscene->IsActivedLodHysteresis()) return hystvariance; - + short hysteresis = 0; // if exists, LoD level hysteresis will override scene hysteresis if (lod->next->flags & OB_LOD_USE_HYST) @@ -944,12 +944,12 @@ void KX_GameObject::InitIPO(bool ipo_as_force, (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, ipo_local); it++; } -} +} void KX_GameObject::UpdateIPO(float curframetime, - bool recurse) + bool recurse) { - /* This function shouldn't call BL_Action::Update, not even indirectly, + /* This function shouldn't call BL_Action::Update, not even indirectly, * as it will cause deadlock due to the lock in BL_Action::Update. */ // just the 'normal' update procedure. @@ -959,7 +959,7 @@ void KX_GameObject::UpdateIPO(float curframetime, } // IPO update -void +void KX_GameObject::UpdateMaterialData( dword matname_hash, MT_Vector4 rgba, @@ -983,7 +983,7 @@ KX_GameObject::UpdateMaterialData( if (poly->GetFlag() & RAS_BLENDERMAT ) { KX_BlenderMaterial *m = static_cast<KX_BlenderMaterial*>(poly); - + if (matname_hash == 0) { m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); @@ -996,7 +996,7 @@ KX_GameObject::UpdateMaterialData( { m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); m_meshes[mesh]->SetVertexColor(poly,rgba); - + // no break here, because one blender material can be split into several game engine materials // (e.g. one uvsphere material is split into one material at poles with ras_mode TRIANGLE and one material for the body // if here was a break then would miss some vertices if material was split @@ -1024,7 +1024,7 @@ static void setVisible_recursive(SG_Node* node, bool v) KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject()); if (clientgameobj != NULL) // This is a GameObject clientgameobj->SetVisible(v, 0); - + // if the childobj is NULL then this may be an inverse parent link // so a non recursive search should still look down this node. setVisible_recursive(childnode, v); @@ -1057,7 +1057,7 @@ static void setOccluder_recursive(SG_Node* node, bool v) KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject()); if (clientgameobj != NULL) // This is a GameObject clientgameobj->SetOccluder(v, false); - + // if the childobj is NULL then this may be an inverse parent link // so a non recursive search should still look down this node. setOccluder_recursive(childnode, v); @@ -1203,11 +1203,11 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) cout << "alignAxisToVect() Error: Null vector!\n"; return; } - + if (fac <= 0.0f) { return; } - + // normalize vect /= len; orimat = GetSGNode()->GetWorldOrientation(); @@ -1277,7 +1277,7 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) if (GetSGNode()->GetSGParent() != NULL) { - // the object is a child, adapt its local orientation so that + // the object is a child, adapt its local orientation so that // the global orientation is aligned as we want (cancelling out the parent orientation) MT_Matrix3x3 invori = GetSGNode()->GetSGParent()->GetWorldOrientation().inverse(); NodeSetLocalOrientation(invori*orimat); @@ -1313,11 +1313,11 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) if (m_pPhysicsController) { velocity = m_pPhysicsController->GetLinearVelocity(); - + if (local) { ori = GetSGNode()->GetWorldOrientation(); - + locvel = velocity * ori; return locvel; } @@ -1332,11 +1332,11 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) if (m_pPhysicsController) { velocity = m_pPhysicsController->GetAngularVelocity(); - + if (local) { ori = GetSGNode()->GetWorldOrientation(); - + locvel = velocity * ori; return locvel; } @@ -1426,7 +1426,7 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale) if (m_pPhysicsController && (!GetSGNode()->GetSGParent())) { // see note above - // we can use the local scale: it's the same thing for a root object + // we can use the local scale: it's the same thing for a root object // and the world scale is not yet updated MT_Vector3 newscale = GetSGNode()->GetLocalScale(); m_pPhysicsController->SetScaling(newscale); @@ -1446,8 +1446,8 @@ void KX_GameObject::NodeSetWorldScale(const MT_Vector3& scale) if (fabs(p_scale[0]) < (MT_Scalar)FLT_EPSILON || fabs(p_scale[1]) < (MT_Scalar)FLT_EPSILON || fabs(p_scale[2]) < (MT_Scalar)FLT_EPSILON) - { - return; + { + return; } p_scale[0] = 1/p_scale[0]; @@ -1474,8 +1474,8 @@ void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans) if (fabs(scale[0]) < (MT_Scalar)FLT_EPSILON || fabs(scale[1]) < (MT_Scalar)FLT_EPSILON || fabs(scale[2]) < (MT_Scalar)FLT_EPSILON) - { - return; + { + return; } scale[0] = 1.0f/scale[0]; scale[1] = 1.0f/scale[1]; @@ -1650,7 +1650,7 @@ static void walk_children(SG_Node* node, CListValue* list, bool recursive) // add to the list list->Add(childobj->AddRef()); } - + // if the childobj is NULL then this may be an inverse parent link // so a non recursive search should still look down this node. if (recursive || childobj==NULL) { @@ -1726,7 +1726,7 @@ static int mathutils_kxgameob_generic_check(BaseMathObject *bmo) KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); if (self == NULL) return -1; - + return 0; } @@ -1774,11 +1774,11 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype) if (!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1; self->GetAngularVelocity(false).getValue(bmo->data); break; - + } - + #undef PHYS_ERR - + return 0; } @@ -1787,7 +1787,7 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype) KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); if (self == NULL) return -1; - + switch (subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeSetLocalPosition(MT_Point3(bmo->data)); @@ -1823,7 +1823,7 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype) self->setAngularVelocity(MT_Point3(bmo->data),false); break; } - + return 0; } @@ -1838,11 +1838,11 @@ static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype, int index) { float f= bmo->data[index]; - + /* lazy, avoid repeteing the case statement */ if (mathutils_kxgameob_vector_get(bmo, subtype) == -1) return -1; - + bmo->data[index] = f; return mathutils_kxgameob_vector_set(bmo, subtype); } @@ -1875,7 +1875,7 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype) self->NodeGetWorldOrientation().getValue3x3(bmo->data); break; } - + return 0; } @@ -1885,7 +1885,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype) KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); if (self == NULL) return -1; - + MT_Matrix3x3 mat3x3; switch (subtype) { case MATHUTILS_MAT_CB_ORI_LOCAL: @@ -1899,7 +1899,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype) self->NodeUpdateGS(0.f); break; } - + return 0; } @@ -1954,7 +1954,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_VARARGS}, {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS}, {"reinstancePhysicsMesh", (PyCFunction)KX_GameObject::sPyReinstancePhysicsMesh,METH_VARARGS}, - + KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), KX_PYMETHODTABLE_O(KX_GameObject, getDistanceTo), @@ -1968,10 +1968,10 @@ PyMethodDef KX_GameObject::Methods[] = { KX_PYMETHODTABLE(KX_GameObject, getActionName), KX_PYMETHODTABLE(KX_GameObject, setActionFrame), KX_PYMETHODTABLE(KX_GameObject, isPlayingAction), - + // dict style access for props {"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS}, - + {NULL,NULL} //Sentinel }; @@ -2024,7 +2024,7 @@ PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("color", KX_GameObject, pyattr_get_obcolor, pyattr_set_obcolor), KX_PYATTRIBUTE_RW_FUNCTION("debug", KX_GameObject, pyattr_get_debug, pyattr_set_debug), KX_PYATTRIBUTE_RW_FUNCTION("debugRecursive", KX_GameObject, pyattr_get_debugRecursive, pyattr_set_debugRecursive), - + /* experimental, don't rely on these yet */ KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors), KX_PYATTRIBUTE_RO_FUNCTION("controllers", KX_GameObject, pyattr_get_controllers), @@ -2040,13 +2040,13 @@ PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) PyObject *value; int use_gfx= 1, use_phys= 0; RAS_MeshObject *new_mesh; - + if (!PyArg_ParseTuple(args,"O|ii:replaceMesh", &value, &use_gfx, &use_phys)) return NULL; - + if (!ConvertPythonToMesh(logicmgr, value, &new_mesh, false, "gameOb.replaceMesh(value): KX_GameObject")) return NULL; - + scene->ReplaceMesh(this, new_mesh, (bool)use_gfx, (bool)use_phys); Py_RETURN_NONE; } @@ -2054,9 +2054,9 @@ PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) PyObject *KX_GameObject::PyEndObject() { KX_Scene* scene = GetScene(); - + scene->DelayedRemoveObject(this); - + Py_RETURN_NONE; } @@ -2066,12 +2066,12 @@ PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args) KX_GameObject *gameobj= NULL; RAS_MeshObject *mesh= NULL; SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); - + PyObject *gameobj_py= NULL; PyObject *mesh_py= NULL; if ( !PyArg_ParseTuple(args,"|OO:reinstancePhysicsMesh",&gameobj_py, &mesh_py) || - (gameobj_py && !ConvertPythonToGameObject(logicmgr, gameobj_py, &gameobj, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) || + (gameobj_py && !ConvertPythonToGameObject(logicmgr, gameobj_py, &gameobj, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) || (mesh_py && !ConvertPythonToMesh(logicmgr, mesh_py, &mesh, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) ) { return NULL; @@ -2090,12 +2090,12 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) const char *attr_str= _PyUnicode_AsString(item); CValue* resultattr; PyObject *pyconvert; - + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, " BGE_PROXY_ERROR_MSG); return NULL; } - + /* first see if the attributes a string and try get the cvalue attribute */ if (attr_str && (resultattr=self->GetProperty(attr_str))) { pyconvert = resultattr->ConvertValueToPython(); @@ -2103,7 +2103,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) } /* no CValue attribute, try get the python only m_attr_dict attribute */ else if (self->m_attr_dict && (pyconvert=PyDict_GetItem(self->m_attr_dict, item))) { - + if (attr_str) PyErr_Clear(); Py_INCREF(pyconvert); @@ -2114,7 +2114,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) else PyErr_SetString(PyExc_KeyError, "value = gameOb[key]: KX_GameObject, key does not exist"); return NULL; } - + } @@ -2124,22 +2124,22 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) const char *attr_str= _PyUnicode_AsString(key); if (attr_str==NULL) PyErr_Clear(); - + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "gameOb[key] = value: KX_GameObject, " BGE_PROXY_ERROR_MSG); return -1; } - + if (val==NULL) { /* del ob["key"] */ int del= 0; - + /* try remove both just in case */ if (attr_str) del |= (self->RemoveProperty(attr_str)==true) ? 1:0; - + if (self->m_attr_dict) del |= (PyDict_DelItem(self->m_attr_dict, key)==0) ? 1:0; - + if (del==0) { if (attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" could not be set", attr_str); else PyErr_SetString(PyExc_KeyError, "del gameOb[key]: KX_GameObject, key could not be deleted"); @@ -2151,23 +2151,23 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) } else { /* ob["key"] = value */ bool set = false; - + /* as CValue */ if (attr_str && PyObject_TypeCheck(val, &PyObjectPlus::Type)==0) /* don't allow GameObjects for eg to be assigned to CValue props */ { CValue *vallie = self->ConvertPythonToValue(val, false, "gameOb[key] = value: "); - + if (vallie) { CValue* oldprop = self->GetProperty(attr_str); - + if (oldprop) oldprop->SetValue(vallie); else self->SetProperty(attr_str, vallie); - + vallie->Release(); set = true; - + /* try remove dict value to avoid double ups */ if (self->m_attr_dict) { if (PyDict_DelItem(self->m_attr_dict, key) != 0) @@ -2178,12 +2178,12 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) return -1; } } - + if (set == false) { if (self->m_attr_dict==NULL) /* lazy init */ self->m_attr_dict= PyDict_New(); - - + + if (PyDict_SetItem(self->m_attr_dict, key, val)==0) { if (attr_str) @@ -2195,31 +2195,31 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) else PyErr_SetString(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key not be added to internal dictionary"); } } - + if (set == false) { return -1; /* pythons error value */ } - + } - + return 0; /* success */ } static int Seq_Contains(PyObject *self_v, PyObject *value) { KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); - + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val in gameOb: KX_GameObject, " BGE_PROXY_ERROR_MSG); return -1; } - + if (PyUnicode_Check(value) && self->GetProperty(_PyUnicode_AsString(value))) return 1; - + if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value)) return 1; - + return 0; } @@ -2622,7 +2622,7 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D MT_Point3 pos; if (!PyVecTo(value, pos)) return PY_SET_ATTR_FAIL; - + self->NodeSetWorldPosition(pos); self->NodeUpdateGS(0.f); return PY_SET_ATTR_SUCCESS; @@ -2646,7 +2646,7 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D MT_Point3 pos; if (!PyVecTo(value, pos)) return PY_SET_ATTR_FAIL; - + self->NodeSetLocalPosition(pos); self->NodeUpdateGS(0.f); return PY_SET_ATTR_SUCCESS; @@ -2681,14 +2681,14 @@ PyObject *KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYAT int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); - + /* if value is not a sequence PyOrientationTo makes an error */ MT_Matrix3x3 rot; if (!PyOrientationTo(value, rot, "gameOb.worldOrientation = sequence: KX_GameObject, ")) return PY_SET_ATTR_FAIL; self->NodeSetGlobalOrientation(rot); - + self->NodeUpdateGS(0.f); return PY_SET_ATTR_SUCCESS; } @@ -2708,7 +2708,7 @@ PyObject *KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYAT int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); - + /* if value is not a sequence PyOrientationTo makes an error */ MT_Matrix3x3 rot; if (!PyOrientationTo(value, rot, "gameOb.localOrientation = sequence: KX_GameObject, ")) @@ -2774,10 +2774,10 @@ PyObject *KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTR float mat[16]; MT_Transform trans; - + trans.setOrigin(self->GetSGNode()->GetLocalPosition()); trans.setBasis(self->GetSGNode()->GetLocalOrientation()); - + MT_Vector3 scaling = self->GetSGNode()->GetLocalScale(); trans.scale(scaling[0], scaling[1], scaling[2]); @@ -3012,12 +3012,12 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr KX_GameObject* self = static_cast<KX_GameObject*>(self_v); int state_i = PyLong_AsLong(value); unsigned int state = 0; - + if (state_i == -1 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "gameOb.state = int: KX_GameObject, expected an int bit field"); return PY_SET_ATTR_FAIL; } - + state |= state_i; if ((state & ((1<<30)-1)) == 0) { PyErr_SetString(PyExc_AttributeError, "gameOb.state = int: KX_GameObject, state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); @@ -3032,13 +3032,13 @@ PyObject *KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PyObject *meshes= PyList_New(self->m_meshes.size()); int i; - + for (i=0; i < (int)self->m_meshes.size(); i++) { KX_MeshProxy* meshproxy = new KX_MeshProxy(self->m_meshes[i]); PyList_SET_ITEM(meshes, i, meshproxy->NewProxy(true)); } - + return meshes; } @@ -3160,10 +3160,10 @@ PyObject *KX_GameObject::pyattr_get_children_recursive(void *self_v, const KX_PY PyObject *KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); - + if (self->m_attr_dict==NULL) self->m_attr_dict= PyDict_New(); - + Py_INCREF(self->m_attr_dict); return self->m_attr_dict; } @@ -3292,7 +3292,7 @@ PyObject *KX_GameObject::PySetLinearVelocity(PyObject *args) { int local = 0; PyObject *pyvect; - + if (PyArg_ParseTuple(args,"O|i:setLinearVelocity",&pyvect,&local)) { MT_Vector3 velocity; if (PyVecTo(pyvect, velocity)) { @@ -3321,7 +3321,7 @@ PyObject *KX_GameObject::PySetAngularVelocity(PyObject *args) { int local = 0; PyObject *pyvect; - + if (PyArg_ParseTuple(args,"O|i:setAngularVelocity",&pyvect,&local)) { MT_Vector3 velocity; if (PyVecTo(pyvect, velocity)) { @@ -3349,11 +3349,11 @@ PyObject *KX_GameObject::PySetVisible(PyObject *args) int visible, recursive = 0; if (!PyArg_ParseTuple(args,"i|i:setVisible",&visible, &recursive)) return NULL; - + SetVisible(visible ? true:false, recursive ? true:false); UpdateBuckets(recursive ? true:false); Py_RETURN_NONE; - + } PyObject *KX_GameObject::PySetOcclusion(PyObject *args) @@ -3361,7 +3361,7 @@ PyObject *KX_GameObject::PySetOcclusion(PyObject *args) int occlusion, recursive = 0; if (!PyArg_ParseTuple(args,"i|i:setOcclusion",&occlusion, &recursive)) return NULL; - + SetOccluder(occlusion ? true:false, recursive ? true:false); Py_RETURN_NONE; } @@ -3371,7 +3371,7 @@ PyObject *KX_GameObject::PyGetVelocity(PyObject *args) // only can get the velocity if we have a physics object connected to us... MT_Point3 point(0.0f,0.0f,0.0f); PyObject *pypos = NULL; - + if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point))) return NULL; @@ -3381,16 +3381,16 @@ PyObject *KX_GameObject::PyGetVelocity(PyObject *args) PyObject *KX_GameObject::PyGetReactionForce() { // only can get the velocity if we have a physics object connected to us... - + // XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce #if 0 if (GetPhysicsController1()) return PyObjectFrom(GetPhysicsController1()->getReactionForce()); return PyObjectFrom(dummy_point); #endif - + return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); - + } @@ -3421,7 +3421,7 @@ PyObject *KX_GameObject::PySetParent(PyObject *args) PyObject *pyobj; KX_GameObject *obj; int addToCompound=1, ghost=1; - + if (!PyArg_ParseTuple(args,"O|ii:setParent", &pyobj, &addToCompound, &ghost)) { return NULL; // Python sets a simple error } @@ -3435,7 +3435,7 @@ PyObject *KX_GameObject::PySetParent(PyObject *args) PyObject *KX_GameObject::PyRemoveParent() { KX_Scene *scene = KX_GetActiveScene(); - + this->RemoveParent(scene); Py_RETURN_NONE; } @@ -3444,12 +3444,12 @@ PyObject *KX_GameObject::PyRemoveParent() PyObject *KX_GameObject::PySetCollisionMargin(PyObject *value) { float collisionMargin = PyFloat_AsDouble(value); - + if (collisionMargin==-1 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "expected a float"); return NULL; } - + if (m_pPhysicsController) { m_pPhysicsController->SetMargin(collisionMargin); @@ -3466,12 +3466,12 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) PyObject *pyattach; PyObject *pyimpulse; int local = 0; - + if (!m_pPhysicsController) { PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); return NULL; } - + if (PyArg_ParseTuple(args, "OO|i:applyImpulse", &pyattach, &pyimpulse, &local)) { MT_Point3 attach; @@ -3483,7 +3483,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) } } - + return NULL; } @@ -3518,7 +3518,7 @@ PyObject *KX_GameObject::PyAlignAxisToVect(PyObject *args) PyObject *pyvect; int axis = 2; //z axis is the default float fac = 1.0f; - + if (PyArg_ParseTuple(args,"O|if:alignAxisToVect",&pyvect,&axis, &fac)) { MT_Vector3 vect; @@ -3560,7 +3560,7 @@ PyObject *KX_GameObject::PyGetPhysicsId() PyObject *KX_GameObject::PyGetPropertyNames() { PyObject *list= ConvertKeysToPython(); - + if (m_attr_dict) { PyObject *key, *value; Py_ssize_t pos = 0; @@ -3588,7 +3588,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getDistanceTo, { return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition())); } - + return NULL; } @@ -3606,7 +3606,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, if (!PyVecTo(value, toPoint)) { PyErr_Clear(); - + KX_GameObject *other; if (ConvertPythonToGameObject(logicmgr, value, &other, false, "")) /* error will be overwritten */ { @@ -3631,7 +3631,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, toDir.normalize(); locToDir = toDir * NodeGetWorldOrientation(); } - + returnValue = PyTuple_New(3); if (returnValue) { // very unlikely to fail, python sets a memory error here. PyTuple_SET_ITEM(returnValue, 0, PyFloat_FromDouble(distance)); @@ -3663,7 +3663,7 @@ bool KX_GameObject::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, RayC // if X-ray option is selected, the unwnted objects were not tested, so get here only with true hit // if not, all objects were tested and the front one may not be the correct one. - if ((rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && + if ((rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && hitKXObj->GetUserCollisionGroup() & rayData->m_mask) { rayData->m_hitObject = hitKXObj; @@ -3688,10 +3688,10 @@ bool KX_GameObject::NeedRayCast(KX_ClientObjectInfo *client, RayCastData *rayDat printf("Invalid client type %d found in ray casting\n", client->m_type); return false; } - + // if X-Ray option is selected, skip object that don't match the criteria as we see through them // if not, test all objects because we don't know yet which one will be on front - if ((!rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && + if ((!rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && hitKXObj->GetUserCollisionGroup() & rayData->m_mask) { return true; @@ -3720,7 +3720,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, { KX_GameObject *other; PyErr_Clear(); - + if (ConvertPythonToGameObject(logicmgr, pyarg, &other, false, "")) /* error will be overwritten */ { toPoint = other->NodeGetWorldPosition(); @@ -3731,10 +3731,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, } } MT_Point3 fromPoint = NodeGetWorldPosition(); - + if (dist != 0.0f) toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized(); - + PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); PHY_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); @@ -3746,7 +3746,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { return rayData.m_hitObject->GetProxy(); } - + Py_RETURN_NONE; } @@ -3757,7 +3757,7 @@ static PyObject *none_tuple_3() PyTuple_SET_ITEM(ret, 0, Py_None); PyTuple_SET_ITEM(ret, 1, Py_None); PyTuple_SET_ITEM(ret, 2, Py_None); - + Py_INCREF(Py_None); Py_INCREF(Py_None); Py_INCREF(Py_None); @@ -3770,7 +3770,7 @@ static PyObject *none_tuple_4() PyTuple_SET_ITEM(ret, 1, Py_None); PyTuple_SET_ITEM(ret, 2, Py_None); PyTuple_SET_ITEM(ret, 3, Py_None); - + Py_INCREF(Py_None); Py_INCREF(Py_None); Py_INCREF(Py_None); @@ -3786,7 +3786,7 @@ static PyObject *none_tuple_5() PyTuple_SET_ITEM(ret, 2, Py_None); PyTuple_SET_ITEM(ret, 3, Py_None); PyTuple_SET_ITEM(ret, 4, Py_None); - + Py_INCREF(Py_None); Py_INCREF(Py_None); Py_INCREF(Py_None); @@ -3836,7 +3836,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, if (!PyVecTo(pyto, toPoint)) { PyErr_Clear(); - + if (ConvertPythonToGameObject(logicmgr, pyto, &other, false, "")) /* error will be overwritten */ { toPoint = other->NodeGetWorldPosition(); @@ -3853,7 +3853,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, else if (!PyVecTo(pyfrom, fromPoint)) { PyErr_Clear(); - + if (ConvertPythonToGameObject(logicmgr, pyfrom, &other, false, "")) /* error will be overwritten */ { fromPoint = other->NodeGetWorldPosition(); @@ -3881,7 +3881,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, //return Py_BuildValue("OOO", Py_None, Py_None, Py_None); return none_tuple_3(); } - + PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); PHY_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); @@ -3939,7 +3939,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, return none_tuple_3(); } -KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, +KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, "sendMessage(subject, [body, to])\n" "sends a message in same manner as a message actuator" "subject = Subject of the message (string)" @@ -3954,7 +3954,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, if (!PyArg_ParseTuple(args, "s|ss:sendMessage", &subject, &body, &to)) return NULL; - + scene->GetNetworkScene()->SendMessage(to, from, subject, body); Py_RETURN_NONE; } @@ -4121,8 +4121,8 @@ PyObject *KX_GameObject::Pyget(PyObject *args) if (!PyArg_ParseTuple(args, "O|O:get", &key, &def)) return NULL; - - + + if (PyUnicode_Check(key)) { CValue *item = GetProperty(_PyUnicode_AsString(key)); if (item) { @@ -4133,12 +4133,12 @@ PyObject *KX_GameObject::Pyget(PyObject *args) return item->GetProxy(); } } - + if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) { Py_INCREF(ret); return ret; } - + Py_INCREF(def); return def; } @@ -4150,10 +4150,10 @@ bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_Ga *object = NULL; return false; } - + if (value==Py_None) { *object = NULL; - + if (py_none_ok) { return true; } else { @@ -4161,10 +4161,10 @@ bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_Ga return false; } } - + if (PyUnicode_Check(value)) { *object = (KX_GameObject*)manager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) )); - + if (*object) { return true; } else { @@ -4172,7 +4172,7 @@ bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_Ga return false; } } - + if (PyObject_TypeCheck(value, &KX_GameObject::Type) || PyObject_TypeCheck(value, &KX_LightObject::Type) || PyObject_TypeCheck(value, &KX_Camera::Type) || @@ -4180,24 +4180,24 @@ bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_Ga PyObject_TypeCheck(value, &KX_NavMeshObject::Type)) { *object = static_cast<KX_GameObject*>BGE_PROXY_REF(value); - + /* sets the error */ if (*object==NULL) { PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix); return false; } - + return true; } - + *object = NULL; - + if (py_none_ok) { PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject, a string or None", error_prefix); } else { PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject or a string", error_prefix); } - + return false; } #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 9c582d3e27a..7a8243eb43d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -36,7 +36,7 @@ #ifdef _MSC_VER /* get rid of this stupid "warning 'this' used in initialiser list", generated by VC when including Solid/Sumo */ # pragma warning (disable:4355) -#endif +#endif #include <stddef.h> @@ -91,10 +91,10 @@ protected: std::vector<RAS_MeshObject*> m_lodmeshes; int m_currentLodLevel; short m_previousLodLevel; - SG_QList m_meshSlots; // head of mesh slots of this + SG_QList m_meshSlots; // head of mesh slots of this struct Object* m_pBlenderObject; struct Object* m_pBlenderGroupObject; - + bool m_bUseObjectColor; bool m_bIsNegativeScaling; MT_Vector4 m_objectColor; @@ -105,8 +105,8 @@ protected: // visible = user setting // culled = while rendering, depending on camera - bool m_bVisible; - bool m_bCulled; + bool m_bVisible; + bool m_bCulled; bool m_bOccluder; PHY_IPhysicsController* m_pPhysicsController; @@ -126,7 +126,7 @@ protected: BL_ActionManager* m_actionManager; BL_ActionManager* GetActionManager(); - + bool m_bRecordAnimation; public: @@ -135,7 +135,7 @@ public: /** * KX_GameObject custom infos for ray cast, it contains property name, * collision mask, xray flag and hited object. - * This structure is created during ray cast and passed as argument + * This structure is created during ray cast and passed as argument * "data" to functions KX_GameObject::NeedRayCast and KX_GameObject::RayHit. */ struct RayCastData; @@ -174,21 +174,21 @@ public: * Compute an OpenGl compatible 4x4 matrix. Has the * side effect of storing the result internally. The * memory for the matrix remains the property of this class. - */ + */ float * GetOpenGLMatrix( ); /** - * Return a pointer to a MT_CmMatrix4x4 storing the + * Return a pointer to a MT_CmMatrix4x4 storing the * opengl transformation for this object. This is updated - * by a call to GetOpenGLMatrix(). This class owns the + * by a call to GetOpenGLMatrix(). This class owns the * memory for the returned matrix. */ MT_CmMatrix4x4 * GetOpenGLMatrixPtr( - ) { + ) { return &m_OpenGL_4x4Matrix; }; @@ -209,11 +209,11 @@ public: std::vector<bRigidBodyJointConstraint*> GetConstraints(); void ClearConstraints(); - /** - * Get a pointer to the game object that is the parent of + /** + * Get a pointer to the game object that is the parent of * this object. Or NULL if there is no parent. The returned * object is part of a reference counting scheme. Calling - * this function ups the reference count on the returned + * this function ups the reference count on the returned * object. It is the responsibility of the caller to decrement * the reference count when you have finished with it. */ @@ -221,12 +221,12 @@ public: GetParent( ); - /** + /** * Sets the parent of this object to a game object */ void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true); - /** + /** * Removes the parent of this object to a game object */ void RemoveParent(KX_Scene *scene); @@ -250,8 +250,8 @@ public: void AddInstanceObjects(KX_GameObject* ); - - void + + void RemoveDupliGroupObject( ); @@ -332,7 +332,7 @@ public: *********************************/ /** - * Construct a game object. This class also inherits the + * Construct a game object. This class also inherits the * default constructors - use those with care! */ @@ -341,13 +341,13 @@ public: SG_Callbacks callbacks ); - virtual + virtual ~KX_GameObject( ); - /** + /** * \section Stuff which is here due to poor design. - * Inherited from CValue and needs an implementation. + * Inherited from CValue and needs an implementation. * Do not expect these functions do to anything sensible. */ @@ -373,7 +373,7 @@ public: /** * Inherited from CValue -- does nothing! */ - const + const STR_String & GetText( ); @@ -387,7 +387,7 @@ public: /** * \section Inherited from CValue. These are the useful - * part of the CValue interface that this class implements. + * part of the CValue interface that this class implements. */ /** @@ -405,35 +405,35 @@ public: const char *name ); - /** + /** * Inherited from CValue -- return a new copy of this - * instance allocated on the heap. Ownership of the new + * instance allocated on the heap. Ownership of the new * object belongs with the caller. */ virtual CValue* GetReplica( ); - + /** - * Inherited from CValue -- Makes sure any internal + * Inherited from CValue -- Makes sure any internal * data owned by this class is deep copied. Called internally */ virtual void ProcessReplica(); - /** + /** * Return the linear velocity of the game object. */ - MT_Vector3 + MT_Vector3 GetLinearVelocity( bool local=false ); - /** + /** * Return the linear velocity of a given point in world coordinate * but relative to center of object ([0,0,0]=center of object) */ - MT_Vector3 + MT_Vector3 GetVelocity( const MT_Point3& position ); @@ -450,25 +450,25 @@ public: MT_Vector3 GetLocalInertia(); - /** + /** * Return the angular velocity of the game object. */ - MT_Vector3 + MT_Vector3 GetAngularVelocity( bool local=false ); - /** + /** * Align the object to a given normal. */ - void + void AlignAxisToVect( const MT_Vector3& vect, int axis = 2, float fac = 1.0 ); - /** + /** * Quick'n'dirty obcolor ipo stuff */ @@ -481,7 +481,7 @@ public: GetObjectColor(); - void + void ResolveCombinedVelocities( const MT_Vector3 & lin_vel, const MT_Vector3 & ang_vel, @@ -496,7 +496,7 @@ public: PHY_IPhysicsController* GetPhysicsController(); void SetPhysicsController(PHY_IPhysicsController* physicscontroller,bool isDynamic) - { + { m_bDyna = isDynamic; m_pPhysicsController = physicscontroller; } @@ -511,15 +511,15 @@ public: } /** - * \return a pointer to the graphic controller owner by this class + * \return a pointer to the graphic controller owner by this class */ PHY_IGraphicController* GetGraphicController() { return m_pGraphicController; } - void SetGraphicController(PHY_IGraphicController* graphiccontroller) - { + void SetGraphicController(PHY_IGraphicController* graphiccontroller) + { m_pGraphicController = graphiccontroller; } /* @@ -577,13 +577,13 @@ public: * \section scene graph node accessor functions. */ - SG_Node* GetSGNode( ) - { + SG_Node* GetSGNode( ) + { return m_pSGNode; } const SG_Node* GetSGNode( ) const - { + { return m_pSGNode; } @@ -610,9 +610,9 @@ public: { m_pBlenderGroupObject = obj; } - + bool IsDupliGroup() - { + { return (m_pBlenderObject && (m_pBlenderObject->transflag & OB_DUPLIGROUP) && m_pBlenderObject->dup_group != NULL) ? true : false; @@ -627,14 +627,14 @@ public: * node. */ void SetSGNode(SG_Node* node ) - { - m_pSGNode = node; + { + m_pSGNode = node; } - + //Is it a dynamic/physics object ? - bool IsDynamic() const - { - return m_bDyna; + bool IsDynamic() const + { + return m_bDyna; } bool IsDynamicsSuspended() const; @@ -670,7 +670,7 @@ public: /** * \section Physics accessors for this node. * - * All these calls get passed directly to the physics controller + * All these calls get passed directly to the physics controller * owned by this object. * This is real interface bloat. Why not just use the physics controller * directly? I think this is because the python interface is in the wrong @@ -743,7 +743,7 @@ public: /** * Function to set IPO option at start of IPO - */ + */ void InitIPO( bool ipo_as_force, @@ -753,16 +753,16 @@ public: /** * Odd function to update an ipo. ??? - */ + */ void UpdateIPO( float curframetime, bool recurse ); /** - * Updates Material Ipo data + * Updates Material Ipo data */ - void + void UpdateMaterialData( dword matname_hash, MT_Vector4 rgba, @@ -785,7 +785,7 @@ public: void AddMeshUser( ); - + /** * Update buckets with data about the mesh after * creating or duplicating the object, changing @@ -841,8 +841,8 @@ public: RAS_MeshObject* GetMesh( int num - ) const { - return m_meshes[num]; + ) const { + return m_meshes[num]; } /** @@ -851,10 +851,10 @@ public: */ int GetMeshCount( - ) const { - return m_meshes.size(); + ) const { + return m_meshes.size(); } - + /** * Set the debug color of the meshes associated with this * class. Does this still work? @@ -864,7 +864,7 @@ public: unsigned int bgra ); - /** + /** * Reset the debug color of meshes associated with this class. */ void @@ -904,7 +904,7 @@ public: SetCulled( bool c ) { m_bCulled = c; } - + /** * Is this object an occluder? */ @@ -921,7 +921,7 @@ public: bool v, bool recursive ); - + /** * Change the layer of the object (when it is added in another layer * than the original layer) @@ -938,7 +938,7 @@ public: GetLayer( void ); - + /** * Get the negative scaling state */ @@ -973,14 +973,14 @@ public: { m_pObstacleSimulation = NULL; } - + /** * add debug object to the debuglist. */ void SetUseDebugProperties(bool debug, bool recursive); KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; } - + CListValue* GetChildren(); CListValue* GetChildrenRecursive(); @@ -1047,10 +1047,10 @@ public: KX_PYMETHOD_DOC(KX_GameObject, getActionName); KX_PYMETHOD_DOC(KX_GameObject, setActionFrame); KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction); - + /* Dict access */ KX_PYMETHOD_VARARGS(KX_GameObject,get); - + /* attributes */ static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); @@ -1130,7 +1130,7 @@ public: static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + /* getitem/setitem */ static PyMappingMethods Mapping; static PySequenceMethods Sequence; diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/Ketsji/KX_IInterpolator.h index 6c0bf2d85cc..66fc20fb8c8 100644 --- a/source/gameengine/Ketsji/KX_IInterpolator.h +++ b/source/gameengine/Ketsji/KX_IInterpolator.h @@ -41,8 +41,8 @@ class KX_IInterpolator { public: virtual ~KX_IInterpolator() {} - - virtual void Execute(float currentTime) const = 0; + + virtual void Execute(float currentTime) const = 0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Ketsji/KX_IPOTransform.h b/source/gameengine/Ketsji/KX_IPOTransform.h index a81c432b01e..bc52e1a27fd 100644 --- a/source/gameengine/Ketsji/KX_IPOTransform.h +++ b/source/gameengine/Ketsji/KX_IPOTransform.h @@ -59,16 +59,16 @@ public: const MT_Point3& GetPosition() const { return m_position; } const MT_Vector3& GetEulerAngles() const { return m_eulerAngles; } const MT_Vector3& GetScaling() const { return m_scaling; } - + MT_Vector3& GetDeltaPosition() { return m_deltaPosition; } MT_Vector3& GetDeltaEulerAngles() { return m_deltaEulerAngles; } MT_Vector3& GetDeltaScaling() { return m_deltaScaling; } - + void SetPosition(const MT_Point3& pos) { m_position = pos; } void SetEulerAngles(const MT_Vector3& eul) { m_eulerAngles = eul; } void SetScaling(const MT_Vector3& scaling) { m_scaling = scaling; } - - void ClearDeltaStuff() { + + void ClearDeltaStuff() { 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); diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index be1a4b4ef3a..2258572b563 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -50,7 +50,7 @@ typedef unsigned long uint_ptr; #include "DNA_ipo_types.h" #include "BLI_math.h" -// All objects should start on frame 1! Will we ever need an object to +// All objects should start on frame 1! Will we ever need an object to // start on another frame, the 1.0 should change. KX_IpoSGController::KX_IpoSGController() : m_ipo_as_force(false), @@ -145,7 +145,7 @@ bool KX_IpoSGController::Update(double currentTime) m_ipo_xform.GetPosition(); m_game_object->GetPhysicsController()->ApplyForce(vec, false); } - } + } else { // Local ipo should be defined with the object position at (0,0,0) // Local transform is applied to the object based on initial position @@ -231,8 +231,8 @@ bool KX_IpoSGController::Update(double currentTime) else if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z]) { if (m_ipo_euler_initialized) { // assume all channel absolute - // All 3 channels should be specified but if they are not, we will take - // the value at the start of the game to avoid angle sign reversal + // All 3 channels should be specified but if they are not, we will take + // the value at the start of the game to avoid angle sign reversal double yaw = m_ipo_start_euler[0], pitch = m_ipo_start_euler[1], roll = m_ipo_start_euler[2]; //RotX and dRotX @@ -250,7 +250,7 @@ bool KX_IpoSGController::Update(double currentTime) else if (m_ipo_channels_active[OB_DROT_Y]) { pitch += m_ipo_xform.GetDeltaEulerAngles()[1]; } - + //RotZ and dRotZ if (m_ipo_channels_active[OB_ROT_Z]) { roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] ); @@ -308,7 +308,7 @@ bool KX_IpoSGController::Update(double currentTime) else if (m_ipo_channels_active[OB_DSIZE_Y] && m_ipo_start_initialized) { newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + ((!m_ipo_add)?m_ipo_start_scale[1] : 0.0f)); } - + //RotZ and dRotZ if (m_ipo_channels_active[OB_SIZE_Z]) { newScale[2] = (m_ipo_channels_active[OB_DSIZE_Z] ? (m_ipo_xform.GetScaling()[2] + m_ipo_xform.GetDeltaScaling()[2]) : m_ipo_xform.GetScaling()[2]); diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 3318761bb88..67dd87468d3 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -56,7 +56,7 @@ class KX_IpoSGController : public SG_Controller /** Ipo must be applied in local coordinate rather than in global coordinates (used for force and Add mode)*/ bool m_ipo_local; - + /** Were settings altered since the last update? */ bool m_modified; diff --git a/source/gameengine/Ketsji/KX_IScalarInterpolator.h b/source/gameengine/Ketsji/KX_IScalarInterpolator.h index 1e822c49c6d..34d5bda3ec5 100644 --- a/source/gameengine/Ketsji/KX_IScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_IScalarInterpolator.h @@ -39,8 +39,8 @@ class KX_IScalarInterpolator { public: virtual ~KX_IScalarInterpolator() {} - - virtual float GetValue(float currentTime) const = 0; + + virtual float GetValue(float currentTime) const = 0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index 1963fc7c48f..11f412ade05 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -41,7 +41,7 @@ struct Scene; -class KX_ISceneConverter +class KX_ISceneConverter { public: @@ -93,8 +93,8 @@ public: virtual bool GetCacheMaterials()=0; virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0; - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ISceneConverter") #endif diff --git a/source/gameengine/Ketsji/KX_ISystem.h b/source/gameengine/Ketsji/KX_ISystem.h index 4ba71f8d239..95e10db0197 100644 --- a/source/gameengine/Ketsji/KX_ISystem.h +++ b/source/gameengine/Ketsji/KX_ISystem.h @@ -50,7 +50,7 @@ class KX_ISystem public: KX_ISystem() {}; virtual ~KX_ISystem() {}; - + virtual double GetTimeInSeconds()=0; diff --git a/source/gameengine/Ketsji/KX_IpoConvert.cpp b/source/gameengine/Ketsji/KX_IpoConvert.cpp index 7b00760ee7b..8611c57c863 100644 --- a/source/gameengine/Ketsji/KX_IpoConvert.cpp +++ b/source/gameengine/Ketsji/KX_IpoConvert.cpp @@ -79,7 +79,7 @@ static BL_InterpolatorList *GetAdtList(struct bAction *for_act, KX_BlenderSceneC adtList = new BL_InterpolatorList(for_act); converter->RegisterInterpolatorList(adtList, for_act); } - + return adtList; } @@ -112,13 +112,13 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B } BL_InterpolatorList *adtList= GetAdtList(action, converter); - + // For each active channel in the adtList add an // interpolator to the game object. - + KX_IInterpolator *interpolator; KX_IScalarInterpolator *interp; - + for (int i=0; i<3; i++) { if ((interp = adtList->GetScalarInterpolator("location", i))) { interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp); @@ -161,7 +161,7 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true); } } - + return ipocontr; } @@ -203,10 +203,10 @@ SG_Controller *BL_CreateLampIPO(struct bAction *action, KX_GameObject* lightobj // For each active channel in the adtList add an // interpolator to the game object. - + KX_IInterpolator *interpolator; KX_IScalarInterpolator *interp; - + if ((interp= adtList->GetScalarInterpolator("energy", 0))) { interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp); ipocontr->AddInterpolator(interpolator); @@ -218,7 +218,7 @@ SG_Controller *BL_CreateLampIPO(struct bAction *action, KX_GameObject* lightobj ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyDist(true); } - + for (int i=0; i<3; i++) { if ((interp = adtList->GetScalarInterpolator("color", i))) { interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp); @@ -244,10 +244,10 @@ SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* camera // For each active channel in the adtList add an // interpolator to the game object. - + KX_IInterpolator *interpolator; KX_IScalarInterpolator *interp; - + if ((interp = adtList->GetScalarInterpolator("lens", 0))) { interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp); ipocontr->AddInterpolator(interpolator); @@ -349,7 +349,7 @@ SG_Controller *BL_CreateMaterialIpo( struct bAction *action, Material* blendermaterial, dword matname_hash, - KX_GameObject* gameobj, + KX_GameObject* gameobj, KX_BlenderSceneConverter *converter ) { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index d82a0fd533b..355e63212ae 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -23,7 +23,7 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - * The engine ties all game modules together. + * The engine ties all game modules together. */ /** \file gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -123,9 +123,9 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_activecam(0), m_bFixedTime(false), m_useExternalClock(false), - + m_firstframe(true), - + m_frameTime(0.f), m_clockTime(0.f), m_previousClockTime(0.f), @@ -138,7 +138,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_exitstring(""), m_cameraZoom(1.0f), - + m_overrideCam(false), m_overrideCamUseOrtho(false), m_overrideCamNear(0.0f), @@ -149,7 +149,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_curreye(0), m_logger(NULL), - + // Set up timing info display variables m_show_framerate(false), m_show_profile(false), @@ -280,7 +280,7 @@ void KX_KetsjiEngine::InitDome(short res, short mode, short angle, float resbuf, void KX_KetsjiEngine::RenderDome() { const GLint *viewport = m_canvas->GetViewPort(); - + m_dome->SetViewPort(viewport); KX_Scene* firstscene = *m_scenes.begin(); @@ -327,17 +327,17 @@ void KX_KetsjiEngine::RenderDome() { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - + m_rasterizer->SetAuxilaryClientInfo(scene); - + // do the rendering m_dome->RenderDomeFrame(scene,cam, i); // render all the font objects for this scene scene->RenderFonts(); } - + list<class KX_Camera*>* cameras = scene->GetCameras(); - + // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); while (it != cameras->end()) { @@ -345,15 +345,15 @@ void KX_KetsjiEngine::RenderDome() { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - + m_rasterizer->SetAuxilaryClientInfo(scene); - + // do the rendering m_dome->RenderDomeFrame(scene, (*it),i); // render all the font objects for this scene scene->RenderFonts(); } - + it++; } // Part of PostRenderScene() @@ -427,7 +427,7 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo) m_maxLogicFrame = 5; m_maxPhysicsFrame = 5; } - + if (m_animation_record) { m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo); @@ -499,7 +499,7 @@ bool KX_KetsjiEngine::BeginFrame() return true; } - + return false; } @@ -542,7 +542,7 @@ void KX_KetsjiEngine::EndFrame() m_logger->StartLog(tc_latency, m_kxsystem->GetTimeInSeconds(), true); m_rasterizer->SwapBuffers(); m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true); - + m_canvas->EndDraw(); } @@ -576,7 +576,7 @@ bool KX_KetsjiEngine::NextFrame() * 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 + * - ticrate * - max_physic_frame * - max_logic_frame * XXX The logic over computation framestep is definitively not clear (and @@ -599,7 +599,7 @@ bool KX_KetsjiEngine::NextFrame() m_clockTime += dt * m_timescale; } } - + double deltatime = m_clockTime - m_frameTime; if (deltatime<0.0) { @@ -613,19 +613,19 @@ bool KX_KetsjiEngine::NextFrame() // 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) { - + // printf("framedOut: %d\n",frames); m_frameTime+=(frames-m_maxPhysicsFrame)*timestep; frames = m_maxPhysicsFrame; } - + bool doRender = frames>0; @@ -637,17 +637,17 @@ bool KX_KetsjiEngine::NextFrame() while (frames) { - + m_frameTime += framestep; - + m_sceneconverter->MergeAsyncLoads(); for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit) // for each scene, call the proceed functions { KX_Scene* scene = *sceneit; - + /* Suspension holds the physics and logic processing for an * entire scene. Objects can be suspended individually, and * the settings for that precede the logic and physics @@ -657,7 +657,7 @@ bool KX_KetsjiEngine::NextFrame() m_sceneconverter->resetNoneDynamicObjectToIpo(); // this is for none dynamic objects with ipo scene->UpdateObjectActivity(); - + if (!scene->IsSuspended()) { // if the scene was suspended recalculate the delta tu "curtime" @@ -666,15 +666,15 @@ bool KX_KetsjiEngine::NextFrame() scene->setSuspendedDelta(scene->getSuspendedDelta()+m_clockTime-scene->getSuspendedTime()); m_suspendeddelta = scene->getSuspendedDelta(); - + m_logger->StartLog(tc_network, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_NETWORK); scene->GetNetworkScene()->proceed(m_frameTime); - + //m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); //SG_SetActiveStage(SG_STAGE_NETWORK_UPDATE); //scene->UpdateParents(m_frameTime); - + m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS1); // set Python hooks for each scene @@ -682,35 +682,35 @@ bool KX_KetsjiEngine::NextFrame() PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment()); #endif KX_SetActiveScene(scene); - + scene->GetPhysicsEnvironment()->EndFrame(); - + // Update scenegraph after physics step. This maps physics calculations // into node positions. //m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); //SG_SetActiveStage(SG_STAGE_PHYSICS1_UPDATE); //scene->UpdateParents(m_frameTime); - + // Process sensors, and controllers m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_CONTROLLER); scene->LogicBeginFrame(m_frameTime); - - // Scenegraph needs to be updated again, because Logic Controllers + + // Scenegraph needs to be updated again, because Logic Controllers // can affect the local matrices. m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_CONTROLLER_UPDATE); scene->UpdateParents(m_frameTime); - + // Process actuators - + // Do some cleanup work for this logic frame m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_ACTUATOR); scene->LogicUpdateFrame(m_frameTime, true); - + scene->LogicEndFrame(); - + // Actuators can affect the scenegraph m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_ACTUATOR_UPDATE); @@ -722,16 +722,16 @@ bool KX_KetsjiEngine::NextFrame() m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS2); scene->GetPhysicsEnvironment()->BeginFrame(); - - // Perform physics calculations on the scene. This can involve + + // Perform physics calculations on the scene. This can involve // many iterations of the physics solver. scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime); m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE); scene->UpdateParents(m_frameTime); - - + + if (m_animation_record) { m_sceneconverter->WritePhysicsObjectToAnimationIpo(++m_currentFrame); @@ -742,7 +742,7 @@ bool KX_KetsjiEngine::NextFrame() else if (scene->getSuspendedTime()==0.0) scene->setSuspendedTime(m_clockTime); - + m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true); // invalidates the shadow buffer from previous render/ImageRender because the scene has changed @@ -753,22 +753,22 @@ bool KX_KetsjiEngine::NextFrame() m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true); if (m_keyboarddevice) m_keyboarddevice->NextFrame(); - + if (m_mousedevice) m_mousedevice->NextFrame(); - + if (m_networkdevice) m_networkdevice->NextFrame(); // scene management ProcessScheduledScenes(); - + frames--; } // Start logging time spent outside main loop m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true); - + return doRender && m_doRender; } @@ -846,15 +846,15 @@ void KX_KetsjiEngine::Render() { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - + m_rasterizer->SetAuxilaryClientInfo(scene); - + // do the rendering RenderFrame(scene, cam); } - + list<class KX_Camera*>* cameras = scene->GetCameras(); - + // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); while (it != cameras->end()) { @@ -862,13 +862,13 @@ void KX_KetsjiEngine::Render() { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - + m_rasterizer->SetAuxilaryClientInfo(scene); - + // do the rendering RenderFrame(scene, (*it)); } - + it++; } PostRenderScene(scene); @@ -891,7 +891,7 @@ void KX_KetsjiEngine::Render() // pass the scene's worldsettings to the rasterizer scene->GetWorldInfo()->UpdateWorldSettings(); - + if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); @@ -903,7 +903,7 @@ void KX_KetsjiEngine::Render() RenderFrame(scene, cam); list<class KX_Camera*>* cameras = scene->GetCameras(); - + // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); while (it != cameras->end()) { @@ -911,13 +911,13 @@ void KX_KetsjiEngine::Render() { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - + m_rasterizer->SetAuxilaryClientInfo(scene); - + // do the rendering RenderFrame(scene, (*it)); } - + it++; } PostRenderScene(scene); @@ -951,7 +951,7 @@ int KX_KetsjiEngine::GetExitCode() if (m_scenes.begin() == m_scenes.end()) m_exitcode = KX_EXIT_REQUEST_NO_SCENES_LEFT; } - + // check if the window has been closed. if (!m_exitcode) { @@ -1022,7 +1022,7 @@ void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect if (cam->GetViewport()) { RAS_Rect userviewport; - userviewport.SetLeft(cam->GetViewportLeft()); + userviewport.SetLeft(cam->GetViewportLeft()); userviewport.SetBottom(cam->GetViewportBottom()); userviewport.SetRight(cam->GetViewportRight()); userviewport.SetTop(cam->GetViewportTop()); @@ -1049,7 +1049,7 @@ void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect area = m_canvas->GetDisplayArea(); } else { - viewport.SetLeft(0); + viewport.SetLeft(0); viewport.SetBottom(0); viewport.SetRight(int(m_canvas->GetWidth())); viewport.SetTop(int(m_canvas->GetHeight())); @@ -1134,7 +1134,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) /* remember that we have a valid shadow buffer for that scene */ scene->SetShadowDone(true); } - + // update graphics void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) { @@ -1142,7 +1142,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) RAS_Rect viewport, area; float nearfrust, farfrust, focallength; // KX_Camera* cam = scene->GetActiveCamera(); - + if (!cam) return; @@ -1160,7 +1160,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) // set the viewport for this frame and scene m_canvas->SetViewPort(viewport.GetLeft(), viewport.GetBottom(), viewport.GetRight(), viewport.GetTop()); - + // see KX_BlenderMaterial::Activate //m_rasterizer->SetAmbient(); m_rasterizer->DisplayFog(); @@ -1243,7 +1243,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar, focallength); } cam->SetProjectionMatrix(projmat); - + // Otherwise the projection matrix for each eye will be the same... if (!orthographic && m_rasterizer->Stereo()) cam->InvalidateProjectionMatrix(); @@ -1251,7 +1251,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) MT_Transform camtrans(cam->GetWorldToCamera()); MT_Matrix4x4 viewmat(camtrans); - + m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), cam->GetCameraData()->m_perspective); cam->SetModelviewMatrix(viewmat); @@ -1296,7 +1296,7 @@ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene) // We need to first make sure our viewport is correct (enabling multiple viewports can mess this up) m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight()); - + m_rasterizer->FlushDebugShapes(scene); scene->Render2DFilters(m_canvas); @@ -1337,7 +1337,7 @@ void KX_KetsjiEngine::StopEngine() // Scene Management is able to switch between scenes // and have several scenes running in parallel void KX_KetsjiEngine::AddScene(KX_Scene* scene) -{ +{ m_scenes.push_back(scene); PostProcessScene(scene); } @@ -1362,19 +1362,19 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) camdata.m_lens = m_overrideCamLens; camdata.m_clipstart = m_overrideCamNear; camdata.m_clipend = m_overrideCamFar; - + camdata.m_perspective= !m_overrideCamUseOrtho; } activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata); activecam->SetName("__default__cam__"); - + // set transformation if (override_camera) { const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat; MT_Transform trans = MT_Transform(cammatdata.getPointer()); MT_Transform camtrans; camtrans.invert(trans); - + activecam->NodeSetLocalPosition(camtrans.getOrigin()); activecam->NodeSetLocalOrientation(camtrans.getBasis()); activecam->NodeUpdateGS(0); @@ -1391,7 +1391,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) // done with activecam activecam->Release(); } - + scene->UpdateParents(0.0); } @@ -1409,7 +1409,7 @@ void KX_KetsjiEngine::RenderDebugProperties() int xcoord = 12; // mmmm, these constants were taken from blender source int ycoord = 17; // to 'mimic' behavior - + int profile_indent = 72; float tottime = m_logger->GetAverage(); @@ -1420,7 +1420,7 @@ void KX_KetsjiEngine::RenderDebugProperties() // Set viewport to entire canvas RAS_Rect viewport; m_canvas->SetViewPort(0, 0, int(m_canvas->GetWidth()), int(m_canvas->GetHeight())); - + if (m_show_framerate || m_show_profile) { /* Title for profiling("Profile") */ m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, @@ -1444,7 +1444,7 @@ void KX_KetsjiEngine::RenderDebugProperties() ycoord, m_canvas->GetWidth() /* RdV, TODO ?? */, m_canvas->GetHeight() /* RdV, TODO ?? */); - + debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.0f, 1.0f/tottime); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), @@ -1507,7 +1507,7 @@ void KX_KetsjiEngine::RenderDebugProperties() KX_Scene* scene = *sceneit; /* the 'normal' debug props */ vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties(); - + for (unsigned i=0; i < debugproplist.size() && propsAct < propsMax; i++) { CValue *propobj = debugproplist[i]->m_obj; @@ -1571,8 +1571,8 @@ KX_Scene* KX_KetsjiEngine::FindScene(const STR_String& scenename) { KX_SceneList::iterator sceneit = m_scenes.begin(); - // bit risky :) better to split the second clause - while ( (sceneit != m_scenes.end()) + // bit risky :) better to split the second clause + while ( (sceneit != m_scenes.end()) && ((*sceneit)->GetName() != scenename)) { sceneit++; @@ -1688,7 +1688,7 @@ void KX_KetsjiEngine::AddScheduledScenes() } m_addingOverlayScenes.clear(); } - + if (m_addingBackgroundScenes.size()) { for (scenenameit = m_addingBackgroundScenes.begin(); @@ -1734,7 +1734,7 @@ void KX_KetsjiEngine::ReplaceScheduledScenes() if (m_replace_scenes.size()) { vector<pair<STR_String,STR_String> >::iterator scenenameit; - + for (scenenameit = m_replace_scenes.begin(); scenenameit != m_replace_scenes.end(); scenenameit++) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 1756214b6dd..ab3a3d013b4 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -104,8 +104,8 @@ private: int m_activecam; bool m_bFixedTime; bool m_useExternalClock; - - + + bool m_firstframe; int m_currentFrame; @@ -135,10 +135,10 @@ private: STR_String m_exitstring; float m_cameraZoom; - + bool m_overrideCam; STR_String m_overrideSceneName; - + bool m_overrideCamUseOrtho; MT_CmMatrix4x4 m_overrideCamProjMat; MT_CmMatrix4x4 m_overrideCamViewMat; @@ -169,7 +169,7 @@ private: /** Time logger. */ KX_TimeCategoryLogger* m_logger; - + /** Labels for profiling display. */ static const char m_profileLabels[tc_numCategories][15]; /** Last estimated framerate */ @@ -244,7 +244,7 @@ public: TaskScheduler* GetTaskScheduler() { return m_taskscheduler; } /// Dome functions - void InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text); + void InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text); void EndDome(); void RenderDome(); bool m_usedome; @@ -253,7 +253,7 @@ public: bool NextFrame(); void Render(); void RenderShadowBuffers(KX_Scene *scene); - + void StartEngine(bool clearIpo); void StopEngine(); void Export(const STR_String& filename); @@ -277,9 +277,9 @@ public: /// Sets zoom for camera objects, useful only with extend and scale framing mode. void SetCameraZoom(float camzoom); - + void EnableCameraOverride(const STR_String& forscene); - + void SetCameraOverrideUseOrtho(bool useOrtho); void SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat); void SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat); @@ -290,17 +290,17 @@ public: // Update animations for object in this scene void UpdateAnimations(KX_Scene *scene); - + /** * Sets display of all frames. * \param bUseFixedTime New setting for display all frames. - */ + */ void SetUseFixedTime(bool bUseFixedTime); /** * Returns display of all frames. * \return Current setting for display all frames. - */ + */ bool GetUseFixedTime(void) const; /** @@ -391,7 +391,7 @@ public: static double GetAverageFrameRate(); /** - * Gets the time scale multiplier + * Gets the time scale multiplier */ double GetTimeScale() const; @@ -459,7 +459,7 @@ public: * \param frameRate Display for frame rate on or off. * \param profile Display for individual components on or off. * \param properties Display of scene object debug properties on or off. - */ + */ void SetTimingDisplay(bool frameRate, bool profile, bool properties); /** @@ -467,33 +467,33 @@ public: * \param frameRate Display for frame rate on or off. * \param profile Display for individual components on or off. * \param properties Display of scene object debug properties on or off. - */ + */ void GetTimingDisplay(bool& frameRate, bool& profile, bool& properties) const; - /** + /** * Sets cursor hiding on every frame. * \param hideCursor Turns hiding on or off. */ void SetHideCursor(bool hideCursor); - /** + /** * Returns the current setting for cursor hiding. * \return The current setting for cursor hiding. */ bool GetHideCursor(void) const; - /** + /** * Enables/disables the use of the framing bar color of the Blender file's scenes. * \param overrideFrameColor The new setting. */ void SetUseOverrideFrameColor(bool overrideFrameColor); - /** + /** * Check if the frame color is being overridden. */ - bool GetUseOverrideFrameColor(void) const; + bool GetUseOverrideFrameColor(void) const; - /** + /** * Set the color used for framing bar color instead of the one in the Blender file's scenes. * \param r Red component of the override color. * \param g Green component of the override color. @@ -501,7 +501,7 @@ public: */ void SetOverrideFrameColor(float r, float g, float b, float a); - /** + /** * Returns the color used for framing bar color instead of the one in the Blender file's scenes. * \param r Red component of the override color. * \param g Green component of the override color. @@ -539,12 +539,12 @@ protected: void AddScheduledScenes(void); void ReplaceScheduledScenes(void); void PostProcessScene(class KX_Scene* scene); - + bool BeginFrame(); void ClearFrame(); void EndFrame(); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_KetsjiEngine") #endif diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 5f490747c2b..cdef0f458d7 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -89,7 +89,7 @@ CValue* KX_LightObject::GetReplica() KX_LightObject* replica = new KX_LightObject(*this); replica->ProcessReplica(); - + replica->m_lightobj = m_lightobj->Clone(); replica->m_lightobj->m_light = replica; m_rasterizer->AddLight(replica->m_lightobj); @@ -470,7 +470,7 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr PyErr_SetString(PyExc_ValueError, "light.type= val: KX_LightObject, expected an int between 0 and 2"); return PY_SET_ATTR_FAIL; } - + switch (val) { case 0: self->m_lightobj->m_type = self->m_lightobj->LIGHT_SPOT; diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index b446acd6e63..21c68cb9317 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -58,7 +58,7 @@ public: virtual ~KX_LightObject(); virtual CValue* GetReplica(); RAS_ILightObject* GetLightData() { return m_lightobj;} - + void UpdateScene(class KX_Scene *kxscene); virtual void SetLayer(int layer); diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp index 6b641f7a63f..70efa9b50c1 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp @@ -49,13 +49,13 @@ bool KX_LightIpoSGController::Update(double currentTime) for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { (*i)->Execute(m_ipotime);//currentTime); } - + RAS_ILightObject *lightobj; SG_Spatial* ob = (SG_Spatial*)m_pObject; KX_LightObject* kxlight = (KX_LightObject*) ob->GetSGClientObject(); lightobj = kxlight->GetLightData(); - //lightobj = (KX_Light*) + //lightobj = (KX_Light*) if (m_modify_energy) { lightobj->m_energy = m_energy; @@ -107,7 +107,7 @@ SG_Controller* KX_LightIpoSGController::GetReplica(class SG_Node* destnode) MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; copyipo->SetNewTarget((MT_Scalar*)blaptr); } - + return iporeplica; } @@ -118,5 +118,5 @@ KX_LightIpoSGController::~KX_LightIpoSGController() for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { delete (*i); } - + } diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index 151ced6b8f8..151dfcd5abd 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -55,7 +55,7 @@ private: double m_ipotime; public: - KX_LightIpoSGController() : + KX_LightIpoSGController() : m_modify_energy(false), m_modify_color(false), m_modify_dist(false), @@ -68,7 +68,7 @@ public: virtual SG_Controller* GetReplica(class SG_Node* destnode); virtual bool Update(double time); - + virtual void SetSimulatedTime(double time) { m_ipotime = time; m_modified = true; @@ -95,8 +95,8 @@ public: }; void AddInterpolator(KX_IInterpolator* interp); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_LightIpoSGController") #endif diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp index 1faf8f17d54..0581ffdb1cc 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp @@ -36,19 +36,19 @@ bool KX_MaterialIpoController::Update(double currentTime) for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { (*i)->Execute(m_ipotime); } - + SG_Spatial* ob = (SG_Spatial*)m_pObject; KX_GameObject* kxgameobj= (KX_GameObject*) ob->GetSGClientObject(); //kxgameobj->SetObjectColor(m_rgba); - kxgameobj->UpdateMaterialData( + kxgameobj->UpdateMaterialData( m_matname_hash, - m_rgba, - m_specrgb, - m_hard, - m_spec, - m_ref, + m_rgba, + m_specrgb, + m_hard, + m_spec, + m_ref, m_emit, m_alpha ); @@ -89,7 +89,7 @@ SG_Controller* KX_MaterialIpoController::GetReplica(class SG_Node* destnode) MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; copyipo->SetNewTarget((MT_Scalar*)blaptr); } - + return iporeplica; } @@ -100,6 +100,6 @@ KX_MaterialIpoController::~KX_MaterialIpoController() for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { delete (*i); } - + } diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h index a7e9c2cc1c5..ca5d1040da2 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.h +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h @@ -32,7 +32,7 @@ private: double m_ipotime; dword m_matname_hash; public: - KX_MaterialIpoController(dword matname_hash) : + KX_MaterialIpoController(dword matname_hash) : m_modified(true), m_ipotime(0.0), m_matname_hash(matname_hash) @@ -44,7 +44,7 @@ public: m_ipotime = time; m_modified = true; } - + void SetOption( int option, diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 8da3542b4d6..ceec7fbb07a 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -45,7 +45,7 @@ #include "SCA_LogicManager.h" -#include "EXP_PyObjectPlus.h" +#include "EXP_PyObjectPlus.h" PyTypeObject KX_MeshProxy::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -150,7 +150,7 @@ PyObject *KX_MeshProxy::PyGetTextureName(PyObject *args, PyObject *kwds) } return PyUnicode_From_STR_String(matname); - + } PyObject *KX_MeshProxy::PyGetVertexArrayLength(PyObject *args, PyObject *kwds) @@ -158,20 +158,20 @@ PyObject *KX_MeshProxy::PyGetVertexArrayLength(PyObject *args, PyObject *kwds) int matid= 0; int length = 0; - + if (!PyArg_ParseTuple(args,"i:getVertexArrayLength",&matid)) return NULL; - + RAS_MeshMaterial *mmat = m_meshobj->GetMeshMaterial(matid); /* can be NULL*/ - + if (mmat) { RAS_IPolyMaterial* mat = mmat->m_bucket->GetPolyMaterial(); if (mat) length = m_meshobj->NumVertices(mat); } - + return PyLong_FromLong(length); } @@ -183,14 +183,14 @@ PyObject *KX_MeshProxy::PyGetVertex(PyObject *args, PyObject *kwds) if (!PyArg_ParseTuple(args,"ii:getVertex",&matindex,&vertexindex)) return NULL; - + RAS_TexVert* vertex = m_meshobj->GetVertex(matindex,vertexindex); - + if (vertex==NULL) { PyErr_SetString(PyExc_ValueError, "mesh.getVertex(mat_idx, vert_idx): KX_MeshProxy, could not get a vertex at the given indices"); return NULL; } - + return (new KX_VertexProxy(this, vertex))->NewProxy(true); } @@ -201,13 +201,13 @@ PyObject *KX_MeshProxy::PyGetPolygon(PyObject *args, PyObject *kwds) if (!PyArg_ParseTuple(args,"i:getPolygon",&polyindex)) return NULL; - + if (polyindex<0 || polyindex >= m_meshobj->NumPolygons()) { PyErr_SetString(PyExc_AttributeError, "mesh.getPolygon(int): KX_MeshProxy, invalid polygon index"); return NULL; } - + RAS_Polygon* polygon = m_meshobj->GetPolygon(polyindex); if (polygon) @@ -377,15 +377,15 @@ PyObject *KX_MeshProxy::PyTransformUV(PyObject *args, PyObject *kwds) PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MeshProxy* self = static_cast<KX_MeshProxy*>(self_v); - + int tot= self->m_meshobj->NumMaterials(); int i; - + PyObject *materials = PyList_New( tot ); - + list<RAS_MeshMaterial>::iterator mit= self->m_meshobj->GetFirstMaterial(); - - + + for (i=0; i<tot; mit++, i++) { RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial(); KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial *>(polymat); @@ -414,10 +414,10 @@ bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshOb *object = NULL; return false; } - + if (value==Py_None) { *object = NULL; - + if (py_none_ok) { return true; } else { @@ -425,10 +425,10 @@ bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshOb return false; } } - + if (PyUnicode_Check(value)) { *object = (RAS_MeshObject*)logicmgr->GetMeshByName(STR_String( _PyUnicode_AsString(value) )); - + if (*object) { return true; } else { @@ -436,28 +436,28 @@ bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshOb return false; } } - + if (PyObject_TypeCheck(value, &KX_MeshProxy::Type)) { KX_MeshProxy *kx_mesh = static_cast<KX_MeshProxy*>BGE_PROXY_REF(value); - + /* sets the error */ if (kx_mesh==NULL) { PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix); return false; } - + *object = kx_mesh->GetMesh(); return true; } - + *object = NULL; - + if (py_none_ok) { PyErr_Format(PyExc_TypeError, "%s, expect a KX_MeshProxy, a string or None", error_prefix); } else { PyErr_Format(PyExc_TypeError, "%s, expect a KX_MeshProxy or a string", error_prefix); } - + return false; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index dbd7987f785..f634834a2b6 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -67,14 +67,14 @@ public: KX_PYMETHOD(KX_MeshProxy,GetMaterialName); KX_PYMETHOD(KX_MeshProxy,GetTextureName); KX_PYMETHOD_NOARGS(KX_MeshProxy,GetNumPolygons); // Deprecated - + // both take materialid (int) KX_PYMETHOD(KX_MeshProxy,GetVertexArrayLength); KX_PYMETHOD(KX_MeshProxy,GetVertex); KX_PYMETHOD(KX_MeshProxy,GetPolygon); KX_PYMETHOD(KX_MeshProxy,Transform); KX_PYMETHOD(KX_MeshProxy,TransformUV); - + static PyObject *pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject *pyattr_get_numMaterials(void *self, const KX_PYATTRIBUTE_DEF * attrdef); static PyObject *pyattr_get_numPolygons(void *self, const KX_PYATTRIBUTE_DEF * attrdef); diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp index 4728f71a6ea..38c10c1ed83 100644 --- a/source/gameengine/Ketsji/KX_MotionState.cpp +++ b/source/gameengine/Ketsji/KX_MotionState.cpp @@ -65,18 +65,18 @@ void KX_MotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2 = orn[2]; quatReal = orn[3]; } - + void KX_MotionState::GetWorldOrientation(float* ori) { const MT_Matrix3x3& mat = m_node->GetWorldOrientation(); mat.getValue(ori); } - + void KX_MotionState::SetWorldOrientation(const float* ori) { m_node->SetLocalOrientation(ori); } - + void KX_MotionState::SetWorldPosition(float posX,float posY,float posZ) { m_node->SetLocalPosition(MT_Point3(posX,posY,posZ)); @@ -103,4 +103,4 @@ void KX_MotionState::CalculateWorldTransformations() //m_node->ComputeWorldTransforms(NULL, parentUpdated); } - + diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 451078d4a36..ff7ed3bd647 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -60,7 +60,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, +KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, int startx, int starty, short int mousemode, @@ -91,7 +91,7 @@ void KX_MouseFocusSensor::Init() m_hitObject = 0; m_hitObject_Last = NULL; m_reset = true; - + m_hitPosition.setValue(0,0,0); m_prevTargetPoint.setValue(0,0,0); m_prevSourcePoint.setValue(0,0,0); @@ -110,12 +110,12 @@ bool KX_MouseFocusSensor::Evaluate() /* Focus behavior required. Test mouse-on. The rest is * equivalent to handling a key. */ obHasFocus = ParentObjectHasFocus(); - + if (!obHasFocus) { m_positive_event = false; if (m_mouse_over_in_previous_frame) { result = true; - } + } } else { m_positive_event = true; if (!m_mouse_over_in_previous_frame) { @@ -124,7 +124,7 @@ bool KX_MouseFocusSensor::Evaluate() else if (m_bTouchPulse && (m_hitObject != m_hitObject_Last)) { result = true; } - } + } if (reset) { // force an event result = true; @@ -140,14 +140,14 @@ bool KX_MouseFocusSensor::Evaluate() m_mouse_over_in_previous_frame = obHasFocus; m_hitObject_Last = (void *)m_hitObject; - + return result; } bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *result, void *UNUSED(data)) { KX_GameObject* hitKXObj = client_info->m_gameobject; - + /* Is this me? In the ray test, there are a lot of extra checks * for aliasing artifacts from self-hits. That doesn't happen * here, so a simple test suffices. Or does the camera also get @@ -188,9 +188,9 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *r m_hitNormal = result->m_hitNormal; m_hitUV = result->m_hitUV; return true; - } + } } - + return true; // object must be visible to trigger //return false; // occluded objects can trigger } @@ -238,7 +238,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) { /* All screen handling in the gameengine is done by GL, * specifically the model/view and projection parts. The viewport - * part is in the creator. + * part is in the creator. * * The theory is this: * WCS - world coordinates @@ -262,13 +262,13 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) * Inverting (blender y is flipped!): * * xn = 2(xwin - x_lb)/width - 1.0 - * yn = 2(ywin - y_lb)/height - 1.0 + * yn = 2(ywin - y_lb)/height - 1.0 * = 2(height - y_blender - y_lb)/height - 1.0 * = 1.0 - 2(y_blender - y_lb)/height * * */ - - + + /* Because we don't want to worry about resize events, camera * changes and all that crap, we just determine this over and * over. Stop whining. We have lots of other calculations to do @@ -276,12 +276,12 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) * canvas, the test is irrelevant. The 1.0 makes sure the * calculations don't bomb. Maybe we should explicitly guard for * division by 0.0...*/ - + RAS_Rect area, viewport; short m_y_inv = m_kxengine->GetCanvas()->GetHeight()-m_y; - + m_kxengine->GetSceneViewport(m_kxscene, cam, area, viewport); - + /* Check if the mouse is in the viewport */ if (( m_x < viewport.m_x2 && // less than right m_x > viewport.m_x1 && // more than then left @@ -293,37 +293,37 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) float height = float(viewport.m_y2 - viewport.m_y1 + 1); float width = float(viewport.m_x2 - viewport.m_x1 + 1); - + float x_lb = float(viewport.m_x1); float y_lb = float(viewport.m_y1); MT_Vector4 frompoint; MT_Vector4 topoint; - + /* m_y_inv - inverting for a bounds check is only part of it, now make relative to view bounds */ m_y_inv = (viewport.m_y2 - m_y_inv) + viewport.m_y1; - - + + /* There's some strangeness I don't fully get here... These values * _should_ be wrong! - see from point Z values */ - - - /* build the from and to point in normalized device coordinates + + + /* build the from and to point in normalized device coordinates * Normalized device coordinates are [-1,1] in x, y, z * - * The actual z coordinates used don't have to be exact just infront and + * 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.0f, 1.0f - (2 * (m_y_inv - y_lb) / height), -1.0f, 1.0f ); - + 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()); @@ -339,16 +339,16 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) * clipend = - (topoint[2] / topoint[3]) */ frompoint = camcs_wcs_matrix * frompoint; topoint = camcs_wcs_matrix * topoint; - + /* from hom wcs to 3d wcs: */ m_prevSourcePoint.setValue( frompoint[0]/frompoint[3], frompoint[1]/frompoint[3], - frompoint[2]/frompoint[3]); - + frompoint[2]/frompoint[3]); + m_prevTargetPoint.setValue( topoint[0]/topoint[3], topoint[1]/topoint[3], - topoint[2]/topoint[3]); - + topoint[2]/topoint[3]); + /* 2. Get the object from PhysicsEnvironment */ /* Shoot! Beware that the first argument here is an * ignore-object. We don't ignore anything... */ @@ -357,12 +357,12 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) // get UV mapping KX_RayCast::Callback<KX_MouseFocusSensor, void> callback(this,physics_controller,NULL,false,true); - + KX_RayCast::RayTest(physics_environment, m_prevSourcePoint, m_prevTargetPoint, callback); - + if (m_hitObject) return true; - + return false; } @@ -371,23 +371,23 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus() m_hitObject = 0; m_hitPosition.setValue(0,0,0); m_hitNormal.setValue(1,0,0); - + KX_Camera *cam= m_kxscene->GetActiveCamera(); - + if (ParentObjectHasFocusCamera(cam)) return true; list<class KX_Camera*>* cameras = m_kxscene->GetCameras(); list<KX_Camera*>::iterator it = cameras->begin(); - + while (it != cameras->end()) { if (((*it) != cam) && (*it)->GetViewport()) if (ParentObjectHasFocusCamera(*it)) return true; - + it++; } - + return false; } @@ -489,10 +489,10 @@ PyObject *KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_P PyObject *KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); - + if (self->m_hitObject) return self->m_hitObject->GetProxy(); - + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index dd9295b2ff4..9437a0f3432 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -50,9 +50,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor { Py_Header - + public: - + KX_MouseFocusSensor(class SCA_MouseManager* eventmgr, int startx, int starty, @@ -81,7 +81,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor /** - * \attention Overrides default evaluate. + * \attention Overrides default evaluate. */ virtual bool Evaluate(); virtual void Init(); @@ -96,13 +96,13 @@ class KX_MouseFocusSensor : public SCA_MouseSensor bool RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data)); /// \see KX_RayCast bool NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data)); - + const MT_Point3& RaySource() const; const MT_Point3& RayTarget() const; const MT_Point3& HitPosition() const; const MT_Vector3& HitNormal() const; const MT_Vector2& HitUV() const; - + #ifdef WITH_PYTHON /* --------------------------------------------------------------------- */ @@ -117,7 +117,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor static PyObject* pyattr_get_hit_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_hit_normal(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_hit_uv(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + #endif /* WITH_PYTHON */ /* --------------------------------------------------------------------- */ @@ -139,7 +139,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor * Flags whether changes in hit object should trigger a pulse */ bool m_bTouchPulse; - + /** * Flags get through other objects */ @@ -164,7 +164,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor * Tests whether the object is in mouse focus for this camera */ bool ParentObjectHasFocusCamera(KX_Camera *cam); - + /** * Tests whether the object is in mouse focus in this scene. */ diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 5beda2e038a..a5feb95b00b 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -78,7 +78,7 @@ KX_NavMeshObject::KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbac : KX_GameObject(sgReplicationInfo, callbacks) , m_navMesh(NULL) { - + } KX_NavMeshObject::~KX_NavMeshObject() @@ -110,7 +110,7 @@ void KX_NavMeshObject::ProcessReplica() bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, unsigned short* &polys, int& npolys, unsigned short *&dmeshes, - float *&dvertices, int &ndvertsuniq, unsigned short *&dtris, + float *&dvertices, int &ndvertsuniq, unsigned short *&dtris, int& ndtris, int &vertsPerPoly) { DerivedMesh* dm = mesh_create_derived_no_virtual(GetScene()->GetBlenderScene(), GetBlenderObject(), @@ -278,7 +278,7 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, ndtris = npolys; } dm->release(dm); - + return true; } @@ -301,8 +301,8 @@ bool KX_NavMeshObject::BuildNavMesh() unsigned short *polys = NULL, *dtris = NULL, *dmeshes = NULL; int nverts = 0, npolys = 0, ndvertsuniq = 0, ndtris = 0; int vertsPerPoly = 0; - if (!BuildVertIndArrays(vertices, nverts, polys, npolys, - dmeshes, dvertices, ndvertsuniq, dtris, ndtris, vertsPerPoly ) + if (!BuildVertIndArrays(vertices, nverts, polys, npolys, + dmeshes, dvertices, ndvertsuniq, dtris, ndtris, vertsPerPoly ) || vertsPerPoly<3) { printf("Can't build navigation mesh data for object:%s\n", m_name.ReadPtr()); @@ -314,7 +314,7 @@ bool KX_NavMeshObject::BuildNavMesh() } return false; } - + MT_Point3 pos; if (dmeshes==NULL) { @@ -333,7 +333,7 @@ bool KX_NavMeshObject::BuildNavMesh() delete[] vertices; return false; } - + float cs = 0.2f; if (!nverts || !npolys) @@ -424,8 +424,8 @@ bool KX_NavMeshObject::BuildNavMesh() header->nnodes = createBVTree(vertsi, nverts, polys, npolys, vertsPerPoly, cs, cs, npolys*2, navNodes); - - + + if (dmeshes==NULL) { //create fake detail meshes @@ -496,18 +496,18 @@ void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode) if (!m_navMesh) return; MT_Vector3 color(0.f, 0.f, 0.f); - + switch (renderMode) { case RM_POLYS : - case RM_WALLS : + case RM_WALLS : for (int pi=0; pi<m_navMesh->getPolyCount(); pi++) { const dtStatPoly* poly = m_navMesh->getPoly(pi); for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++) { - if (poly->n[j] && renderMode==RM_WALLS) + if (poly->n[j] && renderMode==RM_WALLS) continue; const float* vif = m_navMesh->getVertex(poly->v[i]); const float* vjf = m_navMesh->getVertex(poly->v[j]); @@ -519,7 +519,7 @@ void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode) } } break; - case RM_TRIS : + case RM_TRIS : for (int i = 0; i < m_navMesh->getPolyDetailCount(); ++i) { const dtStatPoly* p = m_navMesh->getPoly(i); @@ -561,7 +561,7 @@ MT_Point3 KX_NavMeshObject::TransformToLocalCoords(const MT_Point3& wpos) MT_Matrix3x3 orientation = NodeGetWorldOrientation(); const MT_Vector3& scaling = NodeGetWorldScaling(); orientation.scale(scaling[0], scaling[1], scaling[2]); - MT_Transform worldtr(NodeGetWorldPosition(), orientation); + MT_Transform worldtr(NodeGetWorldPosition(), orientation); MT_Transform invworldtr; invworldtr.invert(worldtr); MT_Point3 lpos = invworldtr(wpos); @@ -573,7 +573,7 @@ MT_Point3 KX_NavMeshObject::TransformToWorldCoords(const MT_Point3& lpos) MT_Matrix3x3 orientation = NodeGetWorldOrientation(); const MT_Vector3& scaling = NodeGetWorldScaling(); orientation.scale(scaling[0], scaling[1], scaling[2]); - MT_Transform worldtr(NodeGetWorldPosition(), orientation); + MT_Transform worldtr(NodeGetWorldPosition(), orientation); MT_Point3 wpos = worldtr(lpos); return wpos; } @@ -694,7 +694,7 @@ KX_PYMETHODDEF_DOC(KX_NavMeshObject, findPath, MT_Point3 from, to; if (!PyVecTo(ob_from, from) || !PyVecTo(ob_to, to)) return NULL; - + float path[MAX_PATH_LEN*3]; int pathLen = FindPath(from, to, path, MAX_PATH_LEN); PyObject *pathList = PyList_New( pathLen ); diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.h b/source/gameengine/Ketsji/KX_NavMeshObject.h index af178f9aaee..0f0bf8008d0 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.h +++ b/source/gameengine/Ketsji/KX_NavMeshObject.h @@ -40,12 +40,12 @@ class KX_NavMeshObject: public KX_GameObject protected: dtStatNavMesh* m_navMesh; - + bool BuildVertIndArrays(float *&vertices, int& nverts, - unsigned short* &polys, int& npolys, unsigned short *&dmeshes, - float *&dvertices, int &ndvertsuniq, unsigned short* &dtris, + unsigned short* &polys, int& npolys, unsigned short *&dmeshes, + float *&dvertices, int &ndvertsuniq, unsigned short* &dtris, int& ndtris, int &vertsPerPoly); - + public: KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbacks); ~KX_NavMeshObject(); diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 92ab8f412d9..c436c77c32b 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -62,7 +62,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, gameobj->getClientInfo()->m_sensors.remove(this); m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::SENSOR); m_client_info->m_sensors.push_back(this); - + //DT_ShapeHandle shape = (DT_ShapeHandle) vshape; m_physCtrl = ctrl; if (m_physCtrl) @@ -75,7 +75,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, void KX_NearSensor::SynchronizeTransform() { - // The near and radar sensors are using a different physical object which is + // The near and radar sensors are using a different physical object which is // not linked to the parent object, must synchronize it. if (m_physCtrl) { @@ -100,9 +100,9 @@ CValue* KX_NearSensor::GetReplica() void KX_NearSensor::ProcessReplica() { KX_TouchSensor::ProcessReplica(); - + m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::SENSOR); - + if (m_physCtrl) { m_physCtrl = m_physCtrl->GetReplicaForSensors(); @@ -112,14 +112,14 @@ void KX_NearSensor::ProcessReplica() m_physCtrl->SetMargin(m_Margin); m_physCtrl->SetNewClientInfo(m_client_info); } - + } } void KX_NearSensor::ReParent(SCA_IObject* parent) { SCA_ISensor::ReParent(parent); - m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent); + m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent); m_client_info->m_sensors.push_back(this); //Synchronize here with the actual parent. SynchronizeTransform(); @@ -137,8 +137,8 @@ KX_NearSensor::~KX_NearSensor() delete m_physCtrl; m_physCtrl = NULL; } - - + + if (m_client_info) delete m_client_info; } @@ -168,9 +168,9 @@ bool KX_NearSensor::Evaluate() if (m_bTriggered != m_bLastTriggered) { m_bLastTriggered = m_bTriggered; - + SetPhysCtrlRadius(); - + result = true; } @@ -183,21 +183,21 @@ bool KX_NearSensor::Evaluate() bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2) { KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent()); - + // need the mapping from PHY_IPhysicsController to gameobjects now assert(obj1==m_physCtrl && obj2); KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->GetNewClientInfo()); - KX_GameObject* gameobj = ( client_info ? + KX_GameObject* gameobj = ( client_info ? client_info->m_gameobject : NULL); - + if (gameobj && (gameobj != parent)) { // only take valid colliders if (client_info->m_type == KX_ClientObjectInfo::ACTOR) { - if ((m_touchedpropname.Length() == 0) || + if ((m_touchedpropname.Length() == 0) || (gameobj->GetProperty(m_touchedpropname))) { return true; @@ -212,18 +212,18 @@ bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat { // KX_TouchEventManager* toucheventmgr = static_cast<KX_TouchEventManager*>(m_eventmgr); // KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent()); - + // need the mapping from PHY_IPhysicsController to gameobjects now - + KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (obj1 == m_physCtrl? ((PHY_IPhysicsController*)obj2)->GetNewClientInfo() : ((PHY_IPhysicsController*)obj1)->GetNewClientInfo()); - KX_GameObject* gameobj = ( client_info ? + KX_GameObject* gameobj = ( client_info ? client_info->m_gameobject : NULL); - - // Add the same check as in SCA_ISensor::Activate(), + + // Add the same check as in SCA_ISensor::Activate(), // we don't want to record collision when the sensor is not active. if (m_links && !m_suspended && gameobj /* done in BroadPhaseFilterCollision() && (gameobj != parent)*/) @@ -234,7 +234,7 @@ bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat // These checks are done already in BroadPhaseFilterCollision() //if (client_info->m_type == KX_ClientObjectInfo::ACTOR) //{ - // if ((m_touchedpropname.Length() == 0) || + // if ((m_touchedpropname.Length() == 0) || // (gameobj->GetProperty(m_touchedpropname))) // { m_bTriggered = true; @@ -242,7 +242,7 @@ bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat // } //} } - + return false; // was DT_CONTINUE; but this was defined in Sumo as false } diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index ef6e15f602f..e323357434a 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -65,7 +65,7 @@ public: const STR_String& touchedpropname, class KX_Scene* scene); #endif - virtual ~KX_NearSensor(); + virtual ~KX_NearSensor(); virtual void SynchronizeTransform(); virtual CValue* GetReplica(); virtual void ProcessReplica(); @@ -96,7 +96,7 @@ public: sensor->m_ResetMargin = sensor->m_Margin; sensor->SetPhysCtrlRadius(); - + return 0; } diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp index 7f81f221c07..6777afd03c9 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp @@ -54,10 +54,10 @@ bool KX_ObColorIpoSGController::Update(double currentTime) for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { (*i)->Execute(m_ipotime); } - + kxgameobj->SetObjectColor(m_rgba); - + m_modified=false; } @@ -95,7 +95,7 @@ SG_Controller* KX_ObColorIpoSGController::GetReplica(class SG_Node* destnode) MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; copyipo->SetNewTarget((MT_Scalar*)blaptr); } - + return iporeplica; } @@ -106,5 +106,5 @@ KX_ObColorIpoSGController::~KX_ObColorIpoSGController() for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { delete (*i); } - + } diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h index a7b0b2c4ffc..e482e66fad3 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h @@ -40,7 +40,7 @@ class KX_ObColorIpoSGController : public SG_Controller { public: MT_Vector4 m_rgba; - + private: T_InterpolatorList m_interpolators; @@ -48,7 +48,7 @@ private: double m_ipotime; public: - KX_ObColorIpoSGController() : + KX_ObColorIpoSGController() : m_modified(true), m_ipotime(0.0) {} @@ -59,7 +59,7 @@ public: m_ipotime = time; m_modified = true; } - + void SetOption( int option, @@ -70,8 +70,8 @@ public: void AddInterpolator(KX_IInterpolator* interp); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ObColorIpoSGController") #endif diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 8c1dee7940f..d957fe8f31a 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -57,7 +57,7 @@ KX_ObjectActuator( const MT_Vector3& angV, const short damping, const KX_LocalFlags& flag -) : +) : SCA_IActuator(gameobj, KX_ACT_OBJECT), m_force(force), m_torque(torque), @@ -109,17 +109,17 @@ KX_ObjectActuator::~KX_ObjectActuator() bool KX_ObjectActuator::Update() { - + bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); - - KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent()); + + KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent()); PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent); if (bNegativeEvent) { // If we previously set the linear velocity we now have to inform // the physics controller that we no longer wish to apply it and that - // it should reconcile the externally set velocity with it's + // it should reconcile the externally set velocity with it's // own velocity. if (m_active_combined_velocity) { if (parent) @@ -142,14 +142,14 @@ bool KX_ObjectActuator::Update() 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; + return false; } else if (parent) { - if (m_bitLocalFlag.ServoControl) + if (m_bitLocalFlag.ServoControl) { // In this mode, we try to reach a target speed using force - // As we don't know the friction, we must implement a generic + // As we don't know the friction, we must implement a generic // servo control to achieve the speed in a configurable // v = current velocity // V = target velocity @@ -182,7 +182,7 @@ bool KX_ObjectActuator::Update() m_force = m_pid.x()*e+m_pid.y()*I+m_pid.z()*dv; // to automatically adapt the PID coefficient to mass; m_force *= mass; - if (m_bitLocalFlag.Torque) + if (m_bitLocalFlag.Torque) { if (m_force[0] > m_dloc[0]) { @@ -194,7 +194,7 @@ bool KX_ObjectActuator::Update() I[0] = m_error_accumulator[0]; } } - if (m_bitLocalFlag.DLoc) + if (m_bitLocalFlag.DLoc) { if (m_force[1] > m_dloc[1]) { @@ -206,7 +206,7 @@ bool KX_ObjectActuator::Update() I[1] = m_error_accumulator[1]; } } - if (m_bitLocalFlag.DRot) + if (m_bitLocalFlag.DRot) { if (m_force[2] > m_dloc[2]) { @@ -325,7 +325,7 @@ bool KX_ObjectActuator::Update() } } } - + } return true; } @@ -573,7 +573,7 @@ PyObject *KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATT PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0])); PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0])); PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque)); - + return retVal; } @@ -609,7 +609,7 @@ PyObject *KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATT PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1])); PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1])); PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc)); - + return retVal; } @@ -645,7 +645,7 @@ PyObject *KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATT PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2])); PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2])); PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot)); - + return retVal; } @@ -678,7 +678,7 @@ PyObject *KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PY KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); if (!actuator->m_reference) Py_RETURN_NONE; - + return actuator->m_reference->GetProxy(); } @@ -686,13 +686,13 @@ int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIB { KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); KX_GameObject *refOb; - + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &refOb, true, "actu.reference = value: KX_ObjectActuator")) return PY_SET_ATTR_FAIL; - + if (actuator->m_reference) actuator->m_reference->UnregisterActuator(actuator); - + if (refOb==NULL) { actuator->m_reference= NULL; } @@ -700,7 +700,7 @@ int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIB actuator->m_reference = refOb; actuator->m_reference->RegisterActuator(actuator); } - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index 919c6acf03b..7b34c0cbec2 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -109,8 +109,8 @@ class KX_ObjectActuator : public SCA_IActuator KX_LocalFlags m_bitLocalFlag; KX_GameObject* m_reference; // A hack bool -- oh no sorry everyone - // This bool is used to check if we have informed - // the physics object that we are no longer + // This bool is used to check if we have informed + // the physics object that we are no longer // setting linear velocity. bool m_active_combined_velocity; @@ -129,9 +129,9 @@ public: KX_OBJECT_ACT_ANGULAR_VELOCITY, KX_OBJECT_ACT_MAX }; - + /** - * Check whether this is a valid vector mode + * Check whether this is a valid vector mode */ bool isValid(KX_OBJECT_ACT_VEC_TYPE type); @@ -155,7 +155,7 @@ public: void SetForceLoc(const double force[3]) { /*m_force=force;*/ } void UpdateFuzzyFlags() - { + { m_bitLocalFlag.ZeroForce = MT_fuzzyZero(m_force); m_bitLocalFlag.ZeroTorque = MT_fuzzyZero(m_torque); m_bitLocalFlag.ZeroDLoc = MT_fuzzyZero(m_dloc); diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index c84b2474c90..20d4a517552 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -230,7 +230,7 @@ void KX_ObstacleSimulation::AddObstaclesForNavMesh(KX_NavMeshObject* navmeshobj) if (poly->n[j]) continue; const float* vj = navmesh->getVertex(poly->v[j]); const float* vi = navmesh->getVertex(poly->v[i]); - + KX_Obstacle* obstacle = CreateObstacle(navmeshobj); obstacle->m_type = KX_OBSTACLE_NAV_MESH; obstacle->m_shape = KX_OBSTACLE_SEGMENT; @@ -292,7 +292,7 @@ KX_Obstacle* KX_ObstacleSimulation::GetObstacle(KX_GameObject* gameobj) return NULL; } -void KX_ObstacleSimulation::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, +void KX_ObstacleSimulation::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle) { } @@ -383,7 +383,7 @@ KX_ObstacleSimulationTOI::KX_ObstacleSimulationTOI(MT_Scalar levelHeight, bool e } -void KX_ObstacleSimulationTOI::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, +void KX_ObstacleSimulationTOI::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, MT_Vector3& velocity, MT_Scalar maxDeltaSpeed, MT_Scalar maxDeltaAngle) { int nobs = m_obstacles.size(); @@ -433,7 +433,7 @@ KX_ObstacleSimulationTOI_rays::KX_ObstacleSimulationTOI_rays(MT_Scalar levelHeig } -void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, +void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, const float maxDeltaAngle) { MT_Vector2 vel(activeObst->dvel[0], activeObst->dvel[1]); @@ -580,7 +580,7 @@ void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMes ///////////********* TOI_cells**********///////////////// -static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, +static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, KX_Obstacles& obstacles, float levelHeight, const float vmax, const float* spos, const float cs, const int nspos, float* res, float maxToi, float velWeight, float curVelWeight, float sideWeight, @@ -596,7 +596,7 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM } float activeObstPos[2]; - vset(activeObstPos, activeObst->m_pos.x(), activeObst->m_pos.y()); + vset(activeObstPos, activeObst->m_pos.x(), activeObst->m_pos.y()); /* adist = vdot(adir, activeObstPos); */ float minPenalty = FLT_MAX; @@ -630,7 +630,7 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM // Side // NOTE: dp, and dv are constant over the whole calculation, - // they can be precomputed per object. + // they can be precomputed per object. const float* pa = activeObstPos; float pb[2]; vset(pb, ob->m_pos.x(), ob->m_pos.y()); @@ -739,7 +739,7 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM } } -void KX_ObstacleSimulationTOI_cells::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, +void KX_ObstacleSimulationTOI_cells::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, const float maxDeltaAngle) { vset(activeObst->nvel, 0.f, 0.f); @@ -771,7 +771,7 @@ void KX_ObstacleSimulationTOI_cells::sampleRVO(KX_Obstacle* activeObst, KX_NavMe } } } - processSamples(activeObst, activeNavMeshObj, m_obstacles, m_levelHeight, vmax, spos, cs/2, + processSamples(activeObst, activeNavMeshObj, m_obstacles, m_levelHeight, vmax, spos, cs/2, nspos, activeObst->nvel, m_maxToi, m_velWeight, m_curVelWeight, m_collisionWeight, m_toiWeight); } else diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.h b/source/gameengine/Ketsji/KX_ObstacleSimulation.h index 50589b5bc69..a49911e9fb8 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.h +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.h @@ -1,5 +1,5 @@ /* - * Simulation for obstacle avoidance behavior + * Simulation for obstacle avoidance behavior * (based on Cane Project - http://code.google.com/p/cane by Mikko Mononen (c) 2009) * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -35,13 +35,13 @@ class KX_NavMeshObject; enum KX_OBSTACLE_TYPE { - KX_OBSTACLE_OBJ, + KX_OBSTACLE_OBJ, KX_OBSTACLE_NAV_MESH, }; enum KX_OBSTACLE_SHAPE { - KX_OBSTACLE_CIRCLE, + KX_OBSTACLE_CIRCLE, KX_OBSTACLE_SEGMENT, }; @@ -53,7 +53,7 @@ struct KX_Obstacle MT_Point3 m_pos; MT_Point3 m_pos2; MT_Scalar m_rad; - + float vel[2]; float pvel[2]; float dvel[2]; @@ -61,7 +61,7 @@ struct KX_Obstacle float hvel[VEL_HIST_SIZE*2]; int hhead; - + KX_GameObject* m_gameObj; }; typedef std::vector<KX_Obstacle*> KX_Obstacles; @@ -87,7 +87,7 @@ public: void AddObstaclesForNavMesh(KX_NavMeshObject* navmesh); KX_Obstacle* GetObstacle(KX_GameObject* gameobj); void UpdateObstacles(); - virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, + virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle); }; @@ -102,18 +102,18 @@ protected: float m_toiWeight; // Sample selection TOI weight float m_collisionWeight; // Sample selection collision weight - virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, + virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, const float maxDeltaAngle) = 0; public: KX_ObstacleSimulationTOI(MT_Scalar levelHeight, bool enableVisualization); - virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, + virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle); }; class KX_ObstacleSimulationTOI_rays: public KX_ObstacleSimulationTOI { protected: - virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, + virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, const float maxDeltaAngle); public: KX_ObstacleSimulationTOI_rays(MT_Scalar levelHeight, bool enableVisualization); @@ -125,7 +125,7 @@ protected: float m_bias; bool m_adaptive; int m_sampleRadius; - virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, + virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, const float maxDeltaAngle); public: KX_ObstacleSimulationTOI_cells(MT_Scalar levelHeight, bool enableVisualization); diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index bcaa1e60e92..16a9441acc7 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -45,9 +45,9 @@ void KX_OrientationInterpolator::Execute(float currentTime) const 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; + MT_Scalar cc = ci*ch; + MT_Scalar cs = ci*sh; + MT_Scalar sc = si*ch; MT_Scalar ss = si*sh; m_target.setValue(cj*ch, sj*sc-cs, sj*cc+ss, diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.h b/source/gameengine/Ketsji/KX_OrientationInterpolator.h index 59014b70174..195b414a72c 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.h +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.h @@ -47,7 +47,7 @@ public: m_ipos[1] = ipos[1]; m_ipos[2] = ipos[2]; } - + virtual void Execute(float currentTime) const; private: diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 0b133400920..fd4ef89aa85 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -37,13 +37,13 @@ #include "KX_GameObject.h" #include "KX_PythonInit.h" -#include "EXP_PyObjectPlus.h" +#include "EXP_PyObjectPlus.h" /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ -KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj, +KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj, int mode, bool addToCompound, bool ghost, @@ -56,7 +56,7 @@ KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj, { if (m_ob) m_ob->RegisterActuator(this); -} +} @@ -64,7 +64,7 @@ KX_ParentActuator::~KX_ParentActuator() { if (m_ob) m_ob->UnregisterActuator(this); -} +} @@ -127,7 +127,7 @@ bool KX_ParentActuator::Update() obj->RemoveParent(scene); break; }; - + return false; } @@ -185,18 +185,18 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE { KX_ParentActuator* actuator = static_cast<KX_ParentActuator*>(self); KX_GameObject *gameobj; - + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_ParentActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error - + if (actuator->m_ob != NULL) actuator->m_ob->UnregisterActuator(actuator); actuator->m_ob = (SCA_IObject*) gameobj; - + if (actuator->m_ob) actuator->m_ob->RegisterActuator(actuator); - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 40baac6b2b2..ebb7ab59460 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -39,17 +39,17 @@ class KX_ParentActuator : public SCA_IActuator { Py_Header - + /** Mode */ int m_mode; - + /** option */ bool m_addToCompound; bool m_ghost; /** Object to set as parent */ SCA_IObject *m_ob; - - + + public: enum KX_PARENTACT_MODE @@ -68,12 +68,12 @@ public: SCA_IObject *ob); virtual ~KX_ParentActuator(); virtual bool Update(); - + virtual CValue* GetReplica(); virtual void ProcessReplica(); virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map); virtual bool UnlinkObject(SCA_IObject* clientobj); - + #ifdef WITH_PYTHON /* --------------------------------------------------------------------- */ @@ -83,7 +83,7 @@ public: /* These are used to get and set m_ob */ static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - + #endif /* WITH_PYTHON */ }; /* end of class KX_ParentActuator : public SCA_PropertyActuator */ diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.h b/source/gameengine/Ketsji/KX_PositionInterpolator.h index b5ab053bb0e..f576a8c25ad 100644 --- a/source/gameengine/Ketsji/KX_PositionInterpolator.h +++ b/source/gameengine/Ketsji/KX_PositionInterpolator.h @@ -39,12 +39,12 @@ class KX_IScalarInterpolator; class KX_PositionInterpolator : public KX_IInterpolator { public: - KX_PositionInterpolator(MT_Point3& target, + KX_PositionInterpolator(MT_Point3& target, KX_IScalarInterpolator *ipos[]) : - m_target(target) + m_target(target) { - m_ipos[0] = ipos[0]; - m_ipos[1] = ipos[1]; + m_ipos[0] = ipos[0]; + m_ipos[1] = ipos[1]; m_ipos[2] = ipos[2]; } diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 81fe3be1fcf..25ffa3fe8b0 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -42,7 +42,7 @@ #include "KX_GameObject.h" // ConvertPythonToGameObject() #include "KX_PythonInit.h" -#include "EXP_PyObjectPlus.h" +#include "EXP_PyObjectPlus.h" #ifdef WITH_BULLET # include "LinearMath/btIDebugDraw.h" @@ -163,7 +163,7 @@ static PyObject *gPySetGravity(PyObject *self, else { return NULL; } - + Py_RETURN_NONE; } @@ -177,14 +177,14 @@ static PyObject *gPySetDebugMode(PyObject *self, if (PHY_GetActiveEnvironment()) { PHY_GetActiveEnvironment()->SetDebugMode(mode); - + } - + } else { return NULL; } - + Py_RETURN_NONE; } @@ -446,7 +446,7 @@ static PyObject *gPyGetVehicleConstraint(PyObject *self, { if (PHY_GetActiveEnvironment()) { - + PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->GetVehicleConstraint(constraintid); if (vehicle) { @@ -478,7 +478,7 @@ static PyObject* gPyGetCharacter(PyObject* self, if (PHY_GetActiveEnvironment()) { - + PHY_ICharacter* character= PHY_GetActiveEnvironment()->GetCharacterController(ob); if (character) { @@ -590,7 +590,7 @@ static PyObject *gPyRemoveConstraint(PyObject *self, else { return NULL; } - + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index ee05fd442ab..2620eed4287 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -50,7 +50,7 @@ bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &rot, const char *error_prefix) { int size= PySequence_Size(pyval); - + if (size == 4) { MT_Quaternion qrot; @@ -69,13 +69,13 @@ bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &rot, const char *error_prefi return true; } PyErr_Clear(); - + if (PyMatTo(pyval, rot)) { return true; } } - + PyErr_Format(PyExc_TypeError, "%s, could not set the orientation from a 3x3 matrix, quaternion or euler sequence", error_prefix); return false; } @@ -105,7 +105,7 @@ PyObject *PyObjectFrom(const MT_Matrix4x4 &mat) PyObject *collist = PyList_New(4); PyObject *col; int i; - + for (i=0; i < 4; i++) { col = PyList_New(4); PyList_SET_ITEM(col, 0, PyFloat_FromDouble(mat[0][i])); @@ -114,7 +114,7 @@ PyObject *PyObjectFrom(const MT_Matrix4x4 &mat) PyList_SET_ITEM(col, 3, PyFloat_FromDouble(mat[3][i])); PyList_SET_ITEM(collist, i, col); } - + return collist; #endif } @@ -129,7 +129,7 @@ PyObject *PyObjectFrom(const MT_Matrix3x3 &mat) PyObject *collist = PyList_New(3); PyObject *col; int i; - + for (i=0; i < 3; i++) { col = PyList_New(3); PyList_SET_ITEM(col, 0, PyFloat_FromDouble(mat[0][i])); @@ -137,7 +137,7 @@ PyObject *PyObjectFrom(const MT_Matrix3x3 &mat) PyList_SET_ITEM(col, 2, PyFloat_FromDouble(mat[2][i])); PyList_SET_ITEM(collist, i, col); } - + return collist; #endif } diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 917fd0fcda6..c9059da8913 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -97,7 +97,7 @@ bool PyMatTo(PyObject *pymat, T& mat) unsigned int rows = PySequence_Size(pymat); if (rows != Size(mat)) return false; - + for (unsigned int row = 0; noerror && row < rows; row++) { PyObject *pyrow = PySequence_GetItem(pymat, row); /* new ref */ @@ -120,12 +120,12 @@ bool PyMatTo(PyObject *pymat, T& mat) } Py_DECREF(pyrow); } - } else + } else noerror = false; - + if (noerror==false) PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)"); - + return noerror; } @@ -137,7 +137,7 @@ bool PyVecTo(PyObject *pyval, T& vec) { #ifdef USE_MATHUTILS /* no need for BaseMath_ReadCallback() here, reading the sequences will do this */ - + if (VectorObject_Check(pyval)) { VectorObject *pyvec= (VectorObject *)pyval; if (BaseMath_ReadCallback(pyvec) == -1) { @@ -183,15 +183,15 @@ bool PyVecTo(PyObject *pyval, T& vec) PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec)); return false; } - + for (unsigned int x = 0; x < numitems; x++) vec[x] = PyFloat_AsDouble(PyTuple_GET_ITEM(pyval, x)); /* borrow ref */ - + if (PyErr_Occurred()) { PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float"); return false; } - + return true; } else if (PyObject_TypeCheck(pyval, (PyTypeObject *)&PyObjectPlus::Type)) { @@ -200,7 +200,7 @@ bool PyVecTo(PyObject *pyval, T& vec) * the parent list each time only to discover its not a sequence. * GameObjects are often used as an alternative to vectors so this is a common case * better to do a quick check for it, likely the error below will be ignored. - * + * * This is not 'correct' since we have proxy type CListValues's which could * contain floats/ints but there no cases of CValueLists being this way */ @@ -213,24 +213,24 @@ bool PyVecTo(PyObject *pyval, T& vec) PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec)); return false; } - + for (unsigned int x = 0; x < numitems; x++) { PyObject *item = PySequence_GetItem(pyval, x); /* new ref */ vec[x] = PyFloat_AsDouble(item); Py_DECREF(item); } - + if (PyErr_Occurred()) { PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float"); return false; } - + return true; } else { PyErr_Format(PyExc_AttributeError, "not a sequence type, expected a sequence of numbers size %d", Size(vec)); } - + return false; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 8870224da83..35adbc2d720 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -117,7 +117,7 @@ extern "C" { #include "EXP_PyObjectPlus.h" -#include "KX_PythonInitTypes.h" +#include "KX_PythonInitTypes.h" /* we only need this to get a list of libraries from the main struct */ #include "DNA_ID.h" @@ -240,7 +240,7 @@ static PyObject *gPySetGravity(PyObject *, PyObject *value) if (gp_KetsjiScene) gp_KetsjiScene->SetGravity(vec); - + Py_RETURN_NONE; } @@ -257,7 +257,7 @@ static PyObject *gPyExpandPath(PyObject *, PyObject *args) { char expanded[FILE_MAX]; char* filename; - + if (!PyArg_ParseTuple(args,"s:ExpandPath",&filename)) return NULL; @@ -441,7 +441,7 @@ static PyObject *gPySetLogicTicRate(PyObject *, PyObject *args) float ticrate; if (!PyArg_ParseTuple(args, "f:setLogicTicRate", &ticrate)) return NULL; - + KX_KetsjiEngine::SetTicRate(ticrate); Py_RETURN_NONE; } @@ -485,7 +485,7 @@ static PyObject *gPySetMaxLogicFrame(PyObject *, PyObject *args) int frame; if (!PyArg_ParseTuple(args, "i:setMaxLogicFrame", &frame)) return NULL; - + KX_KetsjiEngine::SetMaxLogicFrame(frame); Py_RETURN_NONE; } @@ -500,7 +500,7 @@ static PyObject *gPySetMaxPhysicsFrame(PyObject *, PyObject *args) int frame; if (!PyArg_ParseTuple(args, "i:setMaxPhysicsFrame", &frame)) return NULL; - + KX_KetsjiEngine::SetMaxPhysicsFrame(frame); Py_RETURN_NONE; } @@ -515,7 +515,7 @@ static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args) float ticrate; if (!PyArg_ParseTuple(args, "f:setPhysicsTicRate", &ticrate)) return NULL; - + PHY_GetActiveEnvironment()->SetFixedTimeStep(true,ticrate); Py_RETURN_NONE; } @@ -525,7 +525,7 @@ static PyObject *gPySetPhysicsDebug(PyObject *, PyObject *args) int debugMode; if (!PyArg_ParseTuple(args, "i:setPhysicsDebug", &debugMode)) return NULL; - + PHY_GetActiveEnvironment()->setDebugMode(debugMode); Py_RETURN_NONE; } @@ -634,7 +634,7 @@ static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) return NULL; list = PyList_New(0); - + if (searchpath) { BLI_strncpy(cpath, searchpath, FILE_MAX); BLI_path_abs(cpath, gp_GamePythonPath); @@ -648,7 +648,7 @@ static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) fprintf(stderr, "Could not read directory (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno)); return list; } - + while ((dirp = readdir(dp)) != NULL) { if (BLI_path_extension_check(dirp->d_name, ".blend")) { value = PyC_UnicodeFromByte(dirp->d_name); @@ -656,7 +656,7 @@ static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) Py_DECREF(value); } } - + closedir(dp); return list; } @@ -671,10 +671,10 @@ static PyObject *gPyAddScene(PyObject *, PyObject *args) { char* name; int overlay = 1; - + if (!PyArg_ParseTuple(args, "s|i:addScene", &name , &overlay)) return NULL; - + gp_KetsjiEngine->ConvertAndAddScene(name, (overlay != 0)); Py_RETURN_NONE; @@ -700,9 +700,9 @@ static PyObject *gPyGetSceneList(PyObject *self) KX_SceneList* scenes = m_engine->CurrentScenes(); int numScenes = scenes->size(); int i; - + list = PyList_New(numScenes); - + for (i=0;i<numScenes;i++) { KX_Scene* scene = scenes->at(i); @@ -742,7 +742,7 @@ static PyObject *gLibLoad(PyObject *, PyObject *args, PyObject *kwds) int load_actions=0, verbose=0, load_scripts=1, async=0; static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", "load_scripts", "async", NULL}; - + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*iiIi:LibLoad", const_cast<char**>(kwlist), &path, &group, &py_buffer, &load_actions, &verbose, &load_scripts, &async)) return NULL; @@ -778,12 +778,12 @@ static PyObject *gLibLoad(PyObject *, PyObject *args, PyObject *kwds) PyBuffer_Release(&py_buffer); } - + if (err_str) { PyErr_SetString(PyExc_ValueError, err_str); return NULL; } - + Py_RETURN_FALSE; } @@ -798,23 +798,23 @@ static PyObject *gLibNew(PyObject *, PyObject *args) if (!PyArg_ParseTuple(args,"ssO!:LibNew",&path, &group, &PyList_Type, &names)) return NULL; - + if (kx_scene->GetSceneConverter()->GetMainDynamicPath(path)) { PyErr_SetString(PyExc_KeyError, "the name of the path given exists"); return NULL; } - + idcode= BKE_idcode_from_name(group); if (idcode==0) { PyErr_Format(PyExc_ValueError, "invalid group given \"%s\"", group); return NULL; } - + Main *maggie=BKE_main_new(); kx_scene->GetSceneConverter()->GetMainDynamic().push_back(maggie); strncpy(maggie->name, path, sizeof(maggie->name)-1); - + /* Copy the object into main */ if (idcode==ID_ME) { PyObject *ret= PyList_New(0); @@ -834,14 +834,14 @@ static PyObject *gLibNew(PyObject *, PyObject *args) PyErr_Clear(); /* wasnt a string, ignore for now */ } } - + return ret; } else { PyErr_Format(PyExc_ValueError, "only \"Mesh\" group currently supported"); return NULL; } - + Py_RETURN_NONE; } @@ -867,12 +867,12 @@ static PyObject *gLibList(PyObject *, PyObject *args) vector<Main*> &dynMaggie = gp_KetsjiScene->GetSceneConverter()->GetMainDynamic(); int i= 0; PyObject *list= PyList_New(dynMaggie.size()); - + for (vector<Main*>::iterator it=dynMaggie.begin(); !(it==dynMaggie.end()); it++) { PyList_SET_ITEM(list, i++, PyUnicode_FromString( (*it)->name) ); } - + return list; } @@ -883,7 +883,7 @@ static PyObject *gPyNextFrame(PyObject *) if (pynextframestate.state == NULL) Py_RETURN_NONE; //should never happen; raise exception instead? if (pynextframestate.func(pynextframestate.state)) //nonzero = stop - { + { Py_RETURN_TRUE; } else // 0 = go on @@ -945,7 +945,7 @@ static struct PyMethodDef game_methods[] = { {"LibNew", (PyCFunction)gLibNew, METH_VARARGS, (const char *)""}, {"LibFree", (PyCFunction)gLibFree, METH_VARARGS, (const char *)""}, {"LibList", (PyCFunction)gLibList, METH_VARARGS, (const char *)""}, - + {NULL, (PyCFunction) NULL, 0, NULL } }; @@ -971,7 +971,7 @@ static PyObject *gPyEnableVisibility(PyObject *, PyObject *args) int visible; if (!PyArg_ParseTuple(args,"i:enableVisibility",&visible)) return NULL; - + gUseVisibilityTemp = (visible != 0); Py_RETURN_NONE; } @@ -983,7 +983,7 @@ static PyObject *gPyShowMouse(PyObject *, PyObject *args) int visible; if (!PyArg_ParseTuple(args,"i:showMouse",&visible)) return NULL; - + if (visible) { if (gp_Canvas) @@ -993,7 +993,7 @@ static PyObject *gPyShowMouse(PyObject *, PyObject *args) if (gp_Canvas) gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); } - + Py_RETURN_NONE; } @@ -1004,10 +1004,10 @@ static PyObject *gPySetMousePosition(PyObject *, PyObject *args) int x,y; if (!PyArg_ParseTuple(args,"ii:setMousePosition",&x,&y)) return NULL; - + if (gp_Canvas) gp_Canvas->SetMousePosition(x,y); - + Py_RETURN_NONE; } @@ -1021,9 +1021,9 @@ static PyObject *gPySetEyeSeparation(PyObject *, PyObject *args) PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setEyeSeparation(float), Rasterizer not available"); return NULL; } - + gp_Rasterizer->SetEyeSeparation(sep); - + Py_RETURN_NONE; } @@ -1033,7 +1033,7 @@ static PyObject *gPyGetEyeSeparation(PyObject *) PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getEyeSeparation(), Rasterizer not available"); return NULL; } - + return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation()); } @@ -1042,14 +1042,14 @@ static PyObject *gPySetFocalLength(PyObject *, PyObject *args) float focus; if (!PyArg_ParseTuple(args, "f:setFocalLength", &focus)) return NULL; - + if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setFocalLength(float), Rasterizer not available"); return NULL; } gp_Rasterizer->SetFocalLength(focus); - + Py_RETURN_NONE; } @@ -1059,9 +1059,9 @@ static PyObject *gPyGetFocalLength(PyObject *, PyObject *, PyObject *) PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getFocalLength(), Rasterizer not available"); return NULL; } - + return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength()); - + Py_RETURN_NONE; } @@ -1103,12 +1103,12 @@ static PyObject *gPyMakeScreenshot(PyObject *, PyObject *args) char* filename; if (!PyArg_ParseTuple(args,"s:makeScreenshot",&filename)) return NULL; - + if (gp_Canvas) { gp_Canvas->MakeScreenShot(filename); } - + Py_RETURN_NONE; } @@ -1117,14 +1117,14 @@ static PyObject *gPyEnableMotionBlur(PyObject *, PyObject *args) float motionblurvalue; if (!PyArg_ParseTuple(args,"f:enableMotionBlur",&motionblurvalue)) return NULL; - + if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.enableMotionBlur(float), Rasterizer not available"); return NULL; } - + gp_Rasterizer->EnableMotionBlur(motionblurvalue); - + Py_RETURN_NONE; } @@ -1134,9 +1134,9 @@ static PyObject *gPyDisableMotionBlur(PyObject *) PyErr_SetString(PyExc_RuntimeError, "Rasterizer.disableMotionBlur(), Rasterizer not available"); return NULL; } - + gp_Rasterizer->DisableMotionBlur(); - + Py_RETURN_NONE; } @@ -1168,16 +1168,16 @@ static PyObject *gPySetGLSLMaterialSetting(PyObject *, if (!PyArg_ParseTuple(args,"si:setGLSLMaterialSetting",&setting,&enable)) return NULL; - + flag = getGLSLSettingFlag(setting); - + if (flag == -1) { PyErr_SetString(PyExc_ValueError, "Rasterizer.setGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } sceneflag= gs->glslflag; - + if (enable) gs->glslflag &= ~flag; else @@ -1214,9 +1214,9 @@ static PyObject *gPyGetGLSLMaterialSetting(PyObject *, if (!PyArg_ParseTuple(args,"s:getGLSLMaterialSetting",&setting)) return NULL; - + flag = getGLSLSettingFlag(setting); - + if (flag == -1) { PyErr_SetString(PyExc_ValueError, "Rasterizer.getGLSLMaterialSetting(string): glsl setting is not known"); return NULL; @@ -1260,7 +1260,7 @@ static PyObject *gPyGetMaterialType(PyObject *) flag = KX_BLENDER_GLSL_MATERIAL; else flag = KX_BLENDER_MULTITEX_MATERIAL; - + return PyLong_FromLong(flag); } @@ -1311,7 +1311,7 @@ static PyObject *gPyDrawLine(PyObject *, PyObject *args) return NULL; gp_Rasterizer->DrawDebugLine(gp_KetsjiScene, from, to, color); - + Py_RETURN_NONE; } @@ -1714,10 +1714,10 @@ PyMODINIT_FUNC initGameLogicPythonBinding() // Add some symbolic constants to the module d = PyModule_GetDict(m); - + // can be overwritten later for gameEngine instances that can load new blend files and re-initialize this module // for now its safe to make sure it exists for other areas such as the web plugin - + PyDict_SetItemString(d, "globalDict", item=PyDict_New()); Py_DECREF(item); // Add keyboard and mouse attributes to this module @@ -1753,7 +1753,7 @@ PyMODINIT_FUNC initGameLogicPythonBinding() ErrorObject = PyUnicode_FromString("GameLogic.error"); PyDict_SetItemString(d, "error", ErrorObject); Py_DECREF(ErrorObject); - + // XXXX Add constants here /* To use logic bricks, we need some sort of constants. Here, we associate */ /* constants and sumbolic names. Add them to dictionary d. */ @@ -1827,7 +1827,7 @@ PyMODINIT_FUNC initGameLogicPythonBinding() KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP, ACT_ACTION_LOOP_STOP); KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND, ACT_ACTION_LOOP_END); KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY, ACT_ACTION_FROM_PROP); - + /* 7. GL_BlendFunc */ KX_MACRO_addTypesToDict(d, BL_ZERO, GL_ZERO); KX_MACRO_addTypesToDict(d, BL_ONE, GL_ONE); @@ -1890,13 +1890,13 @@ PyMODINIT_FUNC initGameLogicPythonBinding() KX_MACRO_addTypesToDict(d, KX_STATE28, (1<<27)); KX_MACRO_addTypesToDict(d, KX_STATE29, (1<<28)); KX_MACRO_addTypesToDict(d, KX_STATE30, (1<<29)); - + /* All Sensors */ KX_MACRO_addTypesToDict(d, KX_SENSOR_JUST_ACTIVATED, SCA_ISensor::KX_SENSOR_JUST_ACTIVATED); KX_MACRO_addTypesToDict(d, KX_SENSOR_ACTIVE, SCA_ISensor::KX_SENSOR_ACTIVE); KX_MACRO_addTypesToDict(d, KX_SENSOR_JUST_DEACTIVATED, SCA_ISensor::KX_SENSOR_JUST_DEACTIVATED); KX_MACRO_addTypesToDict(d, KX_SENSOR_INACTIVE, SCA_ISensor::KX_SENSOR_INACTIVE); - + /* Radar Sensor */ KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_POS_X, KX_RadarSensor::KX_RADAR_AXIS_POS_X); KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_POS_Y, KX_RadarSensor::KX_RADAR_AXIS_POS_Y); @@ -1936,7 +1936,7 @@ PyMODINIT_FUNC initGameLogicPythonBinding() KX_MACRO_addTypesToDict(d, KX_INPUT_JUST_ACTIVATED, SCA_InputEvent::KX_JUSTACTIVATED); KX_MACRO_addTypesToDict(d, KX_INPUT_ACTIVE, SCA_InputEvent::KX_ACTIVE); KX_MACRO_addTypesToDict(d, KX_INPUT_JUST_RELEASED, SCA_InputEvent::KX_JUSTRELEASED); - + KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_LEFT, SCA_IInputDevice::KX_LEFTMOUSE); KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_MIDDLE, SCA_IInputDevice::KX_MIDDLEMOUSE); KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_RIGHT, SCA_IInputDevice::KX_RIGHTMOUSE); @@ -2079,16 +2079,16 @@ PyMODINIT_FUNC initGameLogicPythonBinding() /** * Explanation of - * + * * - 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 * so we cant just add to sys.path all the time, it would leave pythons state in a mess. * It would also be incorrect since loading blend files for new levels etc would always add to sys.path - * + * * To play nice with blenders python, the sys.path is backed up and the current blendfile along * with all its lib paths are added to the sys path. * When loading a new blendfile, the original sys.path is restored and the new paths are added over the top. @@ -2102,11 +2102,11 @@ static void backupPySysObjects(void) PyObject *sys_path = PySys_GetObject("path"); PyObject *sys_meta_path = PySys_GetObject("meta_path"); PyObject *sys_mods = PySys_GetObject("modules"); - + /* paths */ 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 */ @@ -2114,7 +2114,7 @@ static void backupPySysObjects(void) /* modules */ Py_XDECREF(gp_sys_backup.modules); /* just in case its set */ gp_sys_backup.modules = PyDict_Copy(sys_mods); /* copy the dict */ - + } /* for initPySysObjects only, @@ -2126,26 +2126,26 @@ static void initPySysObjects__append(PyObject *sys_path, const char *filename) { PyObject *item; char expanded[FILE_MAX]; - + BLI_split_dir_part(filename, expanded, sizeof(expanded)); /* get the dir part of filename only */ BLI_path_abs(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */ BLI_cleanup_file(gp_GamePythonPath, expanded); /* Don't use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */ item = PyC_UnicodeFromByte(expanded); - + // printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath); - + if (PySequence_Index(sys_path, item) == -1) { PyErr_Clear(); /* PySequence_Index sets a ValueError */ PyList_Insert(sys_path, 0, item); } - + Py_DECREF(item); } static void initPySysObjects(Main *maggie) { PyObject *sys_path = PySys_GetObject("path"); PyObject *sys_meta_path = PySys_GetObject("meta_path"); - + if (gp_sys_backup.path == NULL) { /* backup */ backupPySysObjects(); @@ -2155,18 +2155,18 @@ static void initPySysObjects(Main *maggie) 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; - + 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); lib= (Library *)lib->id.next; } - + initPySysObjects__append(sys_path, gp_GamePythonPath); - + // fprintf(stderr, "\nNew Path: %d ", PyList_GET_SIZE(sys_path)); // PyObject_Print(sys_path, stderr, 0); } @@ -2191,14 +2191,14 @@ static void restorePySysObjects(void) 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_sys_backup.modules); Py_DECREF(gp_sys_backup.modules); gp_sys_backup.modules = NULL; - - + + // fprintf(stderr, "\nRestore Path: %d ", PyList_GET_SIZE(sys_path)); // PyObject_Print(sys_path, stderr, 0); } @@ -2331,7 +2331,7 @@ PyObject *initGamePlayerPythonScripting(Main *maggie, int argc, char** argv) PyC_SetHomePath(py_path_bundle); Py_Initialize(); - + if (argv && first_time) { /* browser plugins don't currently set this */ // Until python support ascii again, we use our own. // PySys_SetArgv(argc, argv); @@ -2371,7 +2371,7 @@ PyObject *initGamePlayerPythonScripting(Main *maggie, int argc, char** argv) PyDict_SetItemString(PyImport_GetModuleDict(), "bge", initBGE()); first_time = false; - + PyObjectPlus::ClearDeprecationWarning(); return PyC_DefaultNameSpace(NULL); @@ -2395,7 +2395,7 @@ void exitGamePlayerPythonScripting() /* since python restarts we cant let the python backup of the sys.path hang around in a global pointer */ restorePySysObjects(); /* get back the original sys.path and clear the backup */ - + Py_Finalize(); bpy_import_main_set(NULL); PyObjectPlus::ClearDeprecationWarning(); @@ -2560,25 +2560,25 @@ static PyObject *gPyEventToString(PyObject *, PyObject *value) { PyObject *mod, *dict, *key, *val, *ret = NULL; Py_ssize_t pos = 0; - + mod = PyImport_ImportModule( "GameKeys" ); if (!mod) return NULL; - + dict = PyModule_GetDict(mod); - + while (PyDict_Next(dict, &pos, &key, &val)) { if (PyObject_RichCompareBool(value, val, Py_EQ)) { ret = key; break; } } - + PyErr_Clear(); // in case there was an error clearing Py_DECREF(mod); if (!ret) PyErr_SetString(PyExc_ValueError, "GameKeys.EventToString(int): expected a valid int keyboard event"); else Py_INCREF(ret); - + return ret; } @@ -2593,7 +2593,7 @@ static PyObject *gPyEventToCharacter(PyObject *, PyObject *args) int event, shift; if (!PyArg_ParseTuple(args,"ii:EventToCharacter", &event, &shift)) return NULL; - + if (IsPrintable(event)) { char ch[2] = {'\0', '\0'}; ch[0] = ToCharacter(event, (bool)shift); @@ -2662,7 +2662,7 @@ PyMODINIT_FUNC initGameKeysPythonBinding() KX_MACRO_addTypesToDict(d, XKEY, SCA_IInputDevice::KX_XKEY); KX_MACRO_addTypesToDict(d, YKEY, SCA_IInputDevice::KX_YKEY); KX_MACRO_addTypesToDict(d, ZKEY, SCA_IInputDevice::KX_ZKEY); - + KX_MACRO_addTypesToDict(d, ZEROKEY, SCA_IInputDevice::KX_ZEROKEY); KX_MACRO_addTypesToDict(d, ONEKEY, SCA_IInputDevice::KX_ONEKEY); KX_MACRO_addTypesToDict(d, TWOKEY, SCA_IInputDevice::KX_TWOKEY); @@ -2673,16 +2673,16 @@ PyMODINIT_FUNC initGameKeysPythonBinding() KX_MACRO_addTypesToDict(d, SEVENKEY, SCA_IInputDevice::KX_SEVENKEY); KX_MACRO_addTypesToDict(d, EIGHTKEY, SCA_IInputDevice::KX_EIGHTKEY); KX_MACRO_addTypesToDict(d, NINEKEY, SCA_IInputDevice::KX_NINEKEY); - + KX_MACRO_addTypesToDict(d, CAPSLOCKKEY, SCA_IInputDevice::KX_CAPSLOCKKEY); - + KX_MACRO_addTypesToDict(d, LEFTCTRLKEY, SCA_IInputDevice::KX_LEFTCTRLKEY); KX_MACRO_addTypesToDict(d, LEFTALTKEY, SCA_IInputDevice::KX_LEFTALTKEY); KX_MACRO_addTypesToDict(d, RIGHTALTKEY, SCA_IInputDevice::KX_RIGHTALTKEY); KX_MACRO_addTypesToDict(d, RIGHTCTRLKEY, SCA_IInputDevice::KX_RIGHTCTRLKEY); KX_MACRO_addTypesToDict(d, RIGHTSHIFTKEY, SCA_IInputDevice::KX_RIGHTSHIFTKEY); KX_MACRO_addTypesToDict(d, LEFTSHIFTKEY, SCA_IInputDevice::KX_LEFTSHIFTKEY); - + KX_MACRO_addTypesToDict(d, ESCKEY, SCA_IInputDevice::KX_ESCKEY); KX_MACRO_addTypesToDict(d, TABKEY, SCA_IInputDevice::KX_TABKEY); KX_MACRO_addTypesToDict(d, RETKEY, SCA_IInputDevice::KX_RETKEY); @@ -2702,34 +2702,34 @@ PyMODINIT_FUNC initGameKeysPythonBinding() KX_MACRO_addTypesToDict(d, EQUALKEY, SCA_IInputDevice::KX_EQUALKEY); KX_MACRO_addTypesToDict(d, LEFTBRACKETKEY, SCA_IInputDevice::KX_LEFTBRACKETKEY); KX_MACRO_addTypesToDict(d, RIGHTBRACKETKEY, SCA_IInputDevice::KX_RIGHTBRACKETKEY); - + KX_MACRO_addTypesToDict(d, LEFTARROWKEY, SCA_IInputDevice::KX_LEFTARROWKEY); KX_MACRO_addTypesToDict(d, DOWNARROWKEY, SCA_IInputDevice::KX_DOWNARROWKEY); KX_MACRO_addTypesToDict(d, RIGHTARROWKEY, SCA_IInputDevice::KX_RIGHTARROWKEY); KX_MACRO_addTypesToDict(d, UPARROWKEY, SCA_IInputDevice::KX_UPARROWKEY); - + KX_MACRO_addTypesToDict(d, PAD2 , SCA_IInputDevice::KX_PAD2); KX_MACRO_addTypesToDict(d, PAD4 , SCA_IInputDevice::KX_PAD4); KX_MACRO_addTypesToDict(d, PAD6 , SCA_IInputDevice::KX_PAD6); KX_MACRO_addTypesToDict(d, PAD8 , SCA_IInputDevice::KX_PAD8); - + KX_MACRO_addTypesToDict(d, PAD1 , SCA_IInputDevice::KX_PAD1); KX_MACRO_addTypesToDict(d, PAD3 , SCA_IInputDevice::KX_PAD3); KX_MACRO_addTypesToDict(d, PAD5 , SCA_IInputDevice::KX_PAD5); KX_MACRO_addTypesToDict(d, PAD7 , SCA_IInputDevice::KX_PAD7); KX_MACRO_addTypesToDict(d, PAD9 , SCA_IInputDevice::KX_PAD9); - + KX_MACRO_addTypesToDict(d, PADPERIOD, SCA_IInputDevice::KX_PADPERIOD); KX_MACRO_addTypesToDict(d, PADSLASHKEY, SCA_IInputDevice::KX_PADSLASHKEY); KX_MACRO_addTypesToDict(d, PADASTERKEY, SCA_IInputDevice::KX_PADASTERKEY); - - + + KX_MACRO_addTypesToDict(d, PAD0, SCA_IInputDevice::KX_PAD0); KX_MACRO_addTypesToDict(d, PADMINUS, SCA_IInputDevice::KX_PADMINUS); KX_MACRO_addTypesToDict(d, PADENTER, SCA_IInputDevice::KX_PADENTER); KX_MACRO_addTypesToDict(d, PADPLUSKEY, SCA_IInputDevice::KX_PADPLUSKEY); - - + + KX_MACRO_addTypesToDict(d, F1KEY, SCA_IInputDevice::KX_F1KEY); KX_MACRO_addTypesToDict(d, F2KEY, SCA_IInputDevice::KX_F2KEY); KX_MACRO_addTypesToDict(d, F3KEY, SCA_IInputDevice::KX_F3KEY); @@ -2751,7 +2751,7 @@ PyMODINIT_FUNC initGameKeysPythonBinding() KX_MACRO_addTypesToDict(d, F19KEY, SCA_IInputDevice::KX_F19KEY); KX_MACRO_addTypesToDict(d, OSKEY, SCA_IInputDevice::KX_OSKEY); - + KX_MACRO_addTypesToDict(d, PAUSEKEY, SCA_IInputDevice::KX_PAUSEKEY); KX_MACRO_addTypesToDict(d, INSERTKEY, SCA_IInputDevice::KX_INSERTKEY); KX_MACRO_addTypesToDict(d, HOMEKEY, SCA_IInputDevice::KX_HOMEKEY); @@ -2805,7 +2805,7 @@ PyMODINIT_FUNC initApplicationPythonBinding() PyObject *d; m = PyModule_Create(&Application_module_def); - + // Add some symbolic constants to the module d = PyModule_GetDict(m); @@ -2865,7 +2865,7 @@ int saveGamePythonConfig( char **marshal_buffer) // for testing only // PyObject_Print(pyGlobalDictMarshal, stderr, 0); char *marshal_cstring; - + marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal); // py3 uses byte arrays marshal_length= PyBytes_Size(pyGlobalDictMarshal); *marshal_buffer = new char[marshal_length + 1]; @@ -2922,7 +2922,7 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) void pathGamePythonConfig(char *path) { int len = strlen(gp_GamePythonPathOrig); // Always use the first loaded blend filename - + BLI_strncpy(path, gp_GamePythonPathOrig, sizeof(gp_GamePythonPathOrig)); /* replace extension */ @@ -2937,7 +2937,7 @@ void setGamePythonPath(const char *path) { BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath)); BLI_cleanup_file(NULL, gp_GamePythonPath); /* not absolutely needed but makes resolving path problems less confusing later */ - + if (gp_GamePythonPathOrig[0] == '\0') BLI_strncpy(gp_GamePythonPathOrig, path, sizeof(gp_GamePythonPathOrig)); } diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index 4a999e37f2b..a9c90b33cda 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -156,7 +156,7 @@ static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *a PyType_Ready(tp); PyDict_SetItemString(dict, tp->tp_name, reinterpret_cast<PyObject *>(tp)); } - + } diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 861e3f70296..4f7a0e33011 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -70,10 +70,10 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr, //m_client_info->m_auxilary_info = NULL; //sumoObj->setClientObject(&m_client_info); } - + KX_RadarSensor::~KX_RadarSensor() { - + } CValue* KX_RadarSensor::GetReplica() @@ -96,7 +96,7 @@ void KX_RadarSensor::SynchronizeTransform() // is the geometry correctly converted? // a collision cone is oriented - // center the cone correctly + // center the cone correctly // depends on the radar 'axis' switch (m_axis) { @@ -146,7 +146,7 @@ void KX_RadarSensor::SynchronizeTransform() { } } - + //Using a temp variable to translate MT_Point3 to float[3]. //float[3] works better for the Python interface. MT_Point3 temp = trans.getOrigin(); @@ -224,7 +224,7 @@ PyObject *KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DE // The original angle from the gui was converted, so we recalculate the value here to maintain // consistency between Python and the gui return PyFloat_FromDouble(MT_degrees(atan(self->m_coneradius / self->m_coneheight)) * 2); - + } #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h index 6a2d50ffa3a..c0cb7bc65d5 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.h +++ b/source/gameengine/Ketsji/KX_RadarSensor.h @@ -42,7 +42,7 @@ class KX_RadarSensor : public KX_NearSensor { protected: Py_Header - + float m_coneradius; /** @@ -60,7 +60,7 @@ class KX_RadarSensor : public KX_NearSensor * The previous direction of the cone (origin to bottom plane). */ float m_cone_target[3]; - + public: KX_RadarSensor(SCA_EventManager* eventmgr, diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 478019c6304..5d3c943b842 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -61,18 +61,18 @@ void KX_RayCast::reportHit(PHY_RayCastResult* result) bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, KX_RayCast& callback) { if (physics_environment==NULL) return false; /* prevents crashing in some cases */ - + // Loops over all physics objects between frompoint and topoint, // calling callback.RayHit for each one. // // callback.RayHit should return true to stop looking, or false to continue. // // returns true if an object was found, false if not. - + MT_Point3 frompoint(_frompoint); const MT_Vector3 todir( (topoint - frompoint).safe_normalized() ); MT_Point3 prevpoint(_frompoint+todir*(-1.f)); - + PHY_IPhysicsController* hit_controller; while ((hit_controller = physics_environment->RayTest(callback, @@ -80,14 +80,14 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ topoint.x(),topoint.y(),topoint.z())) != NULL) { KX_ClientObjectInfo *info = static_cast<KX_ClientObjectInfo*>(hit_controller->GetNewClientInfo()); - + if (!info) { printf("no info!\n"); MT_assert(info && "Physics controller with no client object info"); break; } - + // The biggest danger to endless loop, prevent this by checking that the // hit point always progresses along the ray direction.. prevpoint -= callback.m_hitPoint; @@ -99,7 +99,7 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ return callback.m_hitFound; // Skip past the object and keep tracing. - // Note that retrieving in a single shot multiple hit points would be possible + // Note that retrieving in a single shot multiple hit points would be possible // 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. */ @@ -110,7 +110,7 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ if (h <= 0.01f) // the normal is almost orthogonal to the ray direction, cannot compute the other side break; - marg /= h; + marg /= h; frompoint = callback.m_hitPoint + marg * todir; // verify that we are not passed the to point if ((topoint - frompoint).dot(todir) < 0.f) diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h index c977fb8f385..32531735de3 100644 --- a/source/gameengine/Ketsji/KX_RayCast.h +++ b/source/gameengine/Ketsji/KX_RayCast.h @@ -38,7 +38,7 @@ #include "MT_Point3.h" #include "MT_Vector3.h" -class RAS_MeshObject; +class RAS_MeshObject; struct KX_ClientObjectInfo; /** @@ -80,23 +80,23 @@ public: */ virtual bool RayHit(KX_ClientObjectInfo* client) = 0; - /** + /** * Callback wrapper. * * Construct with KX_RayCast::Callback<MyClass, MyDataClass>(this, data) * and pass to KX_RayCast::RayTest */ template<class T, class dataT> class Callback; - + /// Public interface. /// Implement bool RayHit in your class to receive ray callbacks. static bool RayTest( - PHY_IPhysicsEnvironment* physics_environment, - const MT_Point3& frompoint, - const MT_Point3& topoint, + PHY_IPhysicsEnvironment* physics_environment, + const MT_Point3& frompoint, + const MT_Point3& topoint, KX_RayCast& callback); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayCast") #endif @@ -119,7 +119,7 @@ public: data(_data) { } - + ~Callback() {} virtual bool RayHit(KX_ClientObjectInfo* client) @@ -130,7 +130,7 @@ public: virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller) { KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->GetNewClientInfo()); - + if (!info) { MT_assert(info && "Physics controller with no client object info"); @@ -138,12 +138,12 @@ public: } return self->NeedRayCast(info, data); } - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayCast::Callback") #endif }; - + #endif diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 4ffb5f332db..5e22bc9661f 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -79,7 +79,7 @@ void KX_RaySensor::Init() m_reset = true; } -KX_RaySensor::~KX_RaySensor() +KX_RaySensor::~KX_RaySensor() { /* Nothing to be done here. */ } @@ -103,7 +103,7 @@ bool KX_RaySensor::IsPositiveTrigger() if (m_invert) result = !result; - + return result; } @@ -148,7 +148,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void m_hitNormal[0] = result->m_hitNormal[0]; m_hitNormal[1] = result->m_hitNormal[1]; m_hitNormal[2] = result->m_hitNormal[2]; - + m_hitMaterial = hitMaterial; } // no multi-hit search yet @@ -196,7 +196,7 @@ bool KX_RaySensor::Evaluate() { bool result = false; bool reset = m_reset && m_level; - m_rayHit = false; + m_rayHit = false; m_hitObject = NULL; m_hitPosition[0] = 0; m_hitPosition[1] = 0; @@ -205,12 +205,12 @@ bool KX_RaySensor::Evaluate() m_hitNormal[0] = 1; m_hitNormal[1] = 0; m_hitNormal[2] = 0; - + KX_GameObject* obj = (KX_GameObject*)GetParent(); MT_Point3 frompoint = obj->NodeGetWorldPosition(); MT_Matrix3x3 matje = obj->NodeGetWorldOrientation(); MT_Matrix3x3 invmat = matje.inverse(); - + MT_Vector3 todir; m_reset = false; switch (m_axis) @@ -271,16 +271,16 @@ bool KX_RaySensor::Evaluate() std::cout << "WARNING: Ray sensor " << GetName() << ": There is no physics environment!" << std::endl; std::cout << " Check universe for malfunction." << std::endl; return false; - } + } PHY_IPhysicsController *spc = obj->GetPhysicsController(); KX_GameObject *parent = obj->GetParent(); if (!spc && parent) spc = parent->GetPhysicsController(); - + PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment(); - + KX_RayCast::Callback<KX_RaySensor, void> callback(this, spc); KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback); diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index 1901bb04f86..e84f29f38ac 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -81,9 +81,9 @@ public: /// \see KX_RayCast bool NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data)); - virtual void Replace_IScene(SCA_IScene *val) - { - m_scene= static_cast<KX_Scene *>(val); + virtual void Replace_IScene(SCA_IScene *val) + { + m_scene= static_cast<KX_Scene *>(val); } //Python Interface @@ -96,12 +96,12 @@ public: KX_RAY_AXIS_NEG_Y = 4, KX_RAY_AXIS_NEG_Z = 5, }; - + #ifdef WITH_PYTHON /* Attributes */ static PyObject *pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - + #endif /* WITH_PYTHON */ }; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index bb38d8269b7..9a94dccdd4e 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -38,7 +38,7 @@ #include "KX_SCA_AddObjectActuator.h" #include "SCA_IScene.h" #include "KX_GameObject.h" -#include "EXP_PyObjectPlus.h" +#include "EXP_PyObjectPlus.h" /* ------------------------------------------------------------------------- */ /* Native functions */ @@ -52,11 +52,11 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj, bool linv_local, const float *angvel, bool angv_local) - : + : SCA_IActuator(gameobj, KX_ACT_ADD_OBJECT), m_OriginalObject(original), m_scene(scene), - + m_localLinvFlag(linv_local), m_localAngvFlag(angv_local) { @@ -72,17 +72,17 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj, m_lastCreatedObject = NULL; m_timeProp = time; -} +} KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator() -{ +{ if (m_OriginalObject) m_OriginalObject->UnregisterActuator(this); if (m_lastCreatedObject) m_lastCreatedObject->UnregisterActuator(this); -} +} @@ -91,26 +91,26 @@ bool KX_SCA_AddObjectActuator::Update() //bool result = false; /*unused*/ bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); - + if (bNegativeEvent) return false; // do nothing on negative events InstantAddObject(); - + return false; } -SCA_IObject* KX_SCA_AddObjectActuator::GetLastCreatedObject() const +SCA_IObject* KX_SCA_AddObjectActuator::GetLastCreatedObject() const { return m_lastCreatedObject; } -CValue* KX_SCA_AddObjectActuator::GetReplica() +CValue* KX_SCA_AddObjectActuator::GetReplica() { KX_SCA_AddObjectActuator* replica = new KX_SCA_AddObjectActuator(*this); @@ -215,18 +215,18 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT { KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self); KX_GameObject *gameobj; - + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SCA_AddObjectActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error - + if (actuator->m_OriginalObject != NULL) actuator->m_OriginalObject->UnregisterActuator(actuator); actuator->m_OriginalObject = (SCA_IObject*)gameobj; - + if (actuator->m_OriginalObject) actuator->m_OriginalObject->RegisterActuator(actuator); - + return PY_SET_ATTR_SUCCESS; } @@ -272,7 +272,7 @@ void KX_SCA_AddObjectActuator::InstantAddObject() m_lastCreatedObject->UnregisterActuator(this); m_lastCreatedObject = NULL; } - + m_lastCreatedObject = replica; // no reference //m_lastCreatedObject->AddRef(); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 976f3c58d68..8ab245b5df3 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -56,24 +56,24 @@ class KX_SCA_AddObjectActuator : public SCA_IActuator /// Object will be added to the following scene SCA_IScene* m_scene; - /// Linear velocity upon creation of the object. + /// Linear velocity upon creation of the object. float m_linear_velocity[3]; - /// Apply the velocity locally + /// Apply the velocity locally bool m_localLinvFlag; - - /// Angular velocity upon creation of the object. + + /// Angular velocity upon creation of the object. float m_angular_velocity[3]; - /// Apply the velocity locally - bool m_localAngvFlag; - - - - + /// Apply the velocity locally + bool m_localAngvFlag; + + + + SCA_IObject* m_lastCreatedObject; - + public: - /** + /** * This class also has the default constructors * available. Use with care! */ @@ -91,11 +91,11 @@ public: ~KX_SCA_AddObjectActuator(void); - CValue* + CValue* GetReplica( ); - virtual void + virtual void ProcessReplica(); virtual void Replace_IScene(SCA_IScene *val) @@ -103,13 +103,13 @@ public: m_scene= val; }; - virtual bool + virtual bool UnlinkObject(SCA_IObject* clientobj); - virtual void + virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map); - virtual bool + virtual bool Update(); SCA_IObject * @@ -125,7 +125,7 @@ public: static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject *pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - + #endif /* WITH_PYTHON */ }; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */ diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index a4220424c6f..5593b16cc33 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -95,7 +95,7 @@ KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj, KX_SCA_DynamicActuator::~KX_SCA_DynamicActuator() -{ +{ // there's nothing to be done here, really.... } /* end of destructor */ @@ -111,7 +111,7 @@ bool KX_SCA_DynamicActuator::Update() if (bNegativeEvent) return false; // do nothing on negative events - + if (!obj) return false; // object not accessible, shouldnt happen controller = obj->GetPhysicsController(); @@ -146,7 +146,7 @@ bool KX_SCA_DynamicActuator::Update() CValue* KX_SCA_DynamicActuator::GetReplica() { - KX_SCA_DynamicActuator* replica = + KX_SCA_DynamicActuator* replica = new KX_SCA_DynamicActuator(*this); if (replica == NULL) diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h index 4eb337c54f5..6118ebd3559 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h @@ -56,11 +56,11 @@ class KX_SCA_DynamicActuator : public SCA_IActuator ~KX_SCA_DynamicActuator( ); - CValue* + CValue* GetReplica( ); - virtual bool + virtual bool Update(); //Python Interface @@ -71,6 +71,6 @@ class KX_SCA_DynamicActuator : public SCA_IActuator KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS, }; -}; +}; #endif diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 81c9dc91603..34d45101a06 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -53,7 +53,7 @@ KX_SCA_EndObjectActuator::KX_SCA_EndObjectActuator(SCA_IObject *gameobj, KX_SCA_EndObjectActuator::~KX_SCA_EndObjectActuator() -{ +{ // there's nothing to be done here, really.... } /* end of destructor */ @@ -68,7 +68,7 @@ bool KX_SCA_EndObjectActuator::Update() if (bNegativeEvent) return false; // do nothing on negative events m_scene->DelayedRemoveObject(GetParent()); - + return false; } @@ -76,7 +76,7 @@ bool KX_SCA_EndObjectActuator::Update() CValue* KX_SCA_EndObjectActuator::GetReplica() { - KX_SCA_EndObjectActuator* replica = + KX_SCA_EndObjectActuator* replica = new KX_SCA_EndObjectActuator(*this); if (replica == NULL) return NULL; diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h index 3399ed90667..aac4fa092f6 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h @@ -52,11 +52,11 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator ~KX_SCA_EndObjectActuator(); - CValue* + CValue* GetReplica( ); - virtual bool + virtual bool Update(); virtual void Replace_IScene(SCA_IScene *val) @@ -67,7 +67,7 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + }; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */ #endif diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 1bf76de0b40..2a071c221e4 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -43,7 +43,7 @@ #include "KX_SCA_ReplaceMeshActuator.h" #include "KX_MeshProxy.h" -#include "EXP_PyObjectPlus.h" +#include "EXP_PyObjectPlus.h" #ifdef WITH_PYTHON @@ -100,10 +100,10 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT { KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self); RAS_MeshObject* new_mesh; - + if (!ConvertPythonToMesh(actuator->GetLogicManager(), value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator")) return PY_SET_ATTR_FAIL; - + actuator->m_mesh = new_mesh; return PY_SET_ATTR_SUCCESS; } @@ -138,7 +138,7 @@ KX_SCA_ReplaceMeshActuator::KX_SCA_ReplaceMeshActuator(SCA_IObject *gameobj, KX_SCA_ReplaceMeshActuator::~KX_SCA_ReplaceMeshActuator() -{ +{ // there's nothing to be done here, really.... } /* end of destructor */ @@ -163,7 +163,7 @@ bool KX_SCA_ReplaceMeshActuator::Update() CValue* KX_SCA_ReplaceMeshActuator::GetReplica() { - KX_SCA_ReplaceMeshActuator* replica = + KX_SCA_ReplaceMeshActuator* replica = new KX_SCA_ReplaceMeshActuator(*this); if (replica == NULL) diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index 4370b5d4a4f..52884d692c6 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -49,13 +49,13 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator // mesh reference (mesh to replace) RAS_MeshObject* m_mesh; SCA_IScene* m_scene; - bool m_use_gfx; + bool m_use_gfx; bool m_use_phys; public: KX_SCA_ReplaceMeshActuator( - SCA_IObject* gameobj, - RAS_MeshObject *mesh, + SCA_IObject* gameobj, + RAS_MeshObject *mesh, SCA_IScene* scene, bool use_gfx, bool use_phys @@ -64,11 +64,11 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator ~KX_SCA_ReplaceMeshActuator( ); - CValue* + CValue* GetReplica( ); - virtual bool + virtual bool Update(); void InstantReplaceMesh(); @@ -91,6 +91,6 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator #endif /* WITH_PYTHON */ -}; +}; #endif /* __KX_SCA_REPLACEMESHACTUATOR_H__ */ diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp index 5a13cf5440d..038de1ead10 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp @@ -31,7 +31,7 @@ #include <iostream> - + #include "KX_SG_BoneParentNodeRelationship.h" #include "MT_Matrix4x4.h" @@ -42,7 +42,7 @@ * Implementation of classes defined in KX_SG_BoneParentNodeRelationship.h */ -/** +/** * first of all KX_SG_BoneParentRelation */ @@ -61,7 +61,7 @@ UpdateChildCoordinates( bool& parentUpdated ) { MT_assert(child != NULL); - + // This way of accessing child coordinates is a bit cumbersome // be nice to have non constant reference access to these values. @@ -72,13 +72,13 @@ UpdateChildCoordinates( parentUpdated = true; // the childs world locations which we will update. - + MT_Vector3 child_w_scale; MT_Point3 child_w_pos; MT_Matrix3x3 child_w_rotation; - + bool valid_parent_transform = false; - + if (parent) { BL_ArmatureObject *armature = (BL_ArmatureObject*)(parent->GetSGClientObject()); @@ -88,34 +88,34 @@ UpdateChildCoordinates( if (armature->GetBoneMatrix(m_bone, parent_matrix)) { // Get the child's transform, and the bone matrix. - MT_Matrix4x4 child_transform ( - MT_Transform(child_pos + MT_Vector3(0.0f, armature->GetBoneLength(m_bone), 0.0f), + MT_Matrix4x4 child_transform ( + MT_Transform(child_pos + MT_Vector3(0.0f, armature->GetBoneLength(m_bone), 0.0f), child_rotation.scaled( - child_scale[0], - child_scale[1], + child_scale[0], + child_scale[1], child_scale[2]))); - + // The child's world transform is parent * child parent_matrix = parent->GetWorldTransform() * parent_matrix; child_transform = parent_matrix * child_transform; - + // Recompute the child transform components from the transform. - child_w_scale.setValue( + child_w_scale.setValue( MT_Vector3(child_transform[0][0], child_transform[0][1], child_transform[0][2]).length(), MT_Vector3(child_transform[1][0], child_transform[1][1], child_transform[1][2]).length(), MT_Vector3(child_transform[2][0], child_transform[2][1], child_transform[2][2]).length()); - 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_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.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]); - + valid_parent_transform = true; } } - } - + } + if (valid_parent_transform) { child->SetWorldScale(child_w_scale); diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h index 6f4fd482198..957d514246b 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h @@ -23,7 +23,7 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - * + * */ /** \file KX_SG_BoneParentNodeRelationship.h @@ -32,14 +32,14 @@ #ifndef __KX_SG_BONEPARENTNODERELATIONSHIP_H__ #define __KX_SG_BONEPARENTNODERELATIONSHIP_H__ - + #include "SG_Spatial.h" #include "SG_ParentRelation.h" struct Bone; /** - * Bone parent relationship parents a child SG_Spatial frame to a + * Bone parent relationship parents a child SG_Spatial frame to a * bone in an armature object. */ class KX_BoneParentRelation : public SG_ParentRelation @@ -54,7 +54,7 @@ public : * to a Blender struct Bone - this should be fixed if */ - static + static KX_BoneParentRelation * New(Bone* bone ); diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp index e80de76861e..ea1c755b88e 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp @@ -36,7 +36,7 @@ * Implementation of classes defined in KX_SG_NodeRelationships.h */ -/** +/** * first of all KX_NormalParentRelation */ @@ -100,7 +100,7 @@ KX_NormalParentRelation( // nothing to do } -/** +/** * Next KX_VertexParentRelation */ @@ -111,8 +111,8 @@ New( ) { return new KX_VertexParentRelation(); } - -/** + +/** * Method inherited from KX_ParentRelation */ @@ -130,18 +130,18 @@ UpdateChildCoordinates( return false; child->SetWorldScale(child->GetLocalScale()); - + if (parent) child->SetWorldPosition(child->GetLocalPosition()+parent->GetWorldPosition()); else child->SetWorldPosition(child->GetLocalPosition()); - + child->SetWorldOrientation(child->GetLocalOrientation()); child->ClearModified(); return true; //parent != NULL; } -/** +/** * Method inherited from KX_ParentRelation */ @@ -178,7 +178,7 @@ New( return new KX_SlowParentRelation(relaxation); } -/** +/** * Method inherited from KX_ParentRelation */ @@ -199,11 +199,11 @@ UpdateChildCoordinates( const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation(); // the childs world locations which we will update. - + MT_Vector3 child_w_scale; MT_Point3 child_w_pos; MT_Matrix3x3 child_w_rotation; - + if (parent) { // This is a slow parent relation @@ -220,7 +220,7 @@ UpdateChildCoordinates( child_n_scale = p_world_scale * child_scale; child_n_rotation = p_world_rotation * child_rotation; - child_n_pos = p_world_pos + p_world_scale * + child_n_pos = p_world_pos + p_world_scale * (p_world_rotation * child_pos); @@ -232,7 +232,7 @@ UpdateChildCoordinates( child_w_pos = child->GetWorldPosition(); child_w_rotation = child->GetWorldOrientation(); - // now 'interpolate' the normal coordinates with the last + // now 'interpolate' the normal coordinates with the last // world coordinates to get the new world coordinates. MT_Scalar weight = MT_Scalar(1)/(m_relax + 1); @@ -248,7 +248,7 @@ UpdateChildCoordinates( child_w_rotation = child_n_rotation; m_initialized = true; } - + } else { child_w_scale = child_scale; @@ -262,11 +262,11 @@ UpdateChildCoordinates( child->ClearModified(); // this node must always be updated, so reschedule it for next time child->ActivateRecheduleUpdateCallback(); - + return true; //parent != NULL; } -/** +/** * Method inherited from KX_ParentRelation */ diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index 5d777f5028f..3b2fdf0272b 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -23,20 +23,20 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - * + * */ - + /** \file KX_SG_NodeRelationships.h * \ingroup ketsji - * \section KX_SG_NodeRelationships - * This file provides common concrete implementations of + * \section KX_SG_NodeRelationships + * This file provides common concrete implementations of * SG_ParentRelation used by the game engine. These are * KX_SlowParentRelation a slow parent relationship. - * KX_NormalParentRelation a normal parent relationship where + * KX_NormalParentRelation a normal parent relationship where * orientation and position are inherited from the parent by * the child. - * KX_VertexParentRelation only location information is - * inherited by the child. + * KX_VertexParentRelation only location information is + * inherited by the child. */ #ifndef __KX_SG_NODERELATIONSHIPS_H__ @@ -54,12 +54,12 @@ public : * on the heap. */ - static + static KX_NormalParentRelation * New( ); - /** + /** * Method inherited from KX_ParentRelation */ @@ -70,10 +70,10 @@ public : bool& parentUpdated ); - /** + /** * Method inherited from KX_ParentRelation */ - + SG_ParentRelation * NewCopy( ); @@ -103,12 +103,12 @@ public : * on the heap. */ - static + static KX_VertexParentRelation * New( ); - /** + /** * Method inherited from KX_ParentRelation */ @@ -119,10 +119,10 @@ public : bool& parentUpdated ); - /** + /** * Method inherited from KX_ParentRelation */ - + SG_ParentRelation * NewCopy( ); @@ -132,7 +132,7 @@ public : bool IsVertexRelation( - ) { + ) { return true; } @@ -158,13 +158,13 @@ public : * on the heap. */ - static + static KX_SlowParentRelation * New( MT_Scalar relaxation ); - /** + /** * Method inherited from KX_ParentRelation */ @@ -175,10 +175,10 @@ public : bool& parentUpdated ); - /** + /** * Method inherited from KX_ParentRelation */ - + SG_ParentRelation * NewCopy( ); @@ -186,7 +186,7 @@ public : MT_Scalar GetTimeOffset( ) { return m_relax; } - + void SetTimeOffset( MT_Scalar relaxation @@ -194,10 +194,10 @@ public : ~KX_SlowParentRelation( ); - + bool IsSlowRelation( - ) { + ) { return true; } @@ -217,7 +217,7 @@ private : * time we update spatial data of the child. This is done * by just doing a normal parent relation the first time * UpdateChildCoordinates is called and then doing the - * slow parent relation + * slow parent relation */ bool m_initialized; diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.h b/source/gameengine/Ketsji/KX_ScalarInterpolator.h index 5d8c3163376..ddb1eb68867 100644 --- a/source/gameengine/Ketsji/KX_ScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalarInterpolator.h @@ -39,12 +39,12 @@ class KX_IScalarInterpolator; class KX_ScalarInterpolator : public KX_IInterpolator { public: - KX_ScalarInterpolator(MT_Scalar* target, + KX_ScalarInterpolator(MT_Scalar* target, KX_IScalarInterpolator *ipo) : m_target(target), m_ipo(ipo) {} - + virtual ~KX_ScalarInterpolator() {} virtual void Execute(float currentTime) const; void SetNewTarget(MT_Scalar* newtarget) diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.h b/source/gameengine/Ketsji/KX_ScalingInterpolator.h index 52b6d0cf8cc..55dfb55f500 100644 --- a/source/gameengine/Ketsji/KX_ScalingInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalingInterpolator.h @@ -43,11 +43,11 @@ public: KX_IScalarInterpolator *ipos[]) : m_target(target) { - m_ipos[0] = ipos[0]; - m_ipos[1] = ipos[1]; + m_ipos[0] = ipos[0]; + m_ipos[1] = ipos[1]; m_ipos[2] = ipos[2]; } - + virtual void Execute(float currentTime) const; private: diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index b3061087344..ef5d1580181 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -150,7 +150,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, class NG_NetworkDeviceInterface *ndi, const STR_String& sceneName, Scene *scene, - class RAS_ICanvas* canvas): + class RAS_ICanvas* canvas): PyObjectPlus(), m_keyboardmgr(NULL), m_mousemgr(NULL), @@ -182,11 +182,11 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_animatedlist = new CListValue(); m_logicmgr = new SCA_LogicManager(); - + m_timemgr = new SCA_TimeEventManager(m_logicmgr); m_keyboardmgr = new SCA_KeyboardManager(m_logicmgr,keyboarddevice); m_mousemgr = new SCA_MouseManager(m_logicmgr,mousedevice, canvas); - + //SCA_AlwaysEventManager* alwaysmgr = new SCA_AlwaysEventManager(m_logicmgr); //SCA_PropertyEventManager* propmgr = new SCA_PropertyEventManager(m_logicmgr); SCA_ActuatorEventManager* actmgr = new SCA_ActuatorEventManager(m_logicmgr); @@ -195,8 +195,8 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, //KX_RayEventManager* raymgr = new KX_RayEventManager(m_logicmgr); KX_NetworkEventManager* netmgr = new KX_NetworkEventManager(m_logicmgr, ndi); - - + + //m_logicmgr->RegisterEventManager(alwaysmgr); //m_logicmgr->RegisterEventManager(propmgr); @@ -220,11 +220,11 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, MT_assert (m_networkDeviceInterface != NULL); m_networkScene = new NG_NetworkScene(m_networkDeviceInterface); - + m_rootnode = NULL; m_bucketmanager=new RAS_BucketManager(); - + bool showObstacleSimulation = (scene->gm.flag & GAME_SHOW_OBSTACLE_SIMULATION) != 0; switch (scene->gm.obstacleSimulation) { @@ -237,7 +237,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, default: m_obstacleSimulation = NULL; } - + #ifdef WITH_PYTHON m_attr_dict = NULL; m_draw_call_pre = NULL; @@ -255,7 +255,7 @@ KX_Scene::~KX_Scene() // reference might be hanging and causing late release of objects RemoveAllDebugProperties(); - while (GetRootParentList()->GetCount() > 0) + while (GetRootParentList()->GetCount() > 0) { KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(0); this->RemoveObject(parentobj); @@ -269,13 +269,13 @@ KX_Scene::~KX_Scene() if (m_parentlist) m_parentlist->Release(); - + if (m_inactivelist) m_inactivelist->Release(); if (m_lightlist) m_lightlist->Release(); - + if (m_tempObjectList) m_tempObjectList->Release(); @@ -293,7 +293,7 @@ KX_Scene::~KX_Scene() if (m_networkScene) delete m_networkScene; - + if (m_bucketmanager) { delete m_bucketmanager; @@ -358,7 +358,7 @@ SCA_TimeEventManager* KX_Scene::GetTimeEventManager() - + list<class KX_Camera*>* KX_Scene::GetCameras() { return &m_cameras; @@ -370,12 +370,12 @@ void KX_Scene::SetFramingType(RAS_FrameSettings & frame_settings) }; /** - * Return a const reference to the framing + * Return a const reference to the framing * type set by the above call. * The contents are not guaranteed to be sensible * if you don't call the above function. */ -const RAS_FrameSettings& KX_Scene::GetFramingType() const +const RAS_FrameSettings& KX_Scene::GetFramingType() const { return m_frame_settings; }; @@ -383,7 +383,7 @@ const RAS_FrameSettings& KX_Scene::GetFramingType() const /** - * Store the current scene's viewport on the + * Store the current scene's viewport on the * game engine canvas. */ void KX_Scene::SetSceneViewport(const RAS_Rect &viewport) @@ -393,7 +393,7 @@ void KX_Scene::SetSceneViewport(const RAS_Rect &viewport) -const RAS_Rect& KX_Scene::GetSceneViewport() const +const RAS_Rect& KX_Scene::GetSceneViewport() const { return m_viewport; } @@ -458,7 +458,7 @@ void KX_Scene::AddObjectDebugProperties(class KX_GameObject* gameobj) if (prop->flag & PROP_DEBUG) AddDebugProperty(gameobj,STR_String(prop->name)); prop = prop->next; - } + } if (blenderobject->scaflag & OB_DEBUGSTATE) AddDebugProperty(gameobj,STR_String("__state__")); @@ -490,10 +490,10 @@ void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gam KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CValue* gameobj) { // for group duplication, limit the duplication of the hierarchy to the - // objects that are part of the group. + // objects that are part of the group. if (!IsObjectInGroup(gameobj)) return NULL; - + KX_GameObject* orgobj = (KX_GameObject*)gameobj; KX_GameObject* newobj = (KX_GameObject*)orgobj->GetReplica(); m_map_gameobject_to_replica.insert(orgobj, newobj); @@ -516,7 +516,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal else { m_rootnode = new SG_Node(newobj,this,KX_Scene::m_callbacks); - + // this fixes part of the scaling-added object bug SG_Node* orgnode = orgobj->GetSGNode(); m_rootnode->SetLocalScale(orgnode->GetLocalScale()); @@ -524,13 +524,13 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal m_rootnode->SetLocalOrientation(orgnode->GetLocalOrientation()); // define the relationship between this node and it's parent. - KX_NormalParentRelation * parent_relation = + KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New(); m_rootnode->SetParentRelation(parent_relation); newobj->SetSGNode(m_rootnode); } - + SG_IObject* replicanode = newobj->GetSGNode(); // SG_Node* rootnode = (replicanode == m_rootnode ? NULL : m_rootnode); @@ -551,7 +551,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal replicanode->RemoveAllControllers(); SGControllerList::iterator cit; //int numcont = scenegraphcontrollers.size(); - + for (cit = scenegraphcontrollers.begin();!(cit==scenegraphcontrollers.end());++cit) { // controller replication is quite complicated @@ -603,8 +603,8 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal // ! // It is VERY important that the order of sensors and actuators in // the replicated object is preserved: it is used to reconnect the logic. -// This method is more robust then using the bricks name in case of complex -// group replication. The replication of logic bricks is done in +// This method is more robust then using the bricks name in case of complex +// group replication. The replication of logic bricks is done in // SCA_IObject::ReParentLogic(), make sure it preserves the order of the bricks. void KX_Scene::ReplicateLogic(KX_GameObject* newobj) { @@ -628,14 +628,14 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) // do it directly on the list at this controller is not connected to anything at this stage cont->GetLinkedSensors().clear(); cont->GetLinkedActuators().clear(); - + // now relink each sensor for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++) { SCA_ISensor* oldsensor = (*its); SCA_IObject* oldsensorobj = oldsensor->GetParent(); SCA_IObject* newsensorobj = NULL; - + // the original owner of the sensor has been replicated? void **h_obj = m_map_gameobject_to_replica[oldsensorobj]; if (h_obj) @@ -657,7 +657,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) for (sensorpos=0, sit=sensorlist.begin(); sit!=sensorlist.end(); sit++, sensorpos++) { - if ((*sit) == oldsensor) + if ((*sit) == oldsensor) { newsensor = newsensorobj->GetSensors().at(sensorpos); break; @@ -667,7 +667,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) m_logicmgr->RegisterToSensor(cont,newsensor); } } - + // now relink each actuator for (vector<SCA_IActuator*>::iterator ita = linkedactuators.begin();!(ita==linkedactuators.end());ita++) { @@ -697,7 +697,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) for (actuatorpos=0, ait=actuatorlist.begin(); ait!=actuatorlist.end(); ait++, actuatorpos++) { - if ((*ait) == oldactuator) + if ((*ait) == oldactuator) { newactuator = newactuatorobj->GetActuators().at(actuatorpos); break; @@ -732,13 +732,13 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) m_logicHierarchicalGameObjects.clear(); m_map_gameobject_to_replica.clear(); m_ueberExecutionPriority++; - // for groups will do something special: + // for groups will do something special: // we will force the creation of objects to those in the group only // Again, this is match what Blender is doing (it doesn't care of parent relationship) m_groupGameObjects.clear(); group = blgroupobj->dup_group; - for (go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next) + for (go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next) { Object* blenderobj = go->ob; if (blgroupobj == blenderobj) @@ -746,10 +746,10 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) continue; gameobj = (KX_GameObject*)m_logicmgr->FindGameObjByBlendObj(blenderobj); - if (gameobj == NULL) + if (gameobj == NULL) { // this object has not been converted!!! - // Should not happen as dupli group are created automatically + // Should not happen as dupli group are created automatically continue; } @@ -794,8 +794,8 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) } // don't replicate logic now: we assume that the objects in the group can have // logic relationship, even outside parent relationship - // In order to match 3D view, the position of groupobj is used as a - // transformation matrix instead of the new position. This means that + // In order to match 3D view, the position of groupobj is used as a + // transformation matrix instead of the new position. This means that // the group reference point is 0,0,0 // get the rootnode's scale @@ -804,7 +804,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) replica->NodeSetRelativeScale(newscale); MT_Point3 offset(group->dupli_ofs); - MT_Point3 newpos = groupobj->NodeGetWorldPosition() + + MT_Point3 newpos = groupobj->NodeGetWorldPosition() + newscale*(groupobj->NodeGetWorldOrientation() * (gameobj->NodeGetWorldPosition()-offset)); replica->NodeSetLocalPosition(newpos); // set the orientation after position for softbody! @@ -828,7 +828,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) { (*git)->ReParentLogic(); } - + // relink any pointers as necessary, sort of a temporary solution for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { @@ -843,7 +843,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) { ReplicateLogic((*git)); } - + // now look if object in the hierarchy have dupli group and recurse for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { @@ -947,7 +947,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, { (*git)->ReParentLogic(); } - + // relink any pointers as necessary, sort of a temporary solution for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { @@ -968,7 +968,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, { ReplicateLogic((*git)); } - + // check if there are objects with dupligroup in the hierarchy vector<KX_GameObject*> duplilist; for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) @@ -1003,7 +1003,7 @@ void KX_Scene::RemoveObject(class CValue* gameobj) // recursively destruct node->Destruct(); } - //no need to do that: the object is destroyed and memory released + //no need to do that: the object is destroyed and memory released //newobj->SetSGNode(0); } @@ -1039,7 +1039,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) /* Invalidate the python reference, since the object may exist in script lists * its possible that it wont be automatically invalidated, so do it manually here, - * + * * if for some reason the object is added back into the scene python can always get a new Proxy */ newobj->InvalidateProxy(); @@ -1054,7 +1054,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) //GetPhysicsEnvironment()->RemovePhysicsController(gameobj->getPhysicsController()); // remove all sensors/controllers/actuators from logicsystem... - + SCA_SensorList& sensors = newobj->GetSensors(); for (SCA_SensorList::iterator its = sensors.begin(); !(its==sensors.end());its++) @@ -1103,7 +1103,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) KX_GameObject* group = newobj->GetDupliGroupObject(); if (group) group->RemoveInstanceObject(newobj); - + newobj->RemoveMeshes(); switch (newobj->GetGameObjectType()) { @@ -1146,9 +1146,9 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) if (m_sceneConverter) m_sceneConverter->UnregisterGameObject(newobj); #endif - + // return value will be 0 if the object is actually deleted (all reference gone) - + return ret; } @@ -1168,18 +1168,18 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u { gameobj->RemoveMeshes(); gameobj->AddMesh(mesh); - + if (gameobj->m_isDeformable) { BL_DeformableGameObject* newobj = static_cast<BL_DeformableGameObject*>( gameobj ); - + if (newobj->GetDeformer()) { delete newobj->GetDeformer(); newobj->SetDeformer(NULL); } - if (mesh->GetMesh()) + if (mesh->GetMesh()) { // we must create a new deformer but which one? KX_GameObject* parentobj = newobj->GetParent(); @@ -1192,7 +1192,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u bool bHasModifier = BL_ModifierDeformer::HasCompatibleDeformer(blendobj); bool bHasShapeKey = blendmesh->key != NULL && blendmesh->key->type==KEY_RELATIVE; bool bHasDvert = blendmesh->dvert != NULL; - bool bHasArmature = + bool bHasArmature = BL_ModifierDeformer::HasArmatureDeformer(blendobj) && parentobj && // current parent is armature parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE && @@ -1203,14 +1203,14 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u #ifdef WITH_BULLET bool bHasSoftBody = (!parentobj && (blendobj->gameflag & OB_SOFT_BODY)); #endif - + if (oldblendobj==NULL) { if (bHasModifier || bHasShapeKey || bHasDvert || bHasArmature) { std::cout << "warning: ReplaceMesh() new mesh is not used in an object from the current scene, you will get incorrect behavior" << std::endl; bHasShapeKey= bHasDvert= bHasArmature=bHasModifier= false; } } - + if (bHasModifier) { BL_ModifierDeformer* modifierDeformer; @@ -1241,7 +1241,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u } else if (bHasShapeKey) { BL_ShapeDeformer* shapeDeformer; - if (bHasArmature) + if (bHasArmature) { shapeDeformer = new BL_ShapeDeformer( newobj, @@ -1266,7 +1266,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u } newobj->SetDeformer( shapeDeformer); } - else if (bHasArmature) + else if (bHasArmature) { BL_SkinDeformer* skinDeformer = new BL_SkinDeformer( newobj, @@ -1368,7 +1368,7 @@ void KX_Scene::SetActiveCamera(KX_Camera* cam) if (!FindCamera(cam)) { AddCamera(cam); if (cam) std::cout << "Added cam " << cam->GetName() << std::endl; - } + } m_active_camera = cam; } @@ -1397,9 +1397,9 @@ void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam { MT_Scalar radius = node->Radius(); MT_Point3 center = node->Center(); - - intersect = cam->SphereInsideFrustum(center, radius); - + + intersect = cam->SphereInsideFrustum(center, radius); + if (intersect == KX_Camera::INTERSECT) { MT_Point3 box[8]; @@ -1437,7 +1437,7 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi if (visible) { int nummeshes = gameobj->GetMeshCount(); - + // this adds the vertices to the display list for (int m=0;m<nummeshes;m++) (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode()); @@ -1458,7 +1458,7 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam // User (Python/Actuator) has forced object invisible... if (!gameobj->GetSGNode() || !gameobj->GetVisible()) return; - + // Shadow lamp layers if (layer && !(gameobj->GetLayer() & layer)) { gameobj->SetCulled(true); @@ -1468,13 +1468,13 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam // If Frustum culling is off, the object is always visible. bool vis = !cam->GetFrustumCulling(); - + // If the camera is inside this node, then the object is visible. if (!vis) { vis = gameobj->GetSGNode()->inside( cam->GetCameraLocation() ); } - + // Test the object's bound sphere against the view frustum. if (!vis) { @@ -1491,16 +1491,16 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam case KX_Camera::INTERSECT: // Test the object's bound box against the view frustum. MT_Point3 box[8]; - gameobj->GetSGNode()->getBBox(box); + gameobj->GetSGNode()->getBBox(box); vis = cam->BoxInsideFrustum(box) != KX_Camera::OUTSIDE; break; } } - + if (vis) { int nummeshes = gameobj->GetMeshCount(); - + for (int m=0;m<nummeshes;m++) { // this adds the vertices to the display list @@ -1534,7 +1534,7 @@ void KX_Scene::PhysicsCullingCallback(KX_ClientObjectInfo *objectInfo, void* cul void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int layer) { bool dbvt_culling = false; - if (m_dbvt_culling) + if (m_dbvt_culling) { /* Reset KX_GameObject m_bCulled to true before doing culling * since DBVT culling will only set it to false. @@ -1581,16 +1581,16 @@ void KX_Scene::LogicBeginFrame(double curtime) { // have a look at temp objects ... int lastobj = m_tempObjectList->GetCount() - 1; - + for (int i = lastobj; i >= 0; i--) { CValue* objval = m_tempObjectList->GetValue(i); CFloatValue* propval = (CFloatValue*) objval->GetProperty("::timebomb"); - + if (propval) { float timeleft = (float)(propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate()); - + if (timeleft > 0) { propval->SetFloat(timeleft); @@ -1811,23 +1811,23 @@ int KX_Scene::GetLodHysteresisValue(void) return m_lodHysteresisValue; } -void KX_Scene::UpdateObjectActivity(void) +void KX_Scene::UpdateObjectActivity(void) { if (m_activity_culling) { /* determine the activity criterium and set objects accordingly */ int i=0; - + MT_Point3 camloc = GetActiveCamera()->NodeGetWorldPosition(); //GetCameraLocation(); - + for (i=0;i<GetObjectList()->GetCount();i++) { KX_GameObject* ob = (KX_GameObject*) GetObjectList()->GetValue(i); - + if (!ob->GetIgnoreActivityCulling()) { /* Simple test: more than 10 away from the camera, count * Manhattan distance. */ MT_Point3 obpos = ob->NodeGetWorldPosition(); - + 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) ) @@ -1848,7 +1848,7 @@ void KX_Scene::SetActivityCullingRadius(float f) f = 0.5f; m_activity_box_radius = f; } - + NG_NetworkDeviceInterface* KX_Scene::GetNetworkDeviceInterface() { return m_networkDeviceInterface; @@ -1897,7 +1897,7 @@ void KX_Scene::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv) m_logicmgr->RegisterEventManager(touchmgr); } } - + void KX_Scene::setSuspendedTime(double suspendedtime) { m_suspendedtime = suspendedtime; @@ -2147,7 +2147,7 @@ bool KX_Scene::MergeScene(KX_Scene *other) for (unsigned int i= 0; i < times.size(); i++) { timemgr->AddTimeProperty(times[i]); } - + } return true; } @@ -2209,10 +2209,10 @@ PyMethodDef KX_Scene::Methods[] = { KX_PYMETHODTABLE(KX_Scene, resume), KX_PYMETHODTABLE(KX_Scene, drawObstacleSimulation), - + /* dict style access */ KX_PYMETHODTABLE(KX_Scene, get), - + {NULL,NULL} //Sentinel }; static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) @@ -2220,7 +2220,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(item); PyObject *pyconvert; - + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, " BGE_PROXY_ERROR_MSG); return NULL; @@ -2228,9 +2228,9 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) if (!self->m_attr_dict) self->m_attr_dict = PyDict_New(); - + if (self->m_attr_dict && (pyconvert=PyDict_GetItem(self->m_attr_dict, item))) { - + if (attr_str) PyErr_Clear(); Py_INCREF(pyconvert); @@ -2241,7 +2241,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) else PyErr_SetString(PyExc_KeyError, "value = scene[key]: KX_Scene, key does not exist"); return NULL; } - + } static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) @@ -2250,7 +2250,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) const char *attr_str= _PyUnicode_AsString(key); if (attr_str==NULL) PyErr_Clear(); - + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, " BGE_PROXY_ERROR_MSG); return -1; @@ -2261,10 +2261,10 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) if (val==NULL) { /* del ob["key"] */ int del= 0; - + if (self->m_attr_dict) del |= (PyDict_DelItem(self->m_attr_dict, key)==0) ? 1:0; - + if (del==0) { if (attr_str) PyErr_Format(PyExc_KeyError, "scene[key] = value: KX_Scene, key \"%s\" could not be set", attr_str); else PyErr_SetString(PyExc_KeyError, "del scene[key]: KX_Scene, key could not be deleted"); @@ -2279,25 +2279,25 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) if (self->m_attr_dict==NULL) /* lazy init */ self->m_attr_dict= PyDict_New(); - - + + if (PyDict_SetItem(self->m_attr_dict, key, val)==0) set= 1; else PyErr_SetString(PyExc_KeyError, "scene[key] = value: KX_Scene, key not be added to internal dictionary"); - + if (set==0) return -1; /* pythons error value */ - + } - + return 0; /* success */ } static int Seq_Contains(PyObject *self_v, PyObject *value) { KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v); - + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, " BGE_PROXY_ERROR_MSG); return -1; @@ -2308,7 +2308,7 @@ static int Seq_Contains(PyObject *self_v, PyObject *value) if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value)) return 1; - + return 0; } @@ -2374,18 +2374,18 @@ PyObject *KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *a * the new CListValue is owned by python, so its possible python holds onto it longer then the BGE * however this is the same with "scene.objects + []", when you make a copy by adding lists. */ - + KX_Scene* self = static_cast<KX_Scene*>(self_v); CListValue* clist = new CListValue(); - + /* return self->GetCameras()->GetProxy(); */ - + list<KX_Camera*>::iterator it = self->GetCameras()->begin(); while (it != self->GetCameras()->end()) { clist->Add((*it)->AddRef()); it++; } - + return clist->NewProxy(true); } @@ -2404,10 +2404,10 @@ int KX_Scene::pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *a { KX_Scene* self = static_cast<KX_Scene*>(self_v); KX_Camera *camOb; - + if (!ConvertPythonToCamera(value, &camOb, false, "scene.active_camera = value: KX_Scene")) return PY_SET_ATTR_FAIL; - + self->SetActiveCamera(camOb); return PY_SET_ATTR_SUCCESS; } @@ -2552,7 +2552,7 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject, return NULL; } SCA_IObject *replica = AddReplicaObject((SCA_IObject*)ob, reference, time); - + // release here because AddReplicaObject AddRef's // the object is added to the scene so we don't want python to own a reference replica->Release(); @@ -2563,9 +2563,9 @@ KX_PYMETHODDEF_DOC(KX_Scene, end, "end()\n" "Removes this scene from the game.\n") { - + KX_GetActiveEngine()->RemoveScene(m_sceneName); - + Py_RETURN_NONE; } @@ -2574,7 +2574,7 @@ KX_PYMETHODDEF_DOC(KX_Scene, restart, "Restarts this scene.\n") { KX_GetActiveEngine()->ReplaceScene(m_sceneName, m_sceneName); - + Py_RETURN_NONE; } @@ -2584,13 +2584,13 @@ KX_PYMETHODDEF_DOC(KX_Scene, replace, "Return True if the new scene exists and scheduled for replacement, False otherwise.\n") { char* name; - + if (!PyArg_ParseTuple(args, "s:replace", &name)) return NULL; - + if (KX_GetActiveEngine()->ReplaceScene(m_sceneName, name)) Py_RETURN_TRUE; - + Py_RETURN_FALSE; } @@ -2599,7 +2599,7 @@ KX_PYMETHODDEF_DOC(KX_Scene, suspend, "Suspends this scene.\n") { Suspend(); - + Py_RETURN_NONE; } @@ -2608,7 +2608,7 @@ KX_PYMETHODDEF_DOC(KX_Scene, resume, "Resumes this scene.\n") { Resume(); - + Py_RETURN_NONE; } @@ -2631,12 +2631,12 @@ KX_PYMETHODDEF_DOC(KX_Scene, get, "") if (!PyArg_ParseTuple(args, "O|O:get", &key, &def)) return NULL; - + if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) { Py_INCREF(ret); return ret; } - + Py_INCREF(def); return def; } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 6d8ae8a321b..d548d1e4892 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -121,7 +121,7 @@ protected: /** * The list of objects which have been removed during the - * course of one frame. They are actually destroyed in + * course of one frame. They are actually destroyed in * LogicEndFrame() via a call to RemoveObject(). */ CListValue* m_euthanasyobjects; @@ -131,7 +131,7 @@ protected: CListValue* m_lightlist; CListValue* m_inactivelist; // all objects that are not in the active layer CListValue* m_animatedlist; // all animated objects - + SG_QList m_sghead; // list of nodes that needs scenegraph update // the Dlist is not object that must be updated // the Qlist is for objects that needs to be rescheduled @@ -180,7 +180,7 @@ protected: * The name of the scene */ STR_String m_sceneName; - + /** * stores the world-settings for a scene */ @@ -217,23 +217,23 @@ protected: /** * Another temporary variable outstaying its welcome - * used in AddReplicaObject to keep a record of all added - * objects. Logic can only be updated when all objects + * used in AddReplicaObject to keep a record of all added + * objects. Logic can only be updated when all objects * have been updated. This stores a list of the new objects. */ std::vector<KX_GameObject*> m_logicHierarchicalGameObjects; - + /** - * This temporary variable will contain the list of + * This temporary variable will contain the list of * object that can be added during group instantiation. - * objects outside this list will not be added (can + * objects outside this list will not be added (can * happen with children that are outside the group). * Used in AddReplicaObject. If the list is empty, it * means don't care. */ std::set<CValue*> m_groupGameObjects; - - /** + + /** * Pointer to system variable passed in in constructor * only used in constructor so we do not need to keep it * around in this class. @@ -261,15 +261,15 @@ protected: * Toggle to enable or disable activity culling. */ bool m_activity_culling; - + /** * Toggle to enable or disable culling via DBVT broadphase of Bullet. */ bool m_dbvt_culling; - + /** * Occlusion culling resolution - */ + */ int m_dbvt_occlusion_res; /** @@ -278,12 +278,12 @@ protected: RAS_FrameSettings m_frame_settings; - /** + /** * This scenes viewport into the game engine * canvas.Maintained externally, initially [0,0] -> [0,0] */ RAS_Rect m_viewport; - + /** * Visibility testing functions. */ @@ -331,8 +331,8 @@ public: void UpdateParents(double curtime); void DupliGroupRecurse(CValue* gameobj, int level); bool IsObjectInGroup(CValue* gameobj) - { - return (m_groupGameObjects.empty() || + { + return (m_groupGameObjects.empty() || m_groupGameObjects.find(gameobj) != m_groupGameObjects.end()); } void AddObjectDebugProperties(class KX_GameObject* gameobj); @@ -346,7 +346,7 @@ public: void RemoveObject(CValue* gameobj); void RemoveDupliGroup(CValue *gameobj); void DelayedRemoveObject(CValue* gameobj); - + int NewRemoveObject(CValue* gameobj); void ReplaceMesh(CValue* gameobj, void* meshob, bool use_gfx, bool use_phys); @@ -396,13 +396,13 @@ public: /** Font Routines */ /** Find a font in the scene by pointer. */ - KX_FontObject* + KX_FontObject* FindFont( KX_FontObject* ); /** Add a camera to this scene. */ - void + void AddFont( KX_FontObject* ); @@ -417,22 +417,22 @@ public: std::list<class KX_Camera*>* GetCameras( ); - + /** Find a camera in the scene by pointer. */ - KX_Camera* + KX_Camera* FindCamera( KX_Camera* ); /** Find a scene in the scene by name. */ - KX_Camera* + KX_Camera* FindCamera( STR_String& ); /** Add a camera to this scene. */ - void + void AddCamera( KX_Camera* ); @@ -442,7 +442,7 @@ public: GetActiveCamera( ); - /** + /** * Set this camera to be the active camera in the scene. If the * camera is not present in the camera list, it will be added */ @@ -505,7 +505,7 @@ public: ); /** - * Return a const reference to the framing + * Return a const reference to the framing * type set by the above call. * The contents are not guaranteed to be sensible * if you don't call the above function. @@ -517,18 +517,18 @@ public: ) const; /** - * Store the current scene's viewport on the + * Store the current scene's viewport on the * game engine canvas. */ void SetSceneViewport(const RAS_Rect &viewport); /** * Get the current scene's viewport on the - * game engine canvas. This maintained + * game engine canvas. This maintained * externally in KX_GameEngine */ const RAS_Rect& GetSceneViewport() const; - + /** * \section Accessors to different scenes of this scene */ @@ -550,7 +550,7 @@ public: static SG_Callbacks m_callbacks; const STR_String& GetName(); - + // Suspend the entire scene. void Suspend(); @@ -565,7 +565,7 @@ public: bool IsActivedLodHysteresis(); void SetLodHysteresisValue(int hysteresisvalue); int GetLodHysteresisValue(); - + // Update the activity box settings for objects in this scene, if needed. void UpdateObjectActivity(void); @@ -584,7 +584,7 @@ public: bool GetDbvtCulling() { return m_dbvt_culling; } void SetDbvtOcclusionRes(int i) { m_dbvt_occlusion_res = i; } int GetDbvtOcclusionRes() { return m_dbvt_occlusion_res; } - + void SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter); class PHY_IPhysicsEnvironment* GetPhysicsEnvironment() @@ -598,7 +598,7 @@ public: MT_Vector3 GetGravity(); short GetAnimationFPS(); - + /** * Sets the node tree for this scene. */ @@ -646,7 +646,7 @@ public: static int pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(GetName()); } - + /* getitem/setitem */ static PyMappingMethods Mapping; static PySequenceMethods Sequence; @@ -655,7 +655,7 @@ public: * Run the registered python drawing functions. */ void RunDrawingCallbacks(PyObject *cb_list); - + PyObject *GetPreDrawCB() { return m_draw_call_pre; } PyObject *GetPostDrawCB() { return m_draw_call_post; } PyObject *GetPreDrawSetupCB() { return m_draw_setup_call_pre; } @@ -663,16 +663,16 @@ public: /** * Sets the time the scene was suspended - */ + */ void setSuspendedTime(double suspendedtime); /** * Returns the "curtime" the scene was suspended - */ + */ double getSuspendedTime(); /** * Sets the difference between the local time of the scene (when it * was running and not suspended) and the "curtime" - */ + */ void setSuspendedDelta(double suspendeddelta); /** * Returns the difference between the local time of the scene (when it diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 6fe33fd2f63..2bef9237bb4 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -44,7 +44,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj, +KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj, int mode, KX_Scene *scene, KX_KetsjiEngine* ketsjiEngine, @@ -64,7 +64,7 @@ KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj, KX_SceneActuator::~KX_SceneActuator() -{ +{ if (m_camera) m_camera->UnregisterActuator(this); } /* end of destructor */ @@ -142,10 +142,10 @@ bool KX_SceneActuator::Update() default: break; } - + if (!m_nextSceneName.Length()) return false; - + switch (m_mode) { case KX_SCENE_SET_SCENE: @@ -183,7 +183,7 @@ bool KX_SceneActuator::Update() default: ; /* do nothing? this is an internal error !!! */ } - + return false; } @@ -261,7 +261,7 @@ PyObject *KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTR KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self); if (!actuator->m_camera) Py_RETURN_NONE; - + return actuator->m_camera->GetProxy(); } @@ -269,13 +269,13 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_ { KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self); KX_Camera *camOb; - + if (!ConvertPythonToCamera(value, &camOb, true, "actu.camera = value: KX_SceneActuator")) return PY_SET_ATTR_FAIL; - + if (actuator->m_camera) actuator->m_camera->UnregisterActuator(actuator); - + if (camOb==NULL) { actuator->m_camera= NULL; } @@ -283,7 +283,7 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_ actuator->m_camera = camOb; actuator->m_camera->RegisterActuator(actuator); } - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 389e9208ef3..c83a0a3a11c 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -39,7 +39,7 @@ class KX_SceneActuator : public SCA_IActuator { Py_Header - + int m_mode; // (restart) has become a toggle internally... not in the interface though bool m_restart; @@ -49,7 +49,7 @@ class KX_SceneActuator : public SCA_IActuator class KX_KetsjiEngine* m_KetsjiEngine; /** The scene to switch to. */ STR_String m_nextSceneName; - + // (Set Camera) Object class KX_Camera* m_camera; @@ -57,7 +57,7 @@ class KX_SceneActuator : public SCA_IActuator class KX_Scene* FindScene(const char* sceneName); /** Is this a valid camera? */ class KX_Camera* FindCamera(const char* cameraName); - + public: enum SCA_SceneActuatorMode { @@ -72,7 +72,7 @@ class KX_SceneActuator : public SCA_IActuator KX_SCENE_RESUME, KX_SCENE_MAX }; - + KX_SceneActuator(SCA_IObject* gameobj, int mode, KX_Scene* scene, @@ -87,7 +87,7 @@ class KX_SceneActuator : public SCA_IActuator virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map); virtual bool Update(); - + #ifdef WITH_PYTHON virtual void Replace_IScene(SCA_IScene *val) @@ -98,7 +98,7 @@ class KX_SceneActuator : public SCA_IActuator /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + static PyObject *pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 64aab31ba22..13549148993 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -172,7 +172,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame) // do nothing on negative events, otherwise sounds are played twice! bool bNegativeEvent = IsNegativeEvent(); bool bPositiveEvent = m_posevent; - + RemoveAllEvents(); if (!m_sound) @@ -221,10 +221,10 @@ bool KX_SoundActuator::Update(double curtime, bool frame) // remember that we tried to stop the actuator m_isplaying = false; } - + #if 1 // Warning: when de-activating the actuator, after a single negative event this runs again with... - // m_posevent==false && m_posevent==false, in this case IsNegativeEvent() returns false + // m_posevent==false && m_posevent==false, in this case IsNegativeEvent() returns false // and assumes this is a positive event. // check that we actually have a positive event so as not to play sounds when being disabled. else if (bPositiveEvent) /* <- added since 2.49 */ @@ -506,7 +506,7 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI } else { return PY_SET_ATTR_FAIL; } - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index d918f87c4bf..870540669c9 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -38,7 +38,7 @@ KX_StateActuator::KX_StateActuator( SCA_IObject* gameobj, int operation, unsigned int mask - ) + ) : SCA_IActuator(gameobj, KX_ACT_STATE), m_operation(operation), m_mask(mask) @@ -79,9 +79,9 @@ KX_StateActuator::Update() if (bNegativeEvent) return false; KX_GameObject *obj = (KX_GameObject*) GetParent(); - + objMask = obj->GetState(); - switch (m_operation) + switch (m_operation) { case OP_CPY: objMask = m_mask; diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h index 5ed065d3604..e62127cab62 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.h +++ b/source/gameengine/Ketsji/KX_StateActuator.h @@ -39,7 +39,7 @@ /* * Use of SG_DList : element of actuator being deactivated * Head: SCA_LogicManager::m_removedActuators - * Use of SG_QList : element of global activated state actuator list + * Use of SG_QList : element of global activated state actuator list * Head: KX_StateActuator::m_stateActuatorHead */ class KX_StateActuator : public SCA_IActuator @@ -64,7 +64,7 @@ class KX_StateActuator : public SCA_IActuator int m_mask; public: - + KX_StateActuator( SCA_IObject* gameobj, int operation, diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp index d3a7b665e61..a57b7e9c5f0 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp +++ b/source/gameengine/Ketsji/KX_SteeringActuator.cpp @@ -82,7 +82,7 @@ KX_SteeringActuator::KX_SteeringActuator(SCA_IObject *gameobj, m_navmesh->RegisterActuator(this); if (m_target) m_target->RegisterActuator(this); - + if (m_simulation) m_obstacle = m_simulation->GetObstacle((KX_GameObject*)gameobj); KX_GameObject* parent = ((KX_GameObject*)gameobj)->GetParent(); @@ -92,7 +92,7 @@ KX_SteeringActuator::KX_SteeringActuator(SCA_IObject *gameobj, } else m_parentlocalmat.setIdentity(); -} +} KX_SteeringActuator::~KX_SteeringActuator() { @@ -100,7 +100,7 @@ KX_SteeringActuator::~KX_SteeringActuator() m_navmesh->UnregisterActuator(this); if (m_target) m_target->UnregisterActuator(this); -} +} CValue* KX_SteeringActuator::GetReplica() { @@ -166,7 +166,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) { double delta = curtime - m_updateTime; m_updateTime = curtime; - + if (m_posevent && !m_isActive) { delta = 0.0; @@ -222,7 +222,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) static const MT_Scalar WAYPOINT_RADIUS(0.25f); - if (m_pathUpdateTime<0 || (m_pathUpdatePeriod>=0 && + if (m_pathUpdateTime<0 || (m_pathUpdatePeriod>=0 && curtime - m_pathUpdateTime>((double)m_pathUpdatePeriod/1000.0))) { m_pathUpdateTime = curtime; @@ -248,7 +248,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) m_steerVec = waypoint - mypos; apply_steerforce = true; - + if (m_enableVisualization) { //debug draw @@ -256,7 +256,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) m_navmesh->DrawPath(m_path, m_pathLen, PATH_COLOR); } } - + } break; } @@ -308,7 +308,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) m_obstacle->dvel[0] = 0.f; m_obstacle->dvel[1] = 0.f; } - + } if (terminate && m_isSelfTerminated) @@ -428,7 +428,7 @@ void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity) MT_Vector3 up(0,0,1); MT_Vector3 left; MT_Matrix3x3 mat; - + if (m_navmesh && m_normalUp) { dtStatNavMesh* navmesh = m_navmesh->GetNavMesh(); @@ -489,16 +489,16 @@ void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity) } mat.setValue ( - left[0], dir[0],up[0], + left[0], dir[0],up[0], left[1], dir[1],up[1], left[2], dir[2],up[2] ); - - + + KX_GameObject* parentObject = curobj->GetParent(); if (parentObject) - { + { MT_Point3 localpos; localpos = curobj->GetSGNode()->GetLocalPosition(); MT_Matrix3x3 parentmatinv; diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.h b/source/gameengine/Ketsji/KX_SteeringActuator.h index 3273471c166..4cdf5777da9 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.h +++ b/source/gameengine/Ketsji/KX_SteeringActuator.h @@ -50,7 +50,7 @@ class KX_SteeringActuator : public SCA_IActuator float m_acceleration; float m_turnspeed; KX_ObstacleSimulation* m_simulation; - + double m_updateTime; KX_Obstacle* m_obstacle; bool m_isActive; @@ -79,10 +79,10 @@ public: KX_SteeringActuator(class SCA_IObject* gameobj, int mode, - KX_GameObject *target, + KX_GameObject *target, KX_GameObject *navmesh, float distance, - float velocity, + float velocity, float acceleration, float turnspeed, bool isSelfTerminated, @@ -114,7 +114,7 @@ public: static PyObject *pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject *pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - + #endif /* WITH_PYTHON */ diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h index e097454fca7..d27cd42c255 100644 --- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h +++ b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h @@ -116,9 +116,9 @@ public: virtual double GetAverage(void); protected: - /** + /** * Disposes loggers. - */ + */ virtual void DisposeLoggers(void); /** Storage for the loggers. */ diff --git a/source/gameengine/Ketsji/KX_TimeLogger.cpp b/source/gameengine/Ketsji/KX_TimeLogger.cpp index 12106245c4d..9693a4a3de0 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.cpp +++ b/source/gameengine/Ketsji/KX_TimeLogger.cpp @@ -32,8 +32,8 @@ #include "KX_TimeLogger.h" -KX_TimeLogger::KX_TimeLogger(unsigned int maxNumMeasurements) : - m_maxNumMeasurements(maxNumMeasurements), +KX_TimeLogger::KX_TimeLogger(unsigned int maxNumMeasurements) : + m_maxNumMeasurements(maxNumMeasurements), m_logStart(0), m_logging(false) { diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 7f167652464..ecaceb9c0ed 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -59,14 +59,14 @@ bool KX_TouchEventManager::NewHandleCollision(void* object1, void* object2, cons PHY_IPhysicsController* obj1 = static_cast<PHY_IPhysicsController*>(object1); PHY_IPhysicsController* obj2 = static_cast<PHY_IPhysicsController*>(object2); - + m_newCollisions.insert(NewCollision(obj1, obj2, coll_data)); - + return false; } -bool KX_TouchEventManager::newCollisionResponse(void *client_data, +bool KX_TouchEventManager::newCollisionResponse(void *client_data, void *object1, void *object2, const PHY_CollData *coll_data) @@ -76,7 +76,7 @@ bool KX_TouchEventManager::newCollisionResponse(void *client_data, return false; } -bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, +bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, void *object1, void *object2, const PHY_CollData *coll_data) @@ -118,13 +118,13 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, break; case KX_ClientObjectInfo::OBSENSOR: case KX_ClientObjectInfo::OBACTORSENSOR: - // this object may have multiple collision sensors, + // this object may have multiple collision sensors, // check is any of them is interested in this object for (std::list<SCA_ISensor*>::iterator it = info1->m_sensors.begin(); it != info1->m_sensors.end(); ++it) { - if ((*it)->GetSensorType() == SCA_ISensor::ST_TOUCH) + if ((*it)->GetSensorType() == SCA_ISensor::ST_TOUCH) { KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*it); if (touchsensor->BroadPhaseSensorFilterCollision(object1, object2)) @@ -178,7 +178,7 @@ void KX_TouchEventManager::NextFrame() SG_DList::iterator<KX_TouchSensor> it(m_sensors); for (it.begin();!it.end();++it) (*it)->SynchronizeTransform(); - + for (std::set<NewCollision>::iterator cit = m_newCollisions.begin(); cit != m_newCollisions.end(); ++cit) { // Controllers @@ -215,9 +215,9 @@ void KX_TouchEventManager::NextFrame() delete cit->colldata; } - + m_newCollisions.clear(); - + for (it.begin();!it.end();++it) (*it)->Activate(m_logicmgr); } diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index d9c6fdad307..916a55ba3c9 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -69,29 +69,29 @@ class KX_TouchEventManager : public SCA_EventManager }; PHY_IPhysicsEnvironment* m_physEnv; - + std::set<NewCollision> m_newCollisions; - - - static bool newCollisionResponse(void *client_data, + + + static bool newCollisionResponse(void *client_data, void *object1, void *object2, const PHY_CollData *coll_data); - static bool newBroadphaseResponse(void *client_data, + static bool newBroadphaseResponse(void *client_data, void *object1, void *object2, const PHY_CollData *coll_data); virtual bool NewHandleCollision(void* obj1,void* obj2, - const PHY_CollData * coll_data); + const PHY_CollData * coll_data); public: - KX_TouchEventManager(class SCA_LogicManager* logicmgr, + KX_TouchEventManager(class SCA_LogicManager* logicmgr, PHY_IPhysicsEnvironment* physEnv); virtual void NextFrame(); virtual void EndFrame(); @@ -100,7 +100,7 @@ public: SCA_LogicManager* GetLogicManager() { return m_logicmgr;} PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; } - + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TouchEventManager") #endif diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 593d3e844e8..d5598164eb0 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -87,10 +87,10 @@ bool KX_TouchSensor::Evaluate() if (reset) // force an event result = true; - + if (m_bTouchPulse) { /* pulse on changes to the colliders */ int count = m_colliders->GetCount(); - + if (m_bLastCount!=count || m_bColliderHash!=m_bLastColliderHash) { m_bLastCount = count; m_bLastColliderHash= m_bColliderHash; @@ -110,16 +110,16 @@ m_hitMaterial("") { // KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr; // m_resptable = touchmgr->GetResponseTable(); - + // m_solidHandle = m_sumoObj->getObjectHandle(); m_colliders = new CListValue(); - + KX_ClientObjectInfo *client_info = gameobj->getClientInfo(); //client_info->m_gameobject = gameobj; //client_info->m_auxilary_info = NULL; client_info->m_sensors.push_back(this); - + m_physCtrl = gameobj->GetPhysicsController(); MT_assert( !gameobj->GetPhysicsController() || m_physCtrl ); Init(); @@ -142,7 +142,7 @@ KX_TouchSensor::~KX_TouchSensor() m_colliders->Release(); } -CValue* KX_TouchSensor::GetReplica() +CValue* KX_TouchSensor::GetReplica() { KX_TouchSensor* replica = new KX_TouchSensor(*this); replica->ProcessReplica(); @@ -162,12 +162,12 @@ void KX_TouchSensor::ReParent(SCA_IObject* parent) PHY_IPhysicsController *sphy = ((KX_GameObject*)parent)->GetPhysicsController(); if (sphy) m_physCtrl = sphy; - + // m_solidHandle = m_sumoObj->getObjectHandle(); KX_ClientObjectInfo *client_info = gameobj->getClientInfo(); //client_info->m_gameobject = gameobj; //client_info->m_auxilary_info = NULL; - + client_info->m_sensors.push_back(this); SCA_ISensor::ReParent(parent); } @@ -217,7 +217,7 @@ bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2) (my_client_info->m_type == KX_ClientObjectInfo::OBACTORSENSOR && client_info->m_type != KX_ClientObjectInfo::ACTOR)) // only with actor objects return false; - + bool found = m_touchedpropname.IsEmpty(); if (!found) { @@ -244,21 +244,21 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll KX_GameObject* parent = (KX_GameObject*)GetParent(); // need the mapping from PHY_IPhysicsController to gameobjects now - - KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (object1 == m_physCtrl? + + KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (object1 == m_physCtrl? ((PHY_IPhysicsController*)object2)->GetNewClientInfo(): ((PHY_IPhysicsController*)object1)->GetNewClientInfo()); - KX_GameObject* gameobj = ( client_info ? - client_info->m_gameobject : + KX_GameObject* gameobj = ( client_info ? + client_info->m_gameobject : NULL); - - // add the same check as in SCA_ISensor::Activate(), + + // add the same check as in SCA_ISensor::Activate(), // we don't want to record collision when the sensor is not active. if (m_links && !m_suspended && gameobj && (gameobj != parent) && client_info->isActor()) { - + bool found = m_touchedpropname.IsEmpty(); bool hitMaterial = false; if (!found) @@ -283,7 +283,7 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll { if (!m_colliders->SearchValue(gameobj)) { m_colliders->Add(gameobj->AddRef()); - + if (m_bTouchPulse) m_bColliderHash += (uint_ptr)(static_cast<void *>(&gameobj)); } @@ -292,8 +292,8 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll m_hitMaterial = hitMaterial; //printf("KX_TouchSensor::HandleCollision\n"); } - - } + + } return false; // was DT_CONTINUE but this was defined in sumo as false. } @@ -344,7 +344,7 @@ PyAttributeDef KX_TouchSensor::Attributes[] = { PyObject *KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_TouchSensor* self = static_cast<KX_TouchSensor*>(self_v); - + if (self->m_hitObject) return self->m_hitObject->GetProxy(); else diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index e1b5725a32b..68ac6ffcc6d 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -59,7 +59,7 @@ protected: STR_String m_touchedpropname; bool m_bFindMaterial; bool m_bTouchPulse; /* changes in the colliding objects trigger pulses */ - + class PHY_IPhysicsController* m_physCtrl; bool m_bCollision; @@ -74,7 +74,7 @@ protected: SCA_IObject* m_hitObject; class CListValue* m_colliders; STR_String m_hitMaterial; - + public: KX_TouchSensor(class SCA_EventManager* eventmgr, class KX_GameObject* gameobj, @@ -89,7 +89,7 @@ public: virtual bool Evaluate(); virtual void Init(); virtual void ReParent(SCA_IObject* parent); - + virtual void RegisterSumo(KX_TouchEventManager* touchman); virtual void UnregisterSumo(KX_TouchEventManager* touchman); virtual void UnregisterToManager(); @@ -107,14 +107,14 @@ public: virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2) { return true; } virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2); virtual sensortype GetSensorType() { return ST_TOUCH; } - + virtual bool IsPositiveTrigger() { bool result = m_bTriggered; if (m_invert) result = !result; return result; } - + virtual void EndFrame(); class PHY_IPhysicsController* GetPhysicsController() { return m_physCtrl; } @@ -127,12 +127,12 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - + static PyObject* pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); #endif - + }; #endif /* __KX_TOUCHSENSOR_H__ */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index a8fa9b0815d..e720af06acb 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -50,7 +50,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, +KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, SCA_IObject *ob, int time, bool allow3D, @@ -64,15 +64,15 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, m_trackflag = trackflag; m_upflag = upflag; m_parentobj = 0; - + if (m_object) m_object->RegisterActuator(this); { // if the object is vertex parented, don't check parent orientation as the link is broken if (!((KX_GameObject*)gameobj)->IsVertexParent()) { - m_parentobj = ((KX_GameObject*)gameobj)->GetParent(); // check if the object is parented - if (m_parentobj) { + m_parentobj = ((KX_GameObject*)gameobj)->GetParent(); // check if the object is parented + if (m_parentobj) { // if so, store the initial local rotation // this is needed to revert the effect of the parent inverse node (TBC) m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation(); @@ -91,26 +91,26 @@ static MT_Matrix3x3 EulToMat3(float eul[3]) { MT_Matrix3x3 mat; float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; - + 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; + cc = ci*ch; + cs = ci*sh; + sc = si*ch; ss = si*sh; - mat[0][0] = cj*ch; - mat[1][0] = sj*sc-cs; + mat[0][0] = cj*ch; + mat[1][0] = sj*sc-cs; mat[2][0] = sj*cc+ss; - mat[0][1] = cj*sh; - mat[1][1] = sj*ss+cc; + mat[0][1] = cj*sh; + mat[1][1] = sj*ss+cc; mat[2][1] = sj*cs-sc; - mat[0][2] = -sj; - mat[1][2] = cj*si; + mat[0][2] = -sj; + mat[1][2] = cj*si; mat[2][2] = cj*ci; return mat; @@ -141,7 +141,7 @@ static void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3]) static void compatible_eulFast(float *eul, float *oldrot) { float dx, dy, dz; - + /* angular difference of 360 degrees */ dx = eul[0] - oldrot[0]; @@ -168,11 +168,11 @@ static MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, in Mat3ToEulOld(oldmat, oldeul); Mat3ToEulOld(mat, eul); compatible_eulFast(eul, oldeul); - + eul[0] = (m_time * oldeul[0] + eul[0]) / (1.0f + m_time); eul[1] = (m_time * oldeul[1] + eul[1]) / (1.0f + m_time); eul[2] = (m_time * oldeul[2] + eul[2]) / (1.0f + m_time); - + return EulToMat3(eul); } @@ -322,13 +322,13 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) mat = vectomat(dir, m_trackflag, m_upflag, m_allow3D); oldmat = curobj->NodeGetWorldOrientation(); - + /* erwin should rewrite this! */ mat = matrix3x3_interpol(oldmat, mat, m_time); - + /* check if the model is parented and calculate the child transform */ if (m_parentobj) { - + MT_Point3 localpos; localpos = curobj->GetSGNode()->GetLocalPosition(); // Get the inverse of the parent matrix @@ -410,18 +410,18 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT { KX_TrackToActuator* actuator = static_cast<KX_TrackToActuator*>(self); KX_GameObject *gameobj; - + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_TrackToActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error - + if (actuator->m_object != NULL) actuator->m_object->UnregisterActuator(actuator); actuator->m_object = (SCA_IObject*) gameobj; - + if (actuator->m_object) actuator->m_object->RegisterActuator(actuator); - + return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 124014eede2..697785c4f59 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -49,7 +49,7 @@ class KX_TrackToActuator : public SCA_IActuator int m_time; int m_trackflag; int m_upflag; - + MT_Matrix3x3 m_parentlocalmat; KX_GameObject* m_parentobj; @@ -90,7 +90,7 @@ class KX_TrackToActuator : public SCA_IActuator /* These are used to get and set m_ob */ static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - + #endif /* WITH_PYTHON */ }; /* end of class KX_TrackToActuator : public KX_EditObjectActuator */ diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index ddae645802c..27ad8c6f685 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -73,13 +73,13 @@ static bool raise_exc_wheel(PHY_IVehicle *vehicle, int i, const char *method) PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args) { - + PyObject *pylistPos,*pylistDir,*pylistAxleDir; PyObject *wheelGameObject; float suspensionRestLength,wheelRadius; int hasSteering; - + if (PyArg_ParseTuple(args,"OOOOffi:addWheel",&wheelGameObject,&pylistPos,&pylistDir,&pylistAxleDir,&suspensionRestLength,&wheelRadius,&hasSteering)) { KX_GameObject *gameOb; @@ -107,7 +107,7 @@ PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args) //someone reverse some conventions inside Bullet (axle winding) attachAxle = -attachAxle; - + if (wheelRadius <= 0) { PyErr_SetString(PyExc_AttributeError, "addWheel(...) Unable to add wheel. wheelRadius must be positive."); @@ -117,7 +117,7 @@ PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args) PHY_IMotionState *motionState = new KX_MotionState(gameOb->GetSGNode()); m_vehicle->AddWheel(motionState,attachPos,attachDir,attachAxle,suspensionRestLength,wheelRadius,hasSteering); } - + } else { return NULL; } @@ -127,7 +127,7 @@ PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args) PyObject *KX_VehicleWrapper::PyGetWheelPosition(PyObject *args) { - + int wheelIndex; if (PyArg_ParseTuple(args,"i:getWheelPosition",&wheelIndex)) diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h index 22b9591f48b..259ca7cc1ba 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.h +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h @@ -23,16 +23,16 @@ public: KX_VehicleWrapper(PHY_IVehicle* vehicle,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_VehicleWrapper (); int getConstraintId(); - + #ifdef WITH_PYTHON - + KX_PYMETHOD_VARARGS(KX_VehicleWrapper,AddWheel); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetNumWheels); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetWheelOrientationQuaternion); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetWheelRotation); - + KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetWheelPosition); - + KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetConstraintId); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetConstraintType); @@ -45,11 +45,11 @@ public: KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetTyreFriction); KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionStiffness); - + KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionDamping); - + KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionCompression); - + KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetRollInfluence); #endif /* WITH_PYTHON */ diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 40f4c462801..2733f774663 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -183,7 +183,7 @@ PyObject *KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF * PyObject *KX_VertexProxy::pyattr_get_uvs(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); - + PyObject* uvlist = PyList_New(RAS_TexVert::MAX_UNIT); for (int i=0; i<RAS_TexVert::MAX_UNIT; ++i) { @@ -431,7 +431,7 @@ int KX_VertexProxy::pyattr_set_uvs(void *self_v, const struct KX_PYATTRIBUTE_DEF return PY_SET_ATTR_FAIL; } } - + self->m_mesh->SetMeshModified(true); return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index 8070825ad11..ce4cb1f8343 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -96,7 +96,7 @@ public: KX_PYMETHOD_O(KX_VertexProxy,SetXYZ); KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV1); KX_PYMETHOD_O(KX_VertexProxy,SetUV1); - + KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV2); KX_PYMETHOD_VARARGS(KX_VertexProxy,SetUV2); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 6f689e228b9..1136dea041b 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -39,7 +39,7 @@ KX_VisibilityActuator::KX_VisibilityActuator( bool visible, bool occlusion, bool recursive - ) + ) : SCA_IActuator(gameobj, KX_ACT_VISIBILITY), m_visible(visible), m_occlusion(occlusion), @@ -69,12 +69,12 @@ bool KX_VisibilityActuator::Update() { bool bNegativeEvent = IsNegativeEvent(); - + RemoveAllEvents(); if (bNegativeEvent) return false; KX_GameObject *obj = (KX_GameObject*) GetParent(); - + obj->SetVisible(m_visible, m_recursive); obj->SetOccluder(m_occlusion, m_recursive); obj->UpdateBuckets(m_recursive); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index a207844db74..8368ab2555d 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -45,7 +45,7 @@ class KX_VisibilityActuator : public SCA_IActuator bool m_recursive; public: - + KX_VisibilityActuator( SCA_IObject* gameobj, bool visible, diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp index be8b1ce92fc..d8b9dabe5f3 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.cpp +++ b/source/gameengine/Ketsji/KX_WorldInfo.cpp @@ -264,7 +264,7 @@ static int mathutils_world_generic_check(BaseMathObject *bmo) KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user); if (self == NULL) return -1; - + return 0; } @@ -399,10 +399,10 @@ PyObject *KX_WorldInfo::pyattr_get_mist_typeconst(void *self_v, const KX_PYATTRI if (!strcmp(type, "KX_MIST_QUADRATIC")) { retvalue = PyLong_FromLong(KX_MIST_QUADRATIC); - } + } else if (!strcmp(type, "KX_MIST_LINEAR")) { retvalue = PyLong_FromLong(KX_MIST_LINEAR); - } + } else if (!strcmp(type, "KX_MIST_INV_QUADRATIC")) { retvalue = PyLong_FromLong(KX_MIST_INV_QUADRATIC); } diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.cpp b/source/gameengine/Ketsji/KX_WorldIpoController.cpp index 1123e07ebcc..ea7e78455d3 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.cpp +++ b/source/gameengine/Ketsji/KX_WorldIpoController.cpp @@ -110,7 +110,7 @@ SG_Controller* KX_WorldIpoController::GetReplica(class SG_Node* destnode) MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; copyipo->SetNewTarget((MT_Scalar*)blaptr); } - + return iporeplica; } @@ -121,5 +121,5 @@ KX_WorldIpoController::~KX_WorldIpoController() for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { delete (*i); } - + } diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index 704f421573e..0e4b408323d 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -57,7 +57,7 @@ private: double m_ipotime; public: - KX_WorldIpoController() : + KX_WorldIpoController() : m_modify_mist_start(false), m_modify_mist_dist(false), m_modify_mist_intensity(false), @@ -72,7 +72,7 @@ public: virtual SG_Controller* GetReplica(class SG_Node* destnode); virtual bool Update(double time); - + virtual void SetSimulatedTime(double time) { m_ipotime = time; m_modified = true; @@ -107,8 +107,8 @@ public: }; void AddInterpolator(KX_IInterpolator* interp); - - + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_WorldIpoController") #endif |