Avoid multiple calls to makeNormalMapTexture for the same texture.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2774 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-10-30 16:42:59 +00:00
parent ddc0a95cd4
commit ae0240d602
1 changed files with 9 additions and 1 deletions

View File

@ -423,13 +423,20 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf
texname.replace('\\', '/');
video::ITexture * texture = 0;
bool newTexture=false;
if (texname.size())
{
if (FileSystem->existFile(texname))
{
newTexture = SceneManager->getVideoDriver()->findTexture(texname) == 0;
texture = SceneManager->getVideoDriver()->getTexture(texname);
}
else
{
newTexture = SceneManager->getVideoDriver()->findTexture(relPath + texname) == 0;
// try to read in the relative path, the .obj is loaded from
texture = SceneManager->getVideoDriver()->getTexture( relPath + texname );
}
}
if ( texture )
{
@ -437,7 +444,8 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf
currMaterial->Meshbuffer->Material.setTexture(0, texture);
else if (type==1)
{
SceneManager->getVideoDriver()->makeNormalMapTexture(texture, bumpiness);
if (newTexture)
SceneManager->getVideoDriver()->makeNormalMapTexture(texture, bumpiness);
currMaterial->Meshbuffer->Material.setTexture(1, texture);
currMaterial->Meshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID;
currMaterial->Meshbuffer->Material.MaterialTypeParam=0.035f;