History

remove overlays from application.cpp

SamGondelman committed 7 years ago

Commit 0bfcde61 parent a75fe4b13 files · +585 −544Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+59−22
@@ -571,7 +571,7 @@ QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QStrin · 570 unmodified lines
571 return addEntity(properties);571 return addEntity(properties);
572}572}
573 573
574QUuid EntityScriptingInterface::cloneEntity(QUuid entityIDToClone) {574QUuid EntityScriptingInterface::cloneEntity(const QUuid& entityIDToClone) {
575 EntityItemID newEntityID;575 EntityItemID newEntityID;
576 EntityItemProperties properties = getEntityProperties(entityIDToClone);576 EntityItemProperties properties = getEntityProperties(entityIDToClone);
577 bool cloneAvatarEntity = properties.getCloneAvatarEntity();577 bool cloneAvatarEntity = properties.getCloneAvatarEntity();
@@ -596,12 +596,12 @@ QUuid EntityScriptingInterface::cloneEntity(QUuid entityIDToClone) { · 18 unmodified lines
596 }596 }
597}597}
598 598
599EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid entityID) {599EntityItemProperties EntityScriptingInterface::getEntityProperties(const QUuid& entityID) {
600 const EntityPropertyFlags noSpecificProperties;600 const EntityPropertyFlags noSpecificProperties;
601 return getEntityProperties(entityID, noSpecificProperties);601 return getEntityProperties(entityID, noSpecificProperties);
602}602}
603 603
604EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid entityID, EntityPropertyFlags desiredProperties) {604EntityItemProperties EntityScriptingInterface::getEntityProperties(const QUuid& entityID, EntityPropertyFlags desiredProperties) {
605 PROFILE_RANGE(script_entities, __FUNCTION__);605 PROFILE_RANGE(script_entities, __FUNCTION__);
606 606
607 bool scalesWithParent { false };607 bool scalesWithParent { false };
@@ -775,7 +775,7 @@ QScriptValue EntityScriptingInterface::getMultipleEntityPropertiesInternal(QScri · 167 unmodified lines
775 return finalResult;775 return finalResult;
776}776}
777 777
778QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) {778QUuid EntityScriptingInterface::editEntity(const QUuid& id, const EntityItemProperties& scriptSideProperties) {
779 PROFILE_RANGE(script_entities, __FUNCTION__);779 PROFILE_RANGE(script_entities, __FUNCTION__);
780 780
781 _activityTracking.editedEntityCount++;781 _activityTracking.editedEntityCount++;
@@ -960,7 +960,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 178 unmodified lines
960 return id;960 return id;
961}961}
962 962
963void EntityScriptingInterface::deleteEntity(QUuid id) {963void EntityScriptingInterface::deleteEntity(const QUuid& id) {
964 PROFILE_RANGE(script_entities, __FUNCTION__);964 PROFILE_RANGE(script_entities, __FUNCTION__);
965 965
966 _activityTracking.deletedEntityCount++;966 _activityTracking.deletedEntityCount++;
@@ -1005,12 +1005,49 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 38 unmodified lines
1005 }1005 }
1006}1006}
1007 1007
1008QString EntityScriptingInterface::getEntityType(const QUuid& entityID) {
1009 QString toReturn;
1010 _entityTree->withReadLock([&] {
1011 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
1012 if (entity) {
1013 toReturn = EntityTypes::getEntityTypeName(entity->getType());
1014 }
1015 });
1016 return toReturn;
1017}
1018
1019QObject* EntityScriptingInterface::getEntityObject(const QUuid& id) {
1020 QObject* toReturn { nullptr };
1021 _entityTree->withReadLock([&] {
1022 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(id);
1023 if (entity) {
1024 toReturn = qobject_cast<QObject*>(&(*entity));
1025 }
1026 });
1027 return toReturn;
1028}
1029
1030bool EntityScriptingInterface::isLoaded(const QUuid& id) {
1031 bool toReturn = false;
1032 _entityTree->withReadLock([&] {
1033 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(id);
1034 if (entity) {
1035 toReturn = entity->isVisuallyReady();
1036 }
1037 });
1038 return toReturn;
1039}
1040
1041QSizeF EntityScriptingInterface::textSize(const QUuid& id, const QString& text) {
1042 return EntityTree::textSize(id, text);
1043}
1044
1008void EntityScriptingInterface::setEntitiesScriptEngine(QSharedPointer<EntitiesScriptEngineProvider> engine) {1045void EntityScriptingInterface::setEntitiesScriptEngine(QSharedPointer<EntitiesScriptEngineProvider> engine) {
1009 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);1046 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);
1010 _entitiesScriptEngine = engine;1047 _entitiesScriptEngine = engine;
1011}1048}
1012 1049
1013void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, const QStringList& params) {1050void EntityScriptingInterface::callEntityMethod(const QUuid& id, const QString& method, const QStringList& params) {
1014 PROFILE_RANGE(script_entities, __FUNCTION__);1051 PROFILE_RANGE(script_entities, __FUNCTION__);
1015 1052
1016 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);1053 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);
@@ -1020,12 +1057,12 @@ void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, · 3 unmodified lines
1020 }1057 }
1021}1058}
1022 1059
1023void EntityScriptingInterface::callEntityServerMethod(QUuid id, const QString& method, const QStringList& params) {1060void EntityScriptingInterface::callEntityServerMethod(const QUuid& id, const QString& method, const QStringList& params) {
1024 PROFILE_RANGE(script_entities, __FUNCTION__);1061 PROFILE_RANGE(script_entities, __FUNCTION__);
1025 DependencyManager::get<EntityScriptClient>()->callEntityServerMethod(id, method, params);1062 DependencyManager::get<EntityScriptClient>()->callEntityServerMethod(id, method, params);
1026}1063}
1027 1064
1028void EntityScriptingInterface::callEntityClientMethod(QUuid clientSessionID, QUuid entityID, const QString& method, const QStringList& params) {1065void EntityScriptingInterface::callEntityClientMethod(const QUuid& clientSessionID, const QUuid& entityID, const QString& method, const QStringList& params) {
1029 PROFILE_RANGE(script_entities, __FUNCTION__);1066 PROFILE_RANGE(script_entities, __FUNCTION__);
1030 auto scriptServerServices = DependencyManager::get<EntityScriptServerServices>();1067 auto scriptServerServices = DependencyManager::get<EntityScriptServerServices>();
1031 1068
@@ -1262,7 +1299,7 @@ ParabolaToEntityIntersectionResult EntityScriptingInterface::evalParabolaInterse · 230 unmodified lines
1262 return result;1299 return result;
1263}1300}
1264 1301
1265bool EntityScriptingInterface::reloadServerScripts(QUuid entityID) {1302bool EntityScriptingInterface::reloadServerScripts(const QUuid& entityID) {
1266 auto client = DependencyManager::get<EntityScriptClient>();1303 auto client = DependencyManager::get<EntityScriptClient>();
1267 return client->reloadServerScript(entityID);1304 return client->reloadServerScript(entityID);
1268}1305}
@@ -1335,7 +1372,7 @@ bool EntityPropertyMetadataRequest::serverScripts(EntityItemID entityID, QScript · 66 unmodified lines
1335 return true;1372 return true;
1336}1373}
1337 1374
1338bool EntityScriptingInterface::queryPropertyMetadata(QUuid entityID, QScriptValue property, QScriptValue scopeOrCallback, QScriptValue methodOrName) {1375bool EntityScriptingInterface::queryPropertyMetadata(const QUuid& entityID, QScriptValue property, QScriptValue scopeOrCallback, QScriptValue methodOrName) {
1339 auto name = property.toString();1376 auto name = property.toString();
1340 auto handler = makeScopedHandlerObject(scopeOrCallback, methodOrName);1377 auto handler = makeScopedHandlerObject(scopeOrCallback, methodOrName);
1341 QPointer<BaseScriptEngine> engine = dynamic_cast<BaseScriptEngine*>(handler.engine());1378 QPointer<BaseScriptEngine> engine = dynamic_cast<BaseScriptEngine*>(handler.engine());
@@ -1379,7 +1416,7 @@ bool EntityScriptingInterface::queryPropertyMetadata(QUuid entityID, QScriptValu · 37 unmodified lines
1379 }1416 }
1380}1417}
1381 1418
1382bool EntityScriptingInterface::getServerScriptStatus(QUuid entityID, QScriptValue callback) {1419bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, QScriptValue callback) {
1383 auto client = DependencyManager::get<EntityScriptClient>();1420 auto client = DependencyManager::get<EntityScriptClient>();
1384 auto request = client->createScriptStatusRequest(entityID);1421 auto request = client->createScriptStatusRequest(entityID);
1385 connect(request, &GetScriptStatusRequest::finished, callback.engine(), [callback](GetScriptStatusRequest* request) mutable {1422 connect(request, &GetScriptStatusRequest::finished, callback.engine(), [callback](GetScriptStatusRequest* request) mutable {
@@ -1518,14 +1555,14 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(Line · 132 unmodified lines
1518 return success;1555 return success;
1519}1556}
1520 1557
1521bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value) {1558bool EntityScriptingInterface::setVoxelSphere(const QUuid& entityID, const glm::vec3& center, float radius, int value) {
1522 PROFILE_RANGE(script_entities, __FUNCTION__);1559 PROFILE_RANGE(script_entities, __FUNCTION__);
1523 return polyVoxWorker(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) {1560 return polyVoxWorker(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) {
1524 return polyVoxEntity.setSphere(center, radius, value);1561 return polyVoxEntity.setSphere(center, radius, value);
1525 });1562 });
1526}1563}
1527 1564
1528bool EntityScriptingInterface::setVoxelCapsule(QUuid entityID,1565bool EntityScriptingInterface::setVoxelCapsule(const QUuid& entityID,
1529 const glm::vec3& start, const glm::vec3& end,1566 const glm::vec3& start, const glm::vec3& end,
1530 float radius, int value) {1567 float radius, int value) {
1531 PROFILE_RANGE(script_entities, __FUNCTION__);1568 PROFILE_RANGE(script_entities, __FUNCTION__);
@@ -1535,7 +1572,7 @@ bool EntityScriptingInterface::setVoxelCapsule(QUuid entityID, · 3 unmodified lines
1535 });1572 });
1536}1573}
1537 1574
1538bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) {1575bool EntityScriptingInterface::setVoxel(const QUuid& entityID, const glm::vec3& position, int value) {
1539 PROFILE_RANGE(script_entities, __FUNCTION__);1576 PROFILE_RANGE(script_entities, __FUNCTION__);
1540 1577
1541 return polyVoxWorker(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {1578 return polyVoxWorker(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {
@@ -1543,7 +1580,7 @@ bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& positio · 1 unmodified line
1543 });1580 });
1544}1581}
1545 1582
1546bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {1583bool EntityScriptingInterface::setAllVoxels(const QUuid& entityID, int value) {
1547 PROFILE_RANGE(script_entities, __FUNCTION__);1584 PROFILE_RANGE(script_entities, __FUNCTION__);
1548 1585
1549 return polyVoxWorker(entityID, [value](PolyVoxEntityItem& polyVoxEntity) {1586 return polyVoxWorker(entityID, [value](PolyVoxEntityItem& polyVoxEntity) {
@@ -1551,7 +1588,7 @@ bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) { · 1 unmodified line
1551 });1588 });
1552}1589}
1553 1590
1554bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition,1591bool EntityScriptingInterface::setVoxelsInCuboid(const QUuid& entityID, const glm::vec3& lowPosition,
1555 const glm::vec3& cuboidSize, int value) {1592 const glm::vec3& cuboidSize, int value) {
1556 PROFILE_RANGE(script_entities, __FUNCTION__);1593 PROFILE_RANGE(script_entities, __FUNCTION__);
1557 1594
@@ -1560,7 +1597,7 @@ bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3 · 2 unmodified lines
1560 });1597 });
1561}1598}
1562 1599
1563bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {1600bool EntityScriptingInterface::setAllPoints(const QUuid& entityID, const QVector<glm::vec3>& points) {
1564 PROFILE_RANGE(script_entities, __FUNCTION__);1601 PROFILE_RANGE(script_entities, __FUNCTION__);
1565 1602
1566 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));1603 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
@@ -1580,7 +1617,7 @@ bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::v · 13 unmodified lines
1580 return false;1617 return false;
1581}1618}
1582 1619
1583bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& point) {1620bool EntityScriptingInterface::appendPoint(const QUuid& entityID, const glm::vec3& point) {
1584 PROFILE_RANGE(script_entities, __FUNCTION__);1621 PROFILE_RANGE(script_entities, __FUNCTION__);
1585 1622
1586 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));1623 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
@@ -2040,7 +2077,7 @@ QVector<QUuid> EntityScriptingInterface::getChildrenIDs(const QUuid& parentID) { · 453 unmodified lines
2040 return result;2077 return result;
2041}2078}
2042 2079
2043bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) {2080bool EntityScriptingInterface::isChildOfParent(const QUuid& childID, const QUuid& parentID) {
2044 bool isChild = false;2081 bool isChild = false;
2045 2082
2046 if (!_entityTree) {2083 if (!_entityTree) {
@@ -2062,7 +2099,7 @@ bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) { · 15 unmodified lines
2062 return isChild;2099 return isChild;
2063}2100}
2064 2101
2065QString EntityScriptingInterface::getNestableType(QUuid id) {2102QString EntityScriptingInterface::getNestableType(const QUuid& id) {
2066 QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();2103 QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
2067 if (!parentFinder) {2104 if (!parentFinder) {
2068 return "unknown";2105 return "unknown";
@@ -2164,7 +2201,7 @@ void EntityScriptingInterface::sendHoverLeaveEntity(const EntityItemID& id, cons · 95 unmodified lines
2164 emit hoverLeaveEntity(id, event);2201 emit hoverLeaveEntity(id, event);
2165}2202}
2166 2203
2167bool EntityScriptingInterface::wantsHandControllerPointerEvents(QUuid id) {2204bool EntityScriptingInterface::wantsHandControllerPointerEvents(const QUuid& id) {
2168 bool result = false;2205 bool result = false;
2169 if (_entityTree) {2206 if (_entityTree) {
2170 _entityTree->withReadLock([&] {2207 _entityTree->withReadLock([&] {
@@ -2196,7 +2233,7 @@ bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, cons · 25 unmodified lines
2196 return aaBox.findCapsulePenetration(start, end, radius, penetration);2233 return aaBox.findCapsulePenetration(start, end, radius, penetration);
2197}2234}
2198 2235
2199void EntityScriptingInterface::getMeshes(QUuid entityID, QScriptValue callback) {2236void EntityScriptingInterface::getMeshes(const QUuid& entityID, QScriptValue callback) {
2200 PROFILE_RANGE(script_entities, __FUNCTION__);2237 PROFILE_RANGE(script_entities, __FUNCTION__);
2201 2238
2202 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));2239 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));