Model cache

As i would expect it sometimes takes 1-3 seconds for my model to come up the 1st time it loads (subsequent loads are almost instant)

From previous panda version, I remembered the model cache where egg files are saved as bam files to be used in game? (or am I remmebering this totally wrong?) I thought this cache happened automatically, but I cannot find any BAM files on my PC (did a search).
I checked config.prc (which I have not edited at all) and found this:

Enable the model-cache, but only for models, not textures.

model-cache-dir $USER_APPDATA/Panda3D-1.7.0/cache
model-cache-textures #f

and there is no cache folder at all.
Do I need to do something to turn this feature on?

Have you looked in $USER_APPDATA? Your USER_APPDATA folder is c:/Documents and Settings//Application Data, on XP. On Vista or Win7, it’s c:/Users//AppData.

You can also edit the model-cache-dir setting to put it somewhere else, somewhere specific like /c/panda-cache, if you like.

David

Hi,
Yes I checked there 1st and I don’t see a folder called “Panda3D-1.7.0” or even “cache”.

I did search the whole drive for any .bam files and did not come up with any.

Am I understanding this right, Panda should automatically be creating BAM fles and storing them in the cache?

Yes. What happens if you set the model-cache to something else? Are you sure you’re looking at the right config file?

You can prove this with:

print cpMgr

or event:

print ConfigVariableFilename('model-cache-dir')

David

when I try
print ConfigVariableFilename(‘model-cache-dir’)

I get:
ConfigVariable model-cache-dir:
model-cache-dir $USER_APPDATA/Panda3D-1.7.0/cache (from /c/Panda3D-1.7.0/etc/Config.prc)

when I try:
print cpMgr

I get:
NameError: name ‘cpMgr’ is not defined

Well, the model-cache-dir is defined, then. It should be storing it in the expected place. You can check ExecutionEnvironment.getEnvironmentVariable(“USER_APPDATA”) to prove that $USER_APPDATA has the expected value.

As to cpMgr not being defined, you may have to import DirectStart first. If you haven’t, you can define cpMgr yourself with:

cpMgr = ConfigPageManager.getGlobalPtr();

David

Thx , was able to use
ExecutionEnvironment.getEnvironmentVariable(“USER_APPDATA”)

to find it under:
C:\Documents and Settings\myname\Local Settings\Application Data\Panda3D-1.7.0\cache

and there are bam files there.

For my understanding, these BAM files seem to speed up model loading after the 1st time a model is loded. but the next time i start the program from scratch the models are slow again (the 1st time) - this is std behavior, unless I explicitly create bam files for my models, right?

I think you might be confusing the model-cache-dir with the ModelPool.

The ModelPool keeps a copy of every model you loaded, in the current session, in RAM. So this means the second time you load a given model (without restarting), it doesn’t even have to look at the disk, it just returns immediately.

Once you exit the program and restart, the first time you load a model it has to find and read the model from disk, and this can take a couple of seconds. If the model is not in the model-cache-dir, it will find the egg file and read it, which can take a few more seconds (depending on the size of your model). But, if the model is found in the model-cache-dir, it will read the bam file instead, which is faster than the egg file but not instant.

Exiting the program and restarting won’t clear out the model-cache-dir. But running the program on a new computer will.

David

Thanks, that makes it much clearer.

I appreciate all your help with my many many questions :slight_smile:

Panda is a fantastic engine and the community makes it even more so.

Cheers!