FindChild by name
This commit is contained in:
parent
f1a6ea29c4
commit
4ebe38eb39
17
Thing.cpp
17
Thing.cpp
@ -1,5 +1,7 @@
|
|||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
using namespace Passer::RoboidControl;
|
using namespace Passer::RoboidControl;
|
||||||
|
|
||||||
Thing::Thing(unsigned char id) : id(id) {
|
Thing::Thing(unsigned char id) : id(id) {
|
||||||
@ -93,6 +95,21 @@ Thing *Passer::RoboidControl::Thing::RemoveChild(Thing *child) {
|
|||||||
return 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::GetLinearVelocity() { return this->linearVelocity; }
|
||||||
|
|
||||||
Spherical16 Thing::GetAngularVelocity() { return this->angularVelocity; }
|
Spherical16 Thing::GetAngularVelocity() { return this->angularVelocity; }
|
1
Thing.h
1
Thing.h
@ -85,6 +85,7 @@ public:
|
|||||||
/// or the child could not be found
|
/// or the child could not be found
|
||||||
Thing *GetChild(unsigned char childIx);
|
Thing *GetChild(unsigned char childIx);
|
||||||
Thing *RemoveChild(Thing *child);
|
Thing *RemoveChild(Thing *child);
|
||||||
|
Thing *FindChild(const char *name);
|
||||||
|
|
||||||
/// @brief Sets the location from where the 3D model of this Thing can be
|
/// @brief Sets the location from where the 3D model of this Thing can be
|
||||||
/// loaded from
|
/// loaded from
|
||||||
|
Loading…
x
Reference in New Issue
Block a user