MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / getModel

Method getModel

radiantcore/model/ModelCache.cpp:43–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43IModelPtr ModelCache::getModel(const std::string& modelPath)
44{
45 // Try to lookup the existing model
46 auto found = _modelMap.find(modelPath);
47
48 if (_enabled && found != _modelMap.end())
49 {
50 return found->second;
51 }
52
53 // The model is not cached or the cache is disabled, load afresh
54
55 // Get the extension of this model
56 std::string type = os::getExtension(modelPath);
57
58 // Find a suitable model loader
59 IModelImporterPtr modelLoader = GlobalModelFormatManager().getImporter(type);
60
61 IModelPtr model = modelLoader->loadModelFromPath(modelPath);
62
63 if (model)
64 {
65 // Model successfully loaded, insert a reference into the map
66 _modelMap.emplace(modelPath, model);
67 }
68
69 return model;
70}
71
72scene::INodePtr ModelCache::getModelNodeForStaticResource(const std::string& resourcePath)
73{

Callers 7

TEST_FFunction · 0.45
TEST_FFunction · 0.45
preMethod · 0.45
visitMethod · 0.45
preMethod · 0.45
loadModelMethod · 0.45
loadModelMethod · 0.45

Calls 5

getExtensionFunction · 0.85
getImporterMethod · 0.80
findMethod · 0.45
endMethod · 0.45
loadModelFromPathMethod · 0.45

Tested by 3

preMethod · 0.36
visitMethod · 0.36
preMethod · 0.36