diff options
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/BL_BlenderShader.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Material.h | 5 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Texture.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 88 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.h | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 8 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PolygonMaterial.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 16 |
9 files changed, 38 insertions, 92 deletions
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index f29408fbc6b..8b0bbc645a9 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -160,7 +160,7 @@ void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) if(!mGPUMat) // || !mBound) return; - + MT_Matrix4x4 model; model.setValue(ms.m_OpenGLMatrix); MT_Matrix4x4 view; diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 568f7e171de..dcb66ea2579 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -129,8 +129,7 @@ enum BL_flag TEXALPHA=8, // use alpha combiner functions TEXNEG=16, // negate blending HASIPO=32, - USENEGALPHA=64, - ALPHA_TEST=128 + USENEGALPHA=64 }; // BL_Material::ras_mode @@ -139,7 +138,7 @@ enum BL_ras_mode POLY_VIS=1, COLLIDER=2, ZSORT=4, - TRANSP=8, + ALPHA=8, TRIANGLE=16, USE_LIGHT=32, WIRE=64 diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 204e7b2ce8d..f0ef84032f7 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -384,9 +384,6 @@ void BL_Texture::DisableUnit() void BL_Texture::DisableAllTextures() { - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - for(int i=0; i<MAXTEX; i++) { if(GLEW_ARB_multitexture) glActiveTextureARB(GL_TEXTURE0_ARB+i); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 04ecc9d3230..e3e47bc511f 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -38,7 +38,6 @@ BL_Shader *KX_BlenderMaterial::mLastShader = NULL; BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL; -int KX_BlenderMaterial::mLastBlenderShaderBlend = -1; //static PyObject *gTextureDict = 0; @@ -59,7 +58,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( data->tileyrep[0], data->mode, data->transp, - ((data->ras_mode &TRANSP)!=0), + ((data->ras_mode &ALPHA)!=0), ((data->ras_mode &ZSORT)!=0), lightlayer, ((data->ras_mode &TRIANGLE)!=0), @@ -80,7 +79,6 @@ KX_BlenderMaterial::KX_BlenderMaterial( m_flag |=RAS_BLENDERMAT; m_flag |=(mMaterial->IdMode>=ONETEX)?RAS_MULTITEX:0; m_flag |=(mMaterial->ras_mode & USE_LIGHT)!=0?RAS_MULTILIGHT:0; - m_flag |=(mMaterial->ras_mode &ALPHA_TEST)!=0?RAS_FORCEALPHA:0; // figure max int enabled = mMaterial->num_enabled; @@ -164,11 +162,6 @@ void KX_BlenderMaterial::EndFrame() if(mLastBlenderShader) { mLastBlenderShader->SetProg(false); mLastBlenderShader = NULL; - - if(mLastBlenderShaderBlend != TF_SOLID) { - setBlendingMode(TF_SOLID); - mLastBlenderShaderBlend = TF_SOLID; - } } if(mLastShader) { @@ -195,11 +188,6 @@ void KX_BlenderMaterial::OnExit() if(mBlenderShader == mLastBlenderShader) { mBlenderShader->SetProg(false); mLastBlenderShader = NULL; - - if(mLastBlenderShaderBlend != TF_SOLID) { - setBlendingMode(TF_SOLID); - mLastBlenderShaderBlend = TF_SOLID; - } } delete mBlenderShader; @@ -229,6 +217,8 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) mShader->SetProg(false); mLastShader = NULL; } + + ras->SetBlendingMode(TF_SOLID); BL_Texture::DisableAllTextures(); return; } @@ -249,9 +239,12 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) } if(!mUserDefBlend) { - setBlendingMode(mMaterial->transp); + ras->SetBlendingMode(mMaterial->transp); } else { + ras->SetBlendingMode(TF_SOLID); + ras->SetBlendingMode(-1); // indicates custom mode + // tested to be valid enums glEnable(GL_BLEND); glBlendFunc(mBlendFunc[0], mBlendFunc[1]); @@ -265,43 +258,38 @@ void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras if(mLastBlenderShader) { mLastBlenderShader->SetProg(false); mLastBlenderShader= NULL; - - if(mLastBlenderShaderBlend != TF_SOLID) { - setBlendingMode(TF_SOLID); - mLastBlenderShaderBlend = TF_SOLID; - } } + ras->SetBlendingMode(TF_SOLID); BL_Texture::DisableAllTextures(); return; } if(!mBlenderShader->Equals(mLastBlenderShader)) { + ras->SetBlendingMode(mMaterial->transp); BL_Texture::DisableAllTextures(); - setBlendingMode(mMaterial->transp); - mLastBlenderShaderBlend = mMaterial->transp; - if(mLastBlenderShader) mLastBlenderShader->SetProg(false); mBlenderShader->SetProg(true); mLastBlenderShader= mBlenderShader; } - - // do setBlendingMode with Update() for per object blend modes } void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) { BL_Texture::DisableAllTextures(); - if( !enable ) + + if( !enable ) { + ras->SetBlendingMode(TF_SOLID); return; + } BL_Texture::ActivateFirst(); if( mMaterial->IdMode == DEFAULT_BLENDER ) { - setBlendingMode(mMaterial->transp); + ras->SetBlendingMode(mMaterial->transp); return; } @@ -311,7 +299,7 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) mTextures[0].ActivateTexture(); mTextures[0].setTexEnv(0, true); mTextures[0].SetMapping(mMaterial->mapping[0].mapping); - setBlendingMode(mMaterial->transp); + ras->SetBlendingMode(mMaterial->transp); } return; } @@ -334,9 +322,12 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) } if(!mUserDefBlend) { - setBlendingMode(mMaterial->transp); + ras->SetBlendingMode(mMaterial->transp); } else { + ras->SetBlendingMode(TF_SOLID); + ras->SetBlendingMode(-1); // indicates custom mode + glEnable(GL_BLEND); glBlendFunc(mBlendFunc[0], mBlendFunc[1]); } @@ -356,11 +347,6 @@ KX_BlenderMaterial::ActivatShaders( if(mLastBlenderShader) { mLastBlenderShader->SetProg(false); mLastBlenderShader= NULL; - - if(mLastBlenderShaderBlend != TF_SOLID) { - setBlendingMode(TF_SOLID); - mLastBlenderShaderBlend = TF_SOLID; - } } if (GetCachingInfo() != cachingInfo) { @@ -460,11 +446,6 @@ KX_BlenderMaterial::ActivateMat( if(mLastBlenderShader) { mLastBlenderShader->SetProg(false); mLastBlenderShader= NULL; - - if(mLastBlenderShaderBlend != TF_SOLID) { - setBlendingMode(TF_SOLID); - mLastBlenderShaderBlend = TF_SOLID; - } } if (GetCachingInfo() != cachingInfo) { @@ -576,10 +557,7 @@ void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterize if((blendmode == TF_SOLID || blendmode == TF_ALPHA) && mMaterial->transp != TF_SOLID) blendmode = mMaterial->transp; - if(mLastBlenderShaderBlend != blendmode) { - setBlendingMode(blendmode); - mLastBlenderShaderBlend = blendmode; - } + rasty->SetBlendingMode(blendmode); } } @@ -660,30 +638,6 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const ras->EnableTextures(false); } -void KX_BlenderMaterial::setBlendingMode(int transp) -{ - if(transp == TF_SOLID) { - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else if(transp == TF_ADD) { - glBlendFunc(GL_ONE, GL_ONE); - glEnable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - else if(transp == TF_ALPHA) { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - else if(transp == TF_CLIP) { - glDisable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.5f); - } -} - void KX_BlenderMaterial::setTexMatrixData(int i) { glMatrixMode(GL_TEXTURE); @@ -914,6 +868,8 @@ void KX_BlenderMaterial::SetBlenderGLSLShader(void) delete mBlenderShader; mBlenderShader = 0; } + else + m_flag |= RAS_BLENDERGLSL; } KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()") diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 5bbf81d225c..0d7657b8cdb 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -121,14 +121,11 @@ private: void setLightData(); - static void setBlendingMode(int transp); - // cleanup stuff void OnExit(); // shader chacing static BL_BlenderShader *mLastBlenderShader; - static int mLastBlenderShaderBlend; static BL_Shader *mLastShader; mutable int mPass; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 2baf3eaa43d..009592aa66a 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -119,7 +119,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_bInitialized(false), m_activecam(0), m_bFixedTime(false), - m_game2ipo(false), m_firstframe(true), @@ -149,6 +148,8 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_showBackground(false), m_show_debug_properties(false), + m_game2ipo(false), + // Default behavior is to hide the cursor every frame. m_hideCursor(false), diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 4cdca477740..d0d7c17148a 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -58,7 +58,7 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname, int tileyrep, int mode, int transp, - bool transparant, + bool alpha, bool zsort, int lightlayer, bool bIsTriangle, @@ -74,7 +74,7 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname, tileyrep, mode, transp, - transparant, + alpha, zsort, lightlayer, bIsTriangle, @@ -245,7 +245,7 @@ PyObject* KX_PolygonMaterial::_getattr(const STR_String& attr) if (attr == "drawingmode") return PyInt_FromLong(m_drawingmode); if (attr == "transparent") - return PyInt_FromLong(m_transparant); + return PyInt_FromLong(m_alpha); if (attr == "zsort") return PyInt_FromLong(m_zsort); if (attr == "lightlayer") @@ -312,7 +312,7 @@ int KX_PolygonMaterial::_setattr(const STR_String &attr, PyObject *pyvalue) if (attr == "transparent") { - m_transparant = value; + m_alpha = value; return 0; } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 342856fc1a1..11c8baa8b1f 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -65,7 +65,7 @@ public: int tileyrep, int mode, int transp, - bool transparant, + bool alpha, bool zsort, int lightlayer, bool bIsTriangle, diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 772625b8a0b..ad476e492d0 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -117,13 +117,13 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, PyObjectPlus(&KX_Scene::Type), m_keyboardmgr(NULL), m_mousemgr(NULL), + m_sceneConverter(NULL), m_physicsEnvironment(0), m_sceneName(sceneName), m_adi(adi), m_networkDeviceInterface(ndi), m_active_camera(NULL), - m_ueberExecutionPriority(0), - m_sceneConverter(NULL) + m_ueberExecutionPriority(0) { m_suspendedtime = 0.0; m_suspendeddelta = 0.0; @@ -985,6 +985,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) //m_active_camera->Release(); m_active_camera = NULL; } + // in case this is a camera m_cameras.remove((KX_Camera*)newobj); @@ -1241,14 +1242,10 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi if (visible) { int nummeshes = gameobj->GetMeshCount(); - MT_Transform t( cam->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform()); - + // this adds the vertices to the display list for (int m=0;m<nummeshes;m++) - { - // this adds the vertices to the display list - (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode()); - } + (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode()); } gameobj->MarkVisible(visible); } @@ -1305,12 +1302,11 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam if (vis) { int nummeshes = gameobj->GetMeshCount(); - MT_Transform t(cam->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform()); for (int m=0;m<nummeshes;m++) { // this adds the vertices to the display list - (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode()); + (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode()); } // Visibility/ non-visibility are marked // elsewhere now. |