| 199 | } |
| 200 | |
| 201 | void ExtendedScene::ProcessNodesRecursive(std::shared_ptr<donut::engine::SceneGraphNode> node) |
| 202 | { |
| 203 | // std::find_if doesn't compile on linux. |
| 204 | auto _find_if = []( |
| 205 | ResourceTracker<Material>::ConstIterator begin, |
| 206 | ResourceTracker<Material>::ConstIterator end, |
| 207 | std::function<bool(const std::shared_ptr<Material>& mat)> fn)->ResourceTracker<Material>::ConstIterator |
| 208 | { |
| 209 | for (ResourceTracker<Material>::ConstIterator it = begin; it != end; it++) |
| 210 | { |
| 211 | if (fn(*it)) { |
| 212 | return it; |
| 213 | } |
| 214 | } |
| 215 | return end; |
| 216 | }; |
| 217 | |
| 218 | if (node->GetLeaf() != nullptr) |
| 219 | { |
| 220 | #if 0 // material patching no longer supported - leaving this as a future reference |
| 221 | std::shared_ptr<MaterialPatch> materialPatch = std::dynamic_pointer_cast<MaterialPatch>(node->GetLeaf()); |
| 222 | if (materialPatch != nullptr) |
| 223 | { |
| 224 | const std::string name = node->GetName(); |
| 225 | |
| 226 | auto & materials = m_SceneGraph->GetMaterials(); |
| 227 | auto it = _find_if( materials.begin(), materials.end(), [&name](const std::shared_ptr<Material> & mat) { return mat->name == name; }); |
| 228 | if (it == materials.end()) |
| 229 | { |
| 230 | log::warning("Material patch '%s' can't find material to patch!", name.c_str() ); |
| 231 | assert( false ); |
| 232 | } |
| 233 | else |
| 234 | { |
| 235 | materialPatch->Patch(**it); |
| 236 | } |
| 237 | } |
| 238 | #endif |
| 239 | std::shared_ptr<SampleSettings> sampleSettings = std::dynamic_pointer_cast<SampleSettings>(node->GetLeaf()); |
| 240 | if (sampleSettings != nullptr) |
| 241 | { |
| 242 | assert(m_loadedSettings == nullptr); // multiple settings nodes? only last one will be loaded |
| 243 | m_loadedSettings = sampleSettings; |
| 244 | } |
| 245 | std::shared_ptr<GameSettings> gameSettings = std::dynamic_pointer_cast<GameSettings>(node->GetLeaf()); |
| 246 | if (gameSettings != nullptr) |
| 247 | { |
| 248 | assert(m_loadedGameSettings == nullptr); // multiple settings nodes? only last one will be loaded |
| 249 | m_loadedGameSettings = gameSettings; |
| 250 | } |
| 251 | if (node->GetLeaf() != nullptr && node->GetLeaf()->GetContentFlags() == SceneContentFlags::Lights) |
| 252 | { |
| 253 | auto light = std::dynamic_pointer_cast<Light>(node->GetLeaf()); |
| 254 | auto lightEx = std::dynamic_pointer_cast<LightExtension>(node->GetLeaf()); |
| 255 | if (light != nullptr && (light->GetLightType() == LightType_Spot || light->GetLightType() == LightType_Point) && lightEx != nullptr) |
| 256 | { |
| 257 | for( auto proxyPath : lightEx->Proxies ) |
| 258 | { |
nothing calls this directly
no test coverage detected