void assetAvailabilityChanged(String const &identifier, filesys::AssetObserver::Event event) override { LOG_RES_MSG("Model asset \"%s\" is now %s") << identifier << (event == filesys::AssetObserver::Added? "available" : "unavailable"); if (event == filesys::AssetObserver::Added) { bank.add(identifier, App::asset(identifier).absolutePath("path")); // Begin loading the model right away. bank.load(identifier); } else { auto const &model = bank.model<render::Model const>(identifier); // Unload programs used by the various rendering passes. for (auto const &pass : model.passes) { DENG2_ASSERT(pass.program); unloadProgram(*static_cast<Program *>(pass.program)); } // Alternatively, the entire model may be using a single program. if (model.passes.isEmpty()) { if (model.program()) { unloadProgram(*static_cast<Program *>(model.program())); } } else { DENG2_ASSERT(!model.program()); } bank.remove(identifier); { DENG2_GUARD(pendingModels); pendingModels.value.remove(identifier); } } }
void writeIfModified() { if(!file || !arch) return; // If modified, the archive is written back to the file. if(arch->modified()) { LOG_RES_MSG("Updating archive in ") << file->description(); // Make sure we have either a compressed or uncompressed version of // each entry in memory before destroying the source file. arch->cache(); file->clear(); Writer(*file) << *arch; file->flush(); } else { LOG_RES_VERBOSE("Not updating archive in %s (not changed)") << file->description(); } }