| 911 | } |
| 912 | |
| 913 | std::shared_ptr<SceneGraphNode> SceneGraph::FindNode(const std::filesystem::path& path, SceneGraphNode* context) const |
| 914 | { |
| 915 | auto pathComponent = path.begin(); |
| 916 | |
| 917 | if (pathComponent == path.end()) |
| 918 | return nullptr; |
| 919 | |
| 920 | if (*pathComponent == "/") |
| 921 | { |
| 922 | context = m_Root.get(); |
| 923 | ++pathComponent; |
| 924 | } |
| 925 | |
| 926 | if (!context) |
| 927 | { |
| 928 | log::error("Relative node queries with NULL context are not supported"); |
| 929 | return nullptr; |
| 930 | } |
| 931 | |
| 932 | SceneGraphNode* current = context; |
| 933 | |
| 934 | while (current && pathComponent != path.end()) |
| 935 | { |
| 936 | if (*pathComponent == "..") |
| 937 | { |
| 938 | current = current->GetParent(); |
| 939 | ++pathComponent; |
| 940 | continue; |
| 941 | } |
| 942 | |
| 943 | auto found = std::find_if(current->m_Children.begin(), current->m_Children.end(), |
| 944 | [&pathComponent](std::shared_ptr<SceneGraphNode> const& item) { return item->GetName() == *pathComponent; }); |
| 945 | |
| 946 | if (found != current->m_Children.end()) |
| 947 | { |
| 948 | current = found->get(); |
| 949 | ++pathComponent; |
| 950 | continue; |
| 951 | } |
| 952 | |
| 953 | return nullptr; |
| 954 | } |
| 955 | |
| 956 | return current->shared_from_this(); |
| 957 | } |
| 958 | |
| 959 | void SceneGraph::Refresh(uint32_t frameIndex) |
| 960 | { |
no test coverage detected