Multiple texture loading when loading my3d from zip file

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Multiple texture loading when loading my3d from zip file

Post by Masterhawk »

While playing around with the my3d-loader I found another strange behaviour when loading a my3d file and its textures from a zip archive. All textures get loaded multiple times.

the log without any fixes: (believe me that the list is a few times longer:wink: )
Image


here the log with the "fixed" loader
Image


I made a quick hotfix. I don't know if that really fixes the real problem, but it achieves that the textures get loaded only one time.

I changed

Code: Select all

if (Name.size()>0)
{
            me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str());
            ligCount++;
}
to

Code: Select all

if (Name.size()>0)
{
     ////////////////////////////////////////////////////////////
     //check if texture was loaded before
     for(s32 p=0; p<m;p++)
    {
        if(!strcmp(MaterialEntry[p].Texture2FileName.c_str(), me.Texture2FileName.c_str()))
        {
               me.Texture2 = MaterialEntry[p].Texture2;
               break; 
        }
        else if(p==(m-1))
        {
               me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str());
					         ligCount++;
        } 
     }
     if(m==0)
     {
         me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str());
         ligCount++;  
     }
    ///////////////////////////////////////////////////
                    
}
This has to be changed on the two other similar positions in the code.

I know that this is a really messy code-style (damn, it's about 3 am in germany :lol: ), so I hope that a more skilled person hunts this bug down. :wink:
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yeah, code could be optimized. But that's not the point. It rather seems to be a problem with the texture cache, because getTexture should check for existence of the texture already. So I'll check the complete texture loading chain.
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Post by Masterhawk »

hey hybrid, I know this thread is quite old, but in my version of irrlicht (1.1 modified) the problem still occurs. Can you remember that you've fixed it?
I searched the MY3DFileLoader form the trunk, but didn't find a relevant code-change.
Guess I should have a look at the getTexture() method but I don't find the code. Can you tell me where I have to look?

It's quite important cause my new map is currently not loading due to too less memory :shock: (GL_OUT_OF_MEMORY)
Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

It's in source/Irrlicht/CNullDriver.cpp

CNullDriver::getTexture(const c8* filename)

This method does try to use an already loaded versions of the specified texture, by calling findTexture() to retrieve it from the cache.

This should find already loaded textures from inside a zip archive; in fact, it has an extant problem in that it can't distinguish between the same subpath in different archives (of any sort), so if you have the same/subpath/filename.foo in multiple archives, you'll always get the texture for the first texture that was loaded using this name, regardless of which archive it came from.

In 1.4.2 and below, you'll get the same texture with that filename, even if it was loaded from the filesystem. 1.4.3 / 1.5 will (or should) be able to distinguish between filesystem files in different working directories, and I'll try to extend that to archive files (with some more careful testing).

See the bug report and the followup.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, don't know what was wrong at that time with the texture loader. But you should be able to check the places in the my3d loader and step through the texture loading process with a debugger. A guess would be that the internal texture names are made up with the submesh name and the texture or something like that.
Post Reply