diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-05-05 01:14:38 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-05-05 01:14:38 +0400 |
commit | cf654b44b6d1a59be7007fd5e3891e9a0bd78eeb (patch) | |
tree | 3890a0282b4cd70112af66de5aa974273a66c40f /source | |
parent | 32099649e394968ebaa559ce39d66715c8536a76 (diff) |
Fix BGE bug in patch #8724 (memory optimization): serious problem with alpha texture when Use Blender Material is active and several objects have same texture. This bug messes up greatly with OpenGL texture. The GE is not usable without this fix.
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 14 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.h | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index cfdcba8a5d6..44727588106 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -84,6 +84,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( mScene(scene), mUserDefBlend(0), mModified(0), + mConstructed(false), mPass(0) { @@ -119,7 +120,9 @@ KX_BlenderMaterial::KX_BlenderMaterial( KX_BlenderMaterial::~KX_BlenderMaterial() { // cleanup work - OnExit(); + if (mConstructed) + // clean only if material was actually used + OnExit(); } @@ -138,6 +141,10 @@ unsigned int* KX_BlenderMaterial::GetMCol(void) const void KX_BlenderMaterial::OnConstruction() { + if (mConstructed) + // when material are reused between objects + return; + // for each unique material... int i; for(i=0; i<mMaterial->num_enabled; i++) { @@ -148,19 +155,20 @@ void KX_BlenderMaterial::OnConstruction() } if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) spit("unable to initialize image("<<i<<") in "<< - mMaterial->matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); } else { if( mMaterial->img[i] ) { if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) spit("unable to initialize image("<<i<<") in "<< - mMaterial->matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); } } } mBlendFunc[0] =0; mBlendFunc[1] =0; + mConstructed = true; } void KX_BlenderMaterial::OnExit() diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 2b1264154d0..b9d48199520 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -93,6 +93,7 @@ private: bool mUserDefBlend; unsigned int mBlendFunc[2]; bool mModified; + bool mConstructed; // if false, don't clean on exit void ActivatGLMaterials( RAS_IRasterizer* rasty )const; void ActivateTexGen( RAS_IRasterizer *ras ) const; |