Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 27 files). Show all
Unified · Split
| @@ -1360,14 +1360,13 @@ void EntityScriptingInterface::onDeletingEntity(EntityItem* entity) { · 1359 unmodified lines | |||
| 1360 | } | 1360 | } |
| 1361 | } | 1361 | } |
| 1362 | 1362 | ||
| 1363 | QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const { | 1363 | QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius, uint filter) const { |
| 1364 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1364 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1365 | 1365 | ||
| 1366 | EntityItemID result; | 1366 | EntityItemID result; |
| 1367 | if (_entityTree) { | 1367 | if (_entityTree) { |
| 1368 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1369 | _entityTree->withReadLock([&] { | 1368 | _entityTree->withReadLock([&] { |
| 1370 | result = _entityTree->evalClosestEntity(center, radius, PickFilter(searchFilter)); | 1369 | result = _entityTree->evalClosestEntity(center, radius, PickFilter(filter)); |
| 1371 | }); | 1370 | }); |
| 1372 | } | 1371 | } |
| 1373 | return result; | 1372 | return result; |
| @@ -1382,34 +1381,32 @@ void EntityScriptingInterface::dumpTree() const { · 8 unmodified lines | |||
| 1382 | } | 1381 | } |
| 1383 | } | 1382 | } |
| 1384 | 1383 | ||
| 1385 | QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const { | 1384 | QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius, uint filter) const { |
| 1386 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1385 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1387 | 1386 | ||
| 1388 | QVector<QUuid> result; | 1387 | QVector<QUuid> result; |
| 1389 | if (_entityTree) { | 1388 | if (_entityTree) { |
| 1390 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1391 | _entityTree->withReadLock([&] { | 1389 | _entityTree->withReadLock([&] { |
| 1392 | _entityTree->evalEntitiesInSphere(center, radius, PickFilter(searchFilter), result); | 1390 | _entityTree->evalEntitiesInSphere(center, radius, PickFilter(filter), result); |
| 1393 | }); | 1391 | }); |
| 1394 | } | 1392 | } |
| 1395 | return result; | 1393 | return result; |
| 1396 | } | 1394 | } |
| 1397 | 1395 | ||
| 1398 | QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const { | 1396 | QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions, uint filter) const { |
| 1399 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1397 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1400 | 1398 | ||
| 1401 | QVector<QUuid> result; | 1399 | QVector<QUuid> result; |
| 1402 | if (_entityTree) { | 1400 | if (_entityTree) { |
| 1403 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1404 | _entityTree->withReadLock([&] { | 1401 | _entityTree->withReadLock([&] { |
| 1405 | AABox box(corner, dimensions); | 1402 | AABox box(corner, dimensions); |
| 1406 | _entityTree->evalEntitiesInBox(box, PickFilter(searchFilter), result); | 1403 | _entityTree->evalEntitiesInBox(box, PickFilter(filter), result); |
| 1407 | }); | 1404 | }); |
| 1408 | } | 1405 | } |
| 1409 | return result; | 1406 | return result; |
| 1410 | } | 1407 | } |
| 1411 | 1408 | ||
| 1412 | QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum) const { | 1409 | QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum, uint filter) const { |
| 1413 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1410 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1414 | 1411 | ||
| 1415 | QVector<QUuid> result; | 1412 | QVector<QUuid> result; |
| @@ -1439,9 +1436,8 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust · 23 unmodified lines | |||
| 1439 | viewFrustum.calculate(); | 1436 | viewFrustum.calculate(); |
| 1440 | 1437 | ||
| 1441 | if (_entityTree) { | 1438 | if (_entityTree) { |
| 1442 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1443 | _entityTree->withReadLock([&] { | 1439 | _entityTree->withReadLock([&] { |
| 1444 | _entityTree->evalEntitiesInFrustum(viewFrustum, PickFilter(searchFilter), result); | 1440 | _entityTree->evalEntitiesInFrustum(viewFrustum, PickFilter(filter), result); |
| 1445 | }); | 1441 | }); |
| 1446 | } | 1442 | } |
| 1447 | } | 1443 | } |
| @@ -1449,62 +1445,53 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust · 1 unmodified line | |||
| 1449 | return result; | 1445 | return result; |
| 1450 | } | 1446 | } |
| 1451 | 1447 | ||
| 1452 | QVector<QUuid> EntityScriptingInterface::findEntitiesByType(const QString entityType, const glm::vec3& center, float radius) const { | 1448 | QVector<QUuid> EntityScriptingInterface::findEntitiesByType(const QString entityType, const glm::vec3& center, float radius, uint filter) const { |
| 1453 | EntityTypes::EntityType type = EntityTypes::getEntityTypeFromName(entityType); | 1449 | EntityTypes::EntityType type = EntityTypes::getEntityTypeFromName(entityType); |
| 1454 | 1450 | ||
| 1455 | QVector<QUuid> result; | 1451 | QVector<QUuid> result; |
| 1456 | if (_entityTree) { | 1452 | if (_entityTree) { |
| 1457 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1458 | _entityTree->withReadLock([&] { | 1453 | _entityTree->withReadLock([&] { |
| 1459 | _entityTree->evalEntitiesInSphereWithType(center, radius, type, PickFilter(searchFilter), result); | 1454 | _entityTree->evalEntitiesInSphereWithType(center, radius, type, PickFilter(filter), result); |
| 1460 | }); | 1455 | }); |
| 1461 | } | 1456 | } |
| 1462 | return result; | 1457 | return result; |
| 1463 | } | 1458 | } |
| 1464 | 1459 | ||
| 1465 | QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entityName, const glm::vec3& center, float radius, bool caseSensitiveSearch) const { | 1460 | QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entityName, |
| 1461 | const glm::vec3& center, | ||
| 1462 | float radius, | ||
| 1463 | bool caseSensitiveSearch, | ||
| 1464 | uint filter) const { | ||
| 1466 | QVector<QUuid> result; | 1465 | QVector<QUuid> result; |
| 1467 | if (_entityTree) { | 1466 | if (_entityTree) { |
| 1468 | _entityTree->withReadLock([&] { | 1467 | _entityTree->withReadLock([&] { |
| 1469 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | 1468 | _entityTree->evalEntitiesInSphereWithName(center, radius, entityName, caseSensitiveSearch, PickFilter(filter), result); |
| 1470 | _entityTree->evalEntitiesInSphereWithName(center, radius, entityName, caseSensitiveSearch, PickFilter(searchFilter), result); | ||
| 1471 | }); | 1469 | }); |
| 1472 | } | 1470 | } |
| 1473 | return result; | 1471 | return result; |
| 1474 | } | 1472 | } |
| 1475 | 1473 | ||
| 1476 | QVector<QUuid> EntityScriptingInterface::findEntitiesByTags(const QVector<QString> entityTags, const glm::vec3& center, float radius, bool caseSensitiveSearch) const { | 1474 | QVector<QUuid> EntityScriptingInterface::findEntitiesByTags(const QVector<QString> entityTags, |
| 1475 | const glm::vec3& center, | ||
| 1476 | float radius, | ||
| 1477 | bool caseSensitiveSearch, | ||
| 1478 | uint filter) const { | ||
| 1477 | QVector<QUuid> result; | 1479 | QVector<QUuid> result; |
| 1478 | if (_entityTree) { | 1480 | if (_entityTree) { |
| 1479 | _entityTree->withReadLock([&] { | 1481 | _entityTree->withReadLock([&] { |
| 1480 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | 1482 | _entityTree->evalEntitiesInSphereWithTags(center, radius, entityTags, caseSensitiveSearch, PickFilter(filter), result); |
| 1481 | _entityTree->evalEntitiesInSphereWithTags(center, radius, entityTags, caseSensitiveSearch, PickFilter(searchFilter), result); | ||
| 1482 | }); | 1483 | }); |
| 1483 | } | 1484 | } |
| 1484 | return result; | 1485 | return result; |
| 1485 | } | 1486 | } |
| 1486 | 1487 | ||
| 1487 | RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, | 1488 | RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, uint filter, |
| 1488 | const ScriptValue& entityIdsToInclude, const ScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) const { | 1489 | const ScriptValue& entityIdsToInclude, const ScriptValue& entityIdsToDiscard) const { |
| 1489 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1490 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1490 | QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude); | 1491 | QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude); |
| 1491 | QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard); | 1492 | QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard); |
| 1492 | 1493 | ||
| 1493 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | 1494 | return evalRayIntersectionWorker(ray, Octree::Lock, PickFilter(filter), entitiesToInclude, entitiesToDiscard); |
| 1494 | |||
| 1495 | if (!precisionPicking) { | ||
| 1496 | searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::COARSE); | ||
| 1497 | } | ||
| 1498 | |||
| 1499 | if (visibleOnly) { | ||
| 1500 | searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::VISIBLE); | ||
| 1501 | } | ||
| 1502 | |||
| 1503 | if (collidableOnly) { | ||
| 1504 | searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::COLLIDABLE); | ||
| 1505 | } | ||
| 1506 | |||
| 1507 | return evalRayIntersectionWorker(ray, Octree::Lock, PickFilter(searchFilter), entitiesToInclude, entitiesToDiscard); | ||
| 1508 | } | 1495 | } |
| 1509 | 1496 | ||
| 1510 | RayToEntityIntersectionResult EntityScriptingInterface::evalRayIntersectionVector(const PickRay& ray, PickFilter searchFilter, | 1497 | RayToEntityIntersectionResult EntityScriptingInterface::evalRayIntersectionVector(const PickRay& ray, PickFilter searchFilter, |