diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 5ef0db57ec..ad8ef4a20a 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -208,7 +208,24 @@ QVector EntityScriptingInterface::findEntities(const glm::vec3& ce QVector entities; _entityTree->findEntities(center, radius, entities); _entityTree->unlock(); + + foreach (const EntityItem* entity, entities) { + EntityItemID thisEntityItemID(entity->getID(), UNKNOWN_ENTITY_TOKEN, true); + result << thisEntityItemID; + } + } + return result; +} +QVector EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const { + QVector result; + if (_entityTree) { + _entityTree->lockForRead(); + AABox box(corner, dimensions); + QVector entities; + _entityTree->findEntities(box, entities); + _entityTree->unlock(); + foreach (const EntityItem* entity, entities) { EntityItemID thisEntityItemID(entity->getID(), UNKNOWN_ENTITY_TOKEN, true); result << thisEntityItemID; diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index bac018f2ae..7e0c510f21 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -87,10 +87,14 @@ public slots: /// will return a EntityItemID.isKnownID = false if no models are in the radius /// this function will not find any models in script engine contexts which don't have access to models Q_INVOKABLE EntityItemID findClosestEntity(const glm::vec3& center, float radius) const; - + /// finds models within the search sphere specified by the center point and radius /// this function will not find any models in script engine contexts which don't have access to models Q_INVOKABLE QVector findEntities(const glm::vec3& center, float radius) const; + + /// finds models within the search sphere specified by the center point and radius + /// this function will not find any models in script engine contexts which don't have access to models + Q_INVOKABLE QVector findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const; /// If the scripting context has visible entities, this will determine a ray intersection, the results /// may be inaccurate if the engine is unable to access the visible entities, in which case result.accurate