Add Entities.getChildrenIDs() method

This commit is contained in:
David Rowe 2016-06-02 21:26:33 +12:00
parent 35b80ba066
commit 44fe7c1144
2 changed files with 22 additions and 0 deletions

View file

@ -1121,6 +1121,27 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) {
return result;
}
QVector<QUuid> EntityScriptingInterface::getChildrenIDs(const QUuid& parentID) {
QVector<QUuid> result;
if (!_entityTree) {
return result;
}
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(parentID);
if (!entity) {
qDebug() << "EntityScriptingInterface::getChildrenIDs - no entity with ID" << parentID;
return result;
}
_entityTree->withReadLock([&] {
entity->forEachChild([&](SpatiallyNestablePointer child) {
result.push_back(child->getID());
});
});
return result;
}
QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
QVector<QUuid> result;
if (!_entityTree) {

View file

@ -171,6 +171,7 @@ public slots:
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name);
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID);
Q_INVOKABLE QVector<QUuid> getChildrenIDs(const QUuid& parentID);
Q_INVOKABLE QVector<QUuid> getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex);
signals: