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.
Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -662,6 +662,26 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust · 661 unmodified lines | |||
| 662 | return result; | 662 | return result; |
| 663 | } | 663 | } |
| 664 | 664 | ||
| 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 | |||
| 665 | RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, | 685 | RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, |
| 666 | const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) { | 686 | const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) { |
| 667 | PROFILE_RANGE(script_entities, __FUNCTION__); | 687 | PROFILE_RANGE(script_entities, __FUNCTION__); |