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.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user