| 132 | } |
| 133 | |
| 134 | bool Scene::LoadWithThreadPool(const std::filesystem::path& sceneFileName, ThreadPool* threadPool) |
| 135 | { |
| 136 | g_LoadingStats.ObjectsLoaded = 0; |
| 137 | g_LoadingStats.ObjectsTotal = 0; |
| 138 | |
| 139 | m_SceneGraph = m_SceneTypeFactory->CreateGraph(); |
| 140 | |
| 141 | if (sceneFileName.extension() == ".gltf" || sceneFileName.extension() == ".glb") |
| 142 | { |
| 143 | ++g_LoadingStats.ObjectsTotal; |
| 144 | m_Models.resize(1); |
| 145 | LoadModelAsync(0, sceneFileName, threadPool); |
| 146 | |
| 147 | if (threadPool) |
| 148 | threadPool->WaitForTasks(); |
| 149 | |
| 150 | auto modelResult = m_Models[0]; |
| 151 | if (!modelResult.rootNode) |
| 152 | return false; |
| 153 | |
| 154 | m_SceneGraph->SetRootNode(modelResult.rootNode); |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | std::shared_ptr<SceneGraphNode> rootNode = std::make_shared<SceneGraphNode>(); |
| 159 | rootNode->SetName("SceneRoot"); |
| 160 | m_SceneGraph->SetRootNode(rootNode); |
| 161 | |
| 162 | std::filesystem::path scenePath = sceneFileName.parent_path(); |
| 163 | |
| 164 | Json::Value documentRoot; |
| 165 | if (!json::LoadFromFile(*m_fs, sceneFileName, documentRoot)) |
| 166 | return false; |
| 167 | |
| 168 | if (documentRoot.isObject()) |
| 169 | { |
| 170 | if (!LoadCustomData(documentRoot, scenePath, threadPool)) |
| 171 | return false; |
| 172 | |
| 173 | LoadModels(documentRoot["models"], scenePath, threadPool); |
| 174 | LoadSceneGraph(documentRoot["graph"], rootNode); |
| 175 | LoadAnimations(documentRoot["animations"]); |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | log::error("Unrecognized structure of the scene description file."); |
| 180 | return false; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return true; |
| 185 | } |
| 186 | |
| 187 | void Scene::LoadModelAsync( |
| 188 | uint32_t index, |
nothing calls this directly
no test coverage detected