MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / loadFromFile

Method loadFromFile

engine/Poseidon/World/Model/ModelCache.cpp:62–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::shared_ptr<Poseidon::Model::Model> ModelCache::loadFromFile(const std::string& filePath)
63{
64 std::ifstream file(filePath, std::ios::binary);
65 if (!file)
66 {
67 // Fallback to PBO archives
68 if (GFileServer)
69 {
70 return loadFromFileServer(filePath);
71 }
72 return nullptr;
73 }
74
75 FormatInfo info = P3DFormatDetector::DetectFormat(file);
76 if (!info.isSupported)
77 {
78 return nullptr;
79 }
80
81 auto model = std::make_shared<Poseidon::Model::Model>();
82
83 try
84 {
85 if (info.signature == "ODOL")
86 {
87 *model = Poseidon::Asset::Formats::ODOLLoader::load(filePath);
88 }
89 else if (info.signature == "MLOD")
90 {
91 *model = Poseidon::Asset::Formats::MLODLoader::load(filePath);
92 }
93 else
94 {
95 return nullptr;
96 }
97 }
98 catch (...)
99 {
100 return nullptr;
101 }
102
103 if (!model->compile() || !model->isCompiled())
104 {
105 return nullptr;
106 }
107
108 return model;
109}
110
111std::shared_ptr<Poseidon::Model::Model> ModelCache::loadFromFileServer(const std::string& filePath)
112{

Callers

nothing calls this directly

Calls 3

loadFunction · 0.85
compileMethod · 0.80
isCompiledMethod · 0.80

Tested by

no test coverage detected