diff --git a/Thing.cpp b/Thing.cpp index 4515c81..96d7399 100644 --- a/Thing.cpp +++ b/Thing.cpp @@ -1,5 +1,7 @@ #include "Thing.h" +#include + using namespace Passer::RoboidControl; Thing::Thing(unsigned char id) : id(id) { @@ -93,6 +95,21 @@ Thing *Passer::RoboidControl::Thing::RemoveChild(Thing *child) { return child; } +Thing *Thing::FindChild(const char *name) { + for (unsigned char childIx = 0; childIx < this->childCount; childIx++) { + Thing *child = this->children[childIx]; + if (child == nullptr) + continue; + if (strcmp(child->name, name) == 0) + return child; + + Thing *foundChild = child->FindChild(name); + if (foundChild != nullptr) + return foundChild; + } + return nullptr; +} + Spherical16 Thing::GetLinearVelocity() { return this->linearVelocity; } Spherical16 Thing::GetAngularVelocity() { return this->angularVelocity; } \ No newline at end of file diff --git a/Thing.h b/Thing.h index f5fb7d0..62fcb9e 100644 --- a/Thing.h +++ b/Thing.h @@ -85,6 +85,7 @@ public: /// or the child could not be found Thing *GetChild(unsigned char childIx); Thing *RemoveChild(Thing *child); + Thing *FindChild(const char *name); /// @brief Sets the location from where the 3D model of this Thing can be /// loaded from