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}
133
134bool 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
187void Scene::LoadModelAsync(
188 uint32_t index,

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