diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index 569517a6c..98c4df284 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -1344,22 +1344,6 @@ bool EvaluateFilterSet(ICaptureContext &ctx, const rdcarray &filter return accept; } -static const SDObject *FindChildRecursively(const SDObject *parent, rdcstr name) -{ - const SDObject *o = parent->FindChild(name); - if(o) - return o; - - for(size_t i = 0; i < parent->NumChildren(); i++) - { - o = FindChildRecursively(parent->GetChild(i), name); - if(o) - return o; - } - - return NULL; -} - struct ParseTrace { int position = -1; @@ -1787,7 +1771,7 @@ searched for as a case-insensitive substring. if(!chunk) return false; - const SDObject *o = FindChildRecursively(chunk, paramName); + const SDObject *o = chunk->FindChildRecursively(paramName); if(!o) return false; diff --git a/renderdoc/api/replay/structured_data.h b/renderdoc/api/replay/structured_data.h index 1ab2d5a0c..f921e5df2 100644 --- a/renderdoc/api/replay/structured_data.h +++ b/renderdoc/api/replay/structured_data.h @@ -618,6 +618,31 @@ returned. return NULL; } + DOCUMENT(R"(Find a child object by a given name recursively. If no matching child is found, +``None`` is returned. + +The order of the search is not guaranteed, so care should be taken when the name may not be unique. + +:param str childName: The name to search for. +:return: A reference to the child object if found, or ``None`` if not. +:rtype: SDObject +)"); + inline SDObject *FindChildRecursively(const rdcstr &childName) + { + SDObject *o = FindChild(childName); + if(o) + return o; + + for(size_t i = 0; i < NumChildren(); i++) + { + o = GetChild(i)->FindChildRecursively(childName); + if(o) + return o; + } + + return NULL; + } + DOCUMENT(R"(Find a child object by a given index. If the index is out of bounds, ``None`` is returned. @@ -652,6 +677,21 @@ returned. return GetChild(i); return NULL; } + inline const SDObject *FindChildRecursively(const rdcstr &childName) const + { + const SDObject *o = FindChild(childName); + if(o) + return o; + + for(size_t i = 0; i < NumChildren(); i++) + { + o = GetChild(i)->FindChildRecursively(childName); + if(o) + return o; + } + + return NULL; + } inline const SDObject *GetChild(size_t index) const { if(index < data.children.size())