History

Add Entities.getChildrenIDs() method

David Rowe committed 10 years ago

Commit 44fe7c11 parent 35b80ba2 files · +22 −0Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+21−0
@@ -1121,6 +1121,27 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) { · 1120 unmodified lines
11211121 return result;
11221122 }
11231123
1124+QVector<QUuid> EntityScriptingInterface::getChildrenIDs(const QUuid& parentID) {
1125+ QVector<QUuid> result;
1126+ if (!_entityTree) {
1127+ return result;
1128+ }
1129+
1130+ EntityItemPointer entity = _entityTree->findEntityByEntityItemID(parentID);
1131+ if (!entity) {
1132+ qDebug() << "EntityScriptingInterface::getChildrenIDs - no entity with ID" << parentID;
1133+ return result;
1134+ }
1135+
1136+ _entityTree->withReadLock([&] {
1137+ entity->forEachChild([&](SpatiallyNestablePointer child) {
1138+ result.push_back(child->getID());
1139+ });
1140+ });
1141+
1142+ return result;
1143+}
1144+
11241145 QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
11251146 QVector<QUuid> result;
11261147 if (!_entityTree) {