static ModelCache::iterator ModelCache_insert (const std::string& path, const std::string& name, scene::Node& node) { if (g_modelCache_enabled) { return g_modelCache.insert(ModelKey(path, name), NodeSmartReference(node)); } return g_modelCache.insert(ModelKey("", ""), g_nullModel); }
static ModelCache::iterator ModelCache_find (const std::string& path, const std::string& name) { if (g_modelCache_enabled) { return g_modelCache.find(ModelKey(path, name)); } return g_modelCache.end(); }
ModelCache::iterator ModelCache_find(const char* path, const char* name) { if(g_modelCache_enabled) { return g_modelCache.find(ModelKey(path, name)); } return g_modelCache.end(); }
void ModelCache_flush (const std::string& path, const std::string& name) { ModelCache::iterator i = g_modelCache.find(ModelKey(path, name)); if (i != g_modelCache.end()) { //ASSERT_MESSAGE((*i).value.getCount() == 0, "resource flushed while still in use: " << (*i).key.first.c_str() << (*i).key.second.c_str()); g_modelCache.erase(i); } }
void setNode (scene::Node* node) { ModelCache::iterator i = ModelCache_find(m_path, m_name); if (i != g_modelCache.end()) { (*i).value = NodeSmartReference(*node); } setModel(NodeSmartReference(*node)); connectMap(); }
ModelWrapper(entity_interfaces_t* model, const char* name) : m_refcount(1), m_name(name) { m_model = g_model_cache.capture(ModelCache::key_type(m_name.GetBuffer(), 0)); model->pRender = this; model->pRender->IncRef(); model->pEdit = NULL; model->pSelect = this; model->pSelect->IncRef(); }
void loadCached () { if (g_modelCache_enabled) { // cache lookup ModelCache::iterator i = ModelCache_find(m_path, m_name); if (i == g_modelCache.end()) { i = ModelCache_insert(m_path, m_name, Model_load(m_loader, m_path, m_name, m_type)); } setModel((*i).value); } else { setModel(Model_load(m_loader, m_path, m_name, m_type)); } }
RemapWrapper(entity_interfaces_t* model, const char* name) : m_refcount(1) { parse_namestr(name); m_model = g_model_cache.capture(ModelCache::key_type(m_name.GetBuffer(), m_frame)); model->pRender = this; model->pRender->IncRef(); model->pEdit = NULL; model->pSelect = this; model->pSelect->IncRef(); construct_shaders(); }
virtual ~RemapWrapper() { g_model_cache.release(ModelCache::key_type(m_name.GetBuffer(), m_frame)); for(shaders_t::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i) { (*i)->DecRef(); } for(remaps_t::iterator j = m_remaps.begin(); j != m_remaps.end(); ++j) { remap_t *pRemap = (*j); delete pRemap; } m_remaps.clear(); }
void ModelCache_clear() { g_modelCache_enabled = false; g_modelCache.clear(); g_modelCache_enabled = true; }
virtual ~ModelWrapper() { g_model_cache.release(ModelCache::key_type(m_name.GetBuffer(), 0)); }