mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 10:34:33 +02:00
Merge pull request #13172 from wayne-chen/getChildrenIDs-issue-1934
Fix EntityScriptingInterface::getChildrenIDs function
This commit is contained in:
commit
ec3f9549f1
2 changed files with 17 additions and 12 deletions
|
@ -1688,15 +1688,21 @@ QVector<QUuid> EntityScriptingInterface::getChildrenIDs(const QUuid& parentID) {
|
|||
if (!_entityTree) {
|
||||
return result;
|
||||
}
|
||||
|
||||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(parentID);
|
||||
if (!entity) {
|
||||
qCDebug(entities) << "EntityScriptingInterface::getChildrenIDs - no entity with ID" << parentID;
|
||||
return result;
|
||||
}
|
||||
|
||||
_entityTree->withReadLock([&] {
|
||||
entity->forEachChild([&](SpatiallyNestablePointer child) {
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
if (!parentFinder) {
|
||||
return;
|
||||
}
|
||||
bool success;
|
||||
SpatiallyNestableWeakPointer parentWP = parentFinder->find(parentID, success);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
SpatiallyNestablePointer parent = parentWP.lock();
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
parent->forEachChild([&](SpatiallyNestablePointer child) {
|
||||
result.push_back(child->getID());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1226,12 +1226,11 @@ public slots:
|
|||
|
||||
|
||||
/**jsdoc
|
||||
* Get the IDs of entities, overlays, and avatars that are directly parented to an entity. To get all descendants of an
|
||||
* entity, recurse on the IDs returned by the function.
|
||||
* Get the IDs of entities, overlays, and avatars that are directly parented to an entity, overlay, or avatar model. Recurse on the IDs returned by the function to get all descendants of an entity, overlay, or avatar.
|
||||
* @function Entities.getChildrenIDs
|
||||
* @param {Uuid} parentID - The ID of the entity to get the children IDs of.
|
||||
* @param {Uuid} parentID - The ID of the entity, overlay, or avatar to get the children IDs of.
|
||||
* @returns {Uuid[]} An array of entity, overlay, and avatar IDs that are parented directly to the <code>parentID</code>
|
||||
* entity. Does not include children's children, etc. The array is empty if no children can be found or
|
||||
* entity, overlay, or avatar. Does not include children's children, etc. The array is empty if no children can be found or
|
||||
* <code>parentID</code> cannot be found.
|
||||
* @example <caption>Report the children of an entity.</caption>
|
||||
* function createEntity(description, position, parent) {
|
||||
|
|
Loading…
Reference in a new issue