This is with release 1.8.0.
We do some of our own caching, where we explicitly write out bam file (and reload it on subsequent runs). It appears that when loading a bam file, panda immediately writes out a copy to its cache directory.
I haven’t fully debugged it yet, but it appears that Loader::try_load_file is calling cache->store incorrectly under some circumstances.
Before I dig too much deeper into panda’s loading/caching behavior, does any of this ring any bells with anyone?
PT(PandaNode) Loader::
try_load_file(const Filename &pathname, const LoaderOptions &options,
LoaderFileType *requested_type) const {
BamCache *cache = BamCache::get_global_ptr();
bool cache_only = (options.get_flags() & LoaderOptions::LF_cache_only) != 0;
if (requested_type->get_allow_ram_cache(options)) {
// If we're allowing a RAM cache, use the ModelPool to load the
// file.
if (!cache_only || ModelPool::has_model(pathname)) {
PT(PandaNode) node = ModelPool::load_model(pathname, options);
if (node != (PandaNode *)NULL &&
(options.get_flags() & LoaderOptions::LF_allow_instance) == 0) {
// But return a deep copy of the shared model.
node = node->copy_subgraph();
}
return node;
}
}
bool report_errors = (options.get_flags() & LoaderOptions::LF_report_errors) != 0;
PT(BamCacheRecord) record;
if (cache->get_cache_models() && requested_type->get_allow_disk_cache(options)) {
// See if the model can be found in the on-disk cache, if it is
// active.
record = cache->lookup(pathname, "bam");
if (record != (BamCacheRecord *)NULL) {
if (record->has_data()) {
if (report_errors) {
loader_cat.info()
<< "Model " << pathname << " found in disk cache.\n";
}
PT(PandaNode) result = DCAST(PandaNode, record->get_data());
if (premunge_data) {
SceneGraphReducer sgr;
sgr.premunge(result, RenderState::make_empty());
}
return result;
}
}
}
if (!cache_only) {
PT(PandaNode) result = requested_type->load_file(pathname, options, record);
if (result != (PandaNode *)NULL){
if (record != (BamCacheRecord *)NULL) {
record->set_data(result, result);
cache->store(record);
}
if (premunge_data) {
SceneGraphReducer sgr;
sgr.premunge(result, RenderState::make_empty());
}
return result;
}
}