mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
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.
This commit is contained in:
parent
9a4b624029
commit
08eb6442b5
2 changed files with 27 additions and 0 deletions
|
@ -662,6 +662,26 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust
|
|||
return result;
|
||||
}
|
||||
|
||||
QVector<QUuid> EntityScriptingInterface::findEntitiesByType(const QString entityType, const glm::vec3& center, float radius) const {
|
||||
EntityTypes::EntityType type = EntityTypes::getEntityTypeFromName(entityType);
|
||||
|
||||
QVector<QUuid> result;
|
||||
if (_entityTree) {
|
||||
QVector<EntityItemPointer> entities;
|
||||
_entityTree->withReadLock([&] {
|
||||
_entityTree->findEntities(center, radius, entities);
|
||||
});
|
||||
|
||||
foreach(EntityItemPointer entity, entities) {
|
||||
if (entity->getType() == type)
|
||||
{
|
||||
result << entity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking,
|
||||
const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) {
|
||||
PROFILE_RANGE(script_entities, __FUNCTION__);
|
||||
|
|
|
@ -215,6 +215,13 @@ public slots:
|
|||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QVector<QUuid> findEntitiesInFrustum(QVariantMap frustum) const;
|
||||
|
||||
/// finds models within a sphere given by the center point and radius
|
||||
/// @param {QString} string representation of entity type
|
||||
/// @param {vec3} center point
|
||||
/// @param {float} radius to search
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QVector<QUuid> findEntitiesByType(const QString entityType, const glm::vec3& center, float radius) 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
|
||||
/// will be false.
|
||||
|
|
Loading…
Reference in a new issue