History

Add function findEntitiesByType EntityScriptingInterface

Updated EntityScriptingInterface.cpp and .h to create a new function for the Entities API that can be called to filter out entities found by a specific entity type.

Liv committed 9 years ago

Commit 08eb6441 parent 9a4b6242 files · +27 −0Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+20−0
@@ -662,6 +662,26 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust · 661 unmodified lines
662662 return result;
663663 }
664664
665+QVector<QUuid> EntityScriptingInterface::findEntitiesByType(const QString entityType, const glm::vec3& center, float radius) const {
666+ EntityTypes::EntityType type = EntityTypes::getEntityTypeFromName(entityType);
667+
668+ QVector<QUuid> result;
669+ if (_entityTree) {
670+ QVector<EntityItemPointer> entities;
671+ _entityTree->withReadLock([&] {
672+ _entityTree->findEntities(center, radius, entities);
673+ });
674+
675+ foreach(EntityItemPointer entity, entities) {
676+ if (entity->getType() == type)
677+ {
678+ result << entity->getEntityItemID();
679+ }
680+ }
681+ }
682+ return result;
683+}
684+
665685 RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking,
666686 const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) {
667687 PROFILE_RANGE(script_entities, __FUNCTION__);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t