mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 16:14:01 +02:00
added case-sensitive search
This commit is contained in:
parent
3443c112ac
commit
988dca437d
2 changed files with 19 additions and 6 deletions
|
@ -734,7 +734,7 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesByType(const QString entity
|
|||
return result;
|
||||
}
|
||||
|
||||
QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entityName, const glm::vec3& center, float radius) const {
|
||||
QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entityName, const glm::vec3& center, float radius, bool caseSensitiveSearch) const {
|
||||
|
||||
QVector<QUuid> result;
|
||||
if (_entityTree) {
|
||||
|
@ -743,9 +743,21 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entity
|
|||
_entityTree->findEntities(center, radius, entities);
|
||||
});
|
||||
|
||||
foreach(EntityItemPointer entity, entities) {
|
||||
if (entity->getName() == entityName) {
|
||||
result << entity->getEntityItemID();
|
||||
if (caseSensitiveSearch) {
|
||||
foreach(EntityItemPointer entity, entities) {
|
||||
if (entity->getName() == entityName) {
|
||||
result << entity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
QString entityNameLowerCase = entityName.toLower();
|
||||
|
||||
foreach(EntityItemPointer entity, entities) {
|
||||
QString entityItemLowerCase = entity->getName().toLower();
|
||||
if (entityItemLowerCase == entityNameLowerCase) {
|
||||
result << entity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,13 +393,14 @@ public slots:
|
|||
* @param {Entities.EntityType} entityName - The name of the entity to search for.
|
||||
* @param {Vec3} center - The point about which to search.
|
||||
* @param {number} radius - The radius within which to search.
|
||||
* @param {bool} caseSensitiveSearch - Choose whether to to return case sensitive results back.
|
||||
* @returns {Uuid[]} An array of entity IDs of the specified type that intersect the search sphere. The array is empty if
|
||||
* no entities could be found.
|
||||
* @example <caption>Get back a list of entities</caption>
|
||||
* var entityIDs = Entities.findEntitiesByName("Light-Target", MyAvatar.position, 10);
|
||||
* var entityIDs = Entities.findEntitiesByName("Light-Target", MyAvatar.position, 10, false);
|
||||
* print("Number of Entities with the name Light-Target " + entityIDs.length);
|
||||
*/
|
||||
Q_INVOKABLE QVector<QUuid> findEntitiesByName(const QString entityName, const glm::vec3& center, float radius) const;
|
||||
Q_INVOKABLE QVector<QUuid> findEntitiesByName(const QString entityName, const glm::vec3& center, float radius, bool caseSensitiveSearch = false ) const;
|
||||
|
||||
/**jsdoc
|
||||
* Find the first entity intersected by a {@link PickRay}. <code>Light</code> and <code>Zone</code> entities are not
|
||||
|
|
Loading…
Reference in a new issue