MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / LoadWithThreadPool

Method LoadWithThreadPool

src/engine/Scene.cpp:134–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

LoadFromFileFunction · 0.85
errorFunction · 0.85
CreateGraphMethod · 0.80
WaitForTasksMethod · 0.80
SetRootNodeMethod · 0.80
SetNameMethod · 0.80

Tested by

no test coverage detected