Add tree element support to mjs_firstElement() and mjs_nextElement().

PiperOrigin-RevId: 671003046
Change-Id: I9e07d7c85c7218e9bded0f50af9db62d0f1e21e1
This commit is contained in:
Alessio Quaglino
2024-09-04 09:45:35 -07:00
committed by Copybara-Service
parent d3dfa6f970
commit ae4987026c
4 changed files with 79 additions and 24 deletions
+5 -1
View File
@@ -322,7 +322,7 @@ class mjCBody : public mjCBody_, private mjsBody {
const std::vector<double>& get_userdata() { return userdata_; }
// get next child of given type
mjsElement* NextChild(mjsElement* child, mjtObj type = mjOBJ_UNKNOWN);
mjsElement* NextChild(mjsElement* child, mjtObj type = mjOBJ_UNKNOWN, bool recursive = false);
// reset keyframe references for allowing self-attach
void ForgetKeyframes() const;
@@ -355,6 +355,10 @@ class mjCBody : public mjCBody_, private mjsBody {
template <typename T>
void CopyList(std::vector<T*>& dst, const std::vector<T*>& src,
std::map<mjCFrame*, int>& fmap, const mjCFrame* pframe = nullptr);
// gets next child of the same type in this body
template <class T>
mjsElement* GetNext(std::vector<T*>& list, const mjsElement* child, bool recursive = false);
};