isChildOfParent

This commit is contained in:
Dante Ruiz 2016-11-22 17:15:52 +00:00
parent cb0e01bfa4
commit c52f893273
2 changed files with 22 additions and 0 deletions

View file

@ -1318,6 +1318,27 @@ QVector<QUuid> EntityScriptingInterface::getChildrenIDs(const QUuid& parentID) {
return result;
}
bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) {
bool isChild = false;
if(!_entityTree) {
return isChild;
}
_entityTree->withReadLock([&] {
EntityItemPointer parent = _entityTree->findEntityByEntityItemID(parentID);
parent->forEachDescendant([&](SpatiallyNestablePointer descendant) {
if(descendant->getID() == childID) {
isChild = true;
return;
}
});
});
qDebug() << "Is Child of parent? : " << isChild;
return isChild;
}
QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) {
QVector<QUuid> result;
if (!_entityTree) {

View file

@ -255,6 +255,7 @@ public slots:
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);
Q_INVOKABLE bool isChildOfParent(QUuid childID, QUuid parnetID);
Q_INVOKABLE QUuid getKeyboardFocusEntity() const;
Q_INVOKABLE void setKeyboardFocusEntity(QUuid id);