Panda's caching system has many issues

I’m specifically only using glTF right now.
As suggested, panda3d-gltf library is used.

Sometimes, when I load models from different folders but with models and their texture named the same, Panda will just use the first loaded texture and applied it on every model until I manually delete the files in the cache folder.

The other issue is, if I will re-export the glTF from my editor, sometimes Panda will refuse to reload the models and just use the old one in the cache.

Seems like the caching system was designed for egg and either the new glTF importers don’t respect it, or it doesn’t respect them.

Windows 10, Panda 1.11.

I can’t do anything with this.

If there is a specific bug, then please detail a series of reproduction steps so we can find the cause of the bug.

There is nothing egg-specific in the caching system.

I already have.

  1. Create two glTF files, each in its own subfolder. Name them and their texture the same
  2. Load both in Panda.
    The second one will reuse the texture of the first one.
  3. Delete your cache folder, reverse the order of the loaded models in your code. Now the previously first model will reuse the texture of the previously last one. (411.9 KB)

import panda3d.core
from direct.showbase.ShowBase import ShowBase

base = ShowBase()

mdl1 = base.loader.load_model("1/1.gltf")

mdl2 = base.loader.load_model("2/1.gltf")

I think setting noCache to True in loader options will force the loader to load model from disk

loadModel(self, modelPath, loaderOptions=None, noCache=None, allowInstance=False, okMissing=None, callback=None, extraArgs=[], priority=None, blocking=None)

I don’t really want that, I want it to generate and use bam files, otherwise load times for files which will come with my program will be very slow.
What I want it to do is to respect the full file path (at least from the root program directory) and not just the file name of the textures when determining whether to use cached textures or not. Otherwise again, it applies the wrong texture to the wrong model when both texture files are named the same.

Thanks for the reproduction case. I investigated this issue and it turns out that this is a bug in panda3d-gltf.

It is prepending directories to the model-path and then loading textures relative to them. But it is never removing those directories afterwards.

I think this needs to be filed as an issue on the panda3d-gltf issue tracker. I have also alerted @Moguri to this matter.

Can you share reproduction steps for your second and third issue, etc.?

1 Like

Thanks rdb.

I’m unable to create a clear reproduction step for the second (remaining) issue. Sometimes the new gltf files (same name as the one which have already been cached, but updated model data) fail to be used and the old cached version is used, sometimes it does work. I don’t know what the trigger is. My guess is the loader or caching system fails to do a proper comparison between the data in the cached bam file and the current gltf file, to determine if they are different and if a new bam is needed to be generated or not. For example, maybe it is checking for file size or poly count instead of actual coordinates of the vertices (shape of the mesh). I think, if it isn’t currently, it should just be checking the creation or modification date of the gltf file and if that data is newer than the cache, it should generate a new bam file regardless of it considers the new gltf file too similar to the old one or not.

For my current project it’s not an issue as I can delete the cache and generate it one last time when shipping the product, and users are not expected to be able to alter the models on their end, but this is a general issue that has to be identified and fixed.

I believe it’s just looking at the modified time. Is this happening when the file is being modified and reloaded within the same second, by any chance?

The new file is re-exported from Blender and the main script is reran.

I have filed an issue regarding the first problem you reported, so that it is not forgotten.