Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1062,11 +1062,12 @@ void EntityScriptingInterface::handleEntityScriptCallMethodPacket(QSharedPointer · 1061 unmodified lines | |||
| 1062 | 1062 | ||
| 1063 | 1063 | ||
| 1064 | 1064 | ||
| 1065 | QUuid EntityScriptingInterface::evalClosestEntity(const glm::vec3& center, float radius, unsigned int searchFilter) const { | 1065 | QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const { |
| 1066 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1066 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1067 | 1067 | ||
| 1068 | EntityItemID result; | 1068 | EntityItemID result; |
| 1069 | if (_entityTree) { | 1069 | if (_entityTree) { |
| 1070 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1070 | _entityTree->withReadLock([&] { | 1071 | _entityTree->withReadLock([&] { |
| 1071 | result = _entityTree->evalClosestEntity(center, radius, PickFilter(searchFilter)); | 1072 | result = _entityTree->evalClosestEntity(center, radius, PickFilter(searchFilter)); |
| 1072 | }); | 1073 | }); |
| @@ -1083,11 +1084,12 @@ void EntityScriptingInterface::dumpTree() const { · 10 unmodified lines | |||
| 1083 | } | 1084 | } |
| 1084 | } | 1085 | } |
| 1085 | 1086 | ||
| 1086 | QVector<QUuid> EntityScriptingInterface::evalEntitiesInSphere(const glm::vec3& center, float radius, unsigned int searchFilter) const { | 1087 | QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const { |
| 1087 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1088 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1088 | 1089 | ||
| 1089 | QVector<QUuid> result; | 1090 | QVector<QUuid> result; |
| 1090 | if (_entityTree) { | 1091 | if (_entityTree) { |
| 1092 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1091 | _entityTree->withReadLock([&] { | 1093 | _entityTree->withReadLock([&] { |
| 1092 | _entityTree->evalEntitiesInSphere(center, radius, PickFilter(searchFilter), result); | 1094 | _entityTree->evalEntitiesInSphere(center, radius, PickFilter(searchFilter), result); |
| 1093 | }); | 1095 | }); |
| @@ -1095,11 +1097,12 @@ QVector<QUuid> EntityScriptingInterface::evalEntitiesInSphere(const glm::vec3& c · 1 unmodified line | |||
| 1095 | return result; | 1097 | return result; |
| 1096 | } | 1098 | } |
| 1097 | 1099 | ||
| 1098 | QVector<QUuid> EntityScriptingInterface::evalEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions, unsigned int searchFilter) const { | 1100 | QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const { |
| 1099 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1101 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1100 | 1102 | ||
| 1101 | QVector<QUuid> result; | 1103 | QVector<QUuid> result; |
| 1102 | if (_entityTree) { | 1104 | if (_entityTree) { |
| 1105 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1103 | _entityTree->withReadLock([&] { | 1106 | _entityTree->withReadLock([&] { |
| 1104 | AABox box(corner, dimensions); | 1107 | AABox box(corner, dimensions); |
| 1105 | _entityTree->evalEntitiesInBox(box, PickFilter(searchFilter), result); | 1108 | _entityTree->evalEntitiesInBox(box, PickFilter(searchFilter), result); |
| @@ -1108,7 +1111,7 @@ QVector<QUuid> EntityScriptingInterface::evalEntitiesInBox(const glm::vec3& corn · 2 unmodified lines | |||
| 1108 | return result; | 1111 | return result; |
| 1109 | } | 1112 | } |
| 1110 | 1113 | ||
| 1111 | QVector<QUuid> EntityScriptingInterface::evalEntitiesInFrustum(QVariantMap frustum, unsigned int searchFilter) const { | 1114 | QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum) const { |
| 1112 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1115 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1113 | 1116 | ||
| 1114 | QVector<QUuid> result; | 1117 | QVector<QUuid> result; |
| @@ -1138,6 +1141,7 @@ QVector<QUuid> EntityScriptingInterface::evalEntitiesInFrustum(QVariantMap frust · 23 unmodified lines | |||
| 1138 | viewFrustum.calculate(); | 1141 | viewFrustum.calculate(); |
| 1139 | 1142 | ||
| 1140 | if (_entityTree) { | 1143 | if (_entityTree) { |
| 1144 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1141 | _entityTree->withReadLock([&] { | 1145 | _entityTree->withReadLock([&] { |
| 1142 | _entityTree->evalEntitiesInFrustum(viewFrustum, PickFilter(searchFilter), result); | 1146 | _entityTree->evalEntitiesInFrustum(viewFrustum, PickFilter(searchFilter), result); |
| 1143 | }); | 1147 | }); |
| @@ -1147,11 +1151,12 @@ QVector<QUuid> EntityScriptingInterface::evalEntitiesInFrustum(QVariantMap frust · 3 unmodified lines | |||
| 1147 | return result; | 1151 | return result; |
| 1148 | } | 1152 | } |
| 1149 | 1153 | ||
| 1150 | QVector<QUuid> EntityScriptingInterface::evalEntitiesInSphereWithType(const QString entityType, const glm::vec3& center, float radius, unsigned int searchFilter) const { | 1154 | QVector<QUuid> EntityScriptingInterface::findEntitiesByType(const QString entityType, const glm::vec3& center, float radius) const { |
| 1151 | EntityTypes::EntityType type = EntityTypes::getEntityTypeFromName(entityType); | 1155 | EntityTypes::EntityType type = EntityTypes::getEntityTypeFromName(entityType); |
| 1152 | 1156 | ||
| 1153 | QVector<QUuid> result; | 1157 | QVector<QUuid> result; |
| 1154 | if (_entityTree) { | 1158 | if (_entityTree) { |
| 1159 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1155 | _entityTree->withReadLock([&] { | 1160 | _entityTree->withReadLock([&] { |
| 1156 | _entityTree->evalEntitiesInSphereWithType(center, radius, type, PickFilter(searchFilter), result); | 1161 | _entityTree->evalEntitiesInSphereWithType(center, radius, type, PickFilter(searchFilter), result); |
| 1157 | }); | 1162 | }); |
| @@ -1159,22 +1164,37 @@ QVector<QUuid> EntityScriptingInterface::evalEntitiesInSphereWithType(const QStr · 1 unmodified line | |||
| 1159 | return result; | 1164 | return result; |
| 1160 | } | 1165 | } |
| 1161 | 1166 | ||
| 1162 | QVector<QUuid> EntityScriptingInterface::evalEntitiesInSphereWithName(const QString entityName, const glm::vec3& center, float radius, bool caseSensitiveSearch, unsigned int searchFilter) const { | 1167 | QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entityName, const glm::vec3& center, float radius, bool caseSensitiveSearch) const { |
| 1163 | QVector<QUuid> result; | 1168 | QVector<QUuid> result; |
| 1164 | if (_entityTree) { | 1169 | if (_entityTree) { |
| 1165 | _entityTree->withReadLock([&] { | 1170 | _entityTree->withReadLock([&] { |
| 1171 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1166 | _entityTree->evalEntitiesInSphereWithName(center, radius, entityName, caseSensitiveSearch, PickFilter(searchFilter), result); | 1172 | _entityTree->evalEntitiesInSphereWithName(center, radius, entityName, caseSensitiveSearch, PickFilter(searchFilter), result); |
| 1167 | }); | 1173 | }); |
| 1168 | } | 1174 | } |
| 1169 | return result; | 1175 | return result; |
| 1170 | } | 1176 | } |
| 1171 | 1177 | ||
| 1172 | RayToEntityIntersectionResult EntityScriptingInterface::evalRayIntersection(const PickRay& ray, unsigned int searchFilter, | 1178 | RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, |
| 1173 | const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard) { | 1179 | const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) const { |
| 1174 | PROFILE_RANGE(script_entities, __FUNCTION__); | 1180 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1175 | QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude); | 1181 | QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude); |
| 1176 | QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard); | 1182 | QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard); |
| 1177 | 1183 | ||
| 1184 | unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES); | ||
| 1185 | |||
| 1186 | if (!precisionPicking) { | ||
| 1187 | searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::COARSE); | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | if (visibleOnly) { | ||
| 1191 | searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::VISIBLE); | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | if (collidableOnly) { | ||
| 1195 | searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::COLLIDABLE); | ||
| 1196 | } | ||
| 1197 | |||
| 1178 | return evalRayIntersectionWorker(ray, Octree::Lock, PickFilter(searchFilter), entitiesToInclude, entitiesToDiscard); | 1198 | return evalRayIntersectionWorker(ray, Octree::Lock, PickFilter(searchFilter), entitiesToInclude, entitiesToDiscard); |
| 1179 | } | 1199 | } |
| 1180 | 1200 | ||
| @@ -1187,7 +1207,7 @@ RayToEntityIntersectionResult EntityScriptingInterface::evalRayIntersectionVecto · 6 unmodified lines | |||
| 1187 | 1207 | ||
| 1188 | RayToEntityIntersectionResult EntityScriptingInterface::evalRayIntersectionWorker(const PickRay& ray, | 1208 | RayToEntityIntersectionResult EntityScriptingInterface::evalRayIntersectionWorker(const PickRay& ray, |
| 1189 | Octree::lockType lockType, PickFilter searchFilter, const QVector<EntityItemID>& entityIdsToInclude, | 1209 | Octree::lockType lockType, PickFilter searchFilter, const QVector<EntityItemID>& entityIdsToInclude, |
| 1190 | const QVector<EntityItemID>& entityIdsToDiscard) { | 1210 | const QVector<EntityItemID>& entityIdsToDiscard) const { |
| 1191 | 1211 | ||
| 1192 | RayToEntityIntersectionResult result; | 1212 | RayToEntityIntersectionResult result; |
| 1193 | if (_entityTree) { | 1213 | if (_entityTree) { |
| @@ -1213,7 +1233,7 @@ ParabolaToEntityIntersectionResult EntityScriptingInterface::evalParabolaInterse · 19 unmodified lines | |||
| 1213 | 1233 | ||
| 1214 | ParabolaToEntityIntersectionResult EntityScriptingInterface::evalParabolaIntersectionWorker(const PickParabola& parabola, | 1234 | ParabolaToEntityIntersectionResult EntityScriptingInterface::evalParabolaIntersectionWorker(const PickParabola& parabola, |
| 1215 | Octree::lockType lockType, PickFilter searchFilter, const QVector<EntityItemID>& entityIdsToInclude, | 1235 | Octree::lockType lockType, PickFilter searchFilter, const QVector<EntityItemID>& entityIdsToInclude, |
| 1216 | const QVector<EntityItemID>& entityIdsToDiscard) { | 1236 | const QVector<EntityItemID>& entityIdsToDiscard) const { |
| 1217 | 1237 | ||
| 1218 | ParabolaToEntityIntersectionResult result; | 1238 | ParabolaToEntityIntersectionResult result; |
| 1219 | if (_entityTree) { | 1239 | if (_entityTree) { |