Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -178,6 +178,8 @@ EntityItemProperties convertLocationFromScriptSemantics(const EntityItemProperti · 177 unmodified lines | ||
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, bool clientOnly) { |
| 181 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 182 | + | |
| 181 | 183 | _activityTracking.addedEntityCount++; |
| 182 | 184 | |
| 183 | 185 | EntityItemProperties propertiesWithSimID = convertLocationFromScriptSemantics(properties); |
| @@ -270,6 +272,8 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 86 unmodified lines | ||
| 270 | 272 | } |
| 271 | 273 | |
| 272 | 274 | EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identity, EntityPropertyFlags desiredProperties) { |
| 275 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 276 | + | |
| 273 | 277 | EntityItemProperties results; |
| 274 | 278 | if (_entityTree) { |
| 275 | 279 | _entityTree->withReadLock([&] { |
| @@ -316,6 +320,8 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 40 unmodified lines | ||
| 316 | 320 | } |
| 317 | 321 | |
| 318 | 322 | QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) { |
| 323 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 324 | + | |
| 319 | 325 | _activityTracking.editedEntityCount++; |
| 320 | 326 | |
| 321 | 327 | EntityItemProperties properties = scriptSideProperties; |
| @@ -467,6 +473,8 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 145 unmodified lines | ||
| 467 | 473 | } |
| 468 | 474 | |
| 469 | 475 | void EntityScriptingInterface::deleteEntity(QUuid id) { |
| 476 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 477 | + | |
| 470 | 478 | _activityTracking.deletedEntityCount++; |
| 471 | 479 | |
| 472 | 480 | EntityItemID entityID(id); |
| @@ -522,6 +530,8 @@ void EntityScriptingInterface::setEntitiesScriptEngine(EntitiesScriptEngineProvi · 49 unmodified lines | ||
| 522 | 530 | } |
| 523 | 531 | |
| 524 | 532 | void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, const QStringList& params) { |
| 533 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 534 | + | |
| 525 | 535 | std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock); |
| 526 | 536 | if (_entitiesScriptEngine) { |
| 527 | 537 | EntityItemID entityID{ id }; |
| @@ -530,6 +540,8 @@ void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, · 2 unmodified lines | ||
| 530 | 540 | } |
| 531 | 541 | |
| 532 | 542 | QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const { |
| 543 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 544 | + | |
| 533 | 545 | EntityItemID result; |
| 534 | 546 | if (_entityTree) { |
| 535 | 547 | EntityItemPointer closestEntity; |
| @@ -553,6 +565,8 @@ void EntityScriptingInterface::dumpTree() const { · 17 unmodified lines | ||
| 553 | 565 | } |
| 554 | 566 | |
| 555 | 567 | QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const { |
| 568 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 569 | + | |
| 556 | 570 | QVector<QUuid> result; |
| 557 | 571 | if (_entityTree) { |
| 558 | 572 | QVector<EntityItemPointer> entities; |
| @@ -568,6 +582,8 @@ QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, f · 9 unmodified lines | ||
| 568 | 582 | } |
| 569 | 583 | |
| 570 | 584 | QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const { |
| 585 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 586 | + | |
| 571 | 587 | QVector<QUuid> result; |
| 572 | 588 | if (_entityTree) { |
| 573 | 589 | QVector<EntityItemPointer> entities; |
| @@ -584,6 +600,8 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corn · 10 unmodified lines | ||
| 584 | 600 | } |
| 585 | 601 | |
| 586 | 602 | QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum) const { |
| 603 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 604 | + | |
| 587 | 605 | QVector<QUuid> result; |
| 588 | 606 | |
| 589 | 607 | const QString POSITION_PROPERTY = "position"; |
| @@ -627,6 +645,7 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust · 37 unmodified lines | ||
| 627 | 645 | |
| 628 | 646 | RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, |
| 629 | 647 | const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) { |
| 648 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 630 | 649 | |
| 631 | 650 | QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude); |
| 632 | 651 | QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard); |
| @@ -734,6 +753,8 @@ RayToEntityIntersectionResult::RayToEntityIntersectionResult() : · 101 unmodified lines | ||
| 734 | 753 | } |
| 735 | 754 | |
| 736 | 755 | QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) { |
| 756 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 757 | + | |
| 737 | 758 | QScriptValue obj = engine->newObject(); |
| 738 | 759 | obj.setProperty("intersects", value.intersects); |
| 739 | 760 | obj.setProperty("accurate", value.accurate); |
| @@ -781,6 +802,8 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 41 unmodified lines | ||
| 781 | 802 | } |
| 782 | 803 | |
| 783 | 804 | void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) { |
| 805 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 806 | + | |
| 784 | 807 | value.intersects = object.property("intersects").toVariant().toBool(); |
| 785 | 808 | value.accurate = object.property("accurate").toVariant().toBool(); |
| 786 | 809 | QScriptValue entityIDValue = object.property("entityID"); |
| @@ -818,6 +841,8 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra · 31 unmodified lines | ||
| 818 | 841 | |
| 819 | 842 | bool EntityScriptingInterface::setVoxels(QUuid entityID, |
| 820 | 843 | std::function<bool(PolyVoxEntityItem&)> actor) { |
| 844 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 845 | + | |
| 821 | 846 | if (!_entityTree) { |
| 822 | 847 | return false; |
| 823 | 848 | } |
| @@ -842,6 +867,8 @@ bool EntityScriptingInterface::setVoxels(QUuid entityID, · 18 unmodified lines | ||
| 842 | 867 | } |
| 843 | 868 | |
| 844 | 869 | bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(LineEntityItem&)> actor) { |
| 870 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 871 | + | |
| 845 | 872 | if (!_entityTree) { |
| 846 | 873 | return false; |
| 847 | 874 | } |
| @@ -881,18 +908,24 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(Line · 33 unmodified lines | ||
| 881 | 908 | |
| 882 | 909 | |
| 883 | 910 | bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value) { |
| 911 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 912 | + | |
| 884 | 913 | return setVoxels(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) { |
| 885 | 914 | return polyVoxEntity.setSphere(center, radius, value); |
| 886 | 915 | }); |
| 887 | 916 | } |
| 888 | 917 | |
| 889 | 918 | bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) { |
| 919 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 920 | + | |
| 890 | 921 | return setVoxels(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) { |
| 891 | 922 | return polyVoxEntity.setVoxelInVolume(position, value); |
| 892 | 923 | }); |
| 893 | 924 | } |
| 894 | 925 | |
| 895 | 926 | bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) { |
| 927 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 928 | + | |
| 896 | 929 | return setVoxels(entityID, [value](PolyVoxEntityItem& polyVoxEntity) { |
| 897 | 930 | return polyVoxEntity.setAll(value); |
| 898 | 931 | }); |
| @@ -900,12 +933,16 @@ bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) { · 1 unmodified line | ||
| 900 | 933 | |
| 901 | 934 | bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition, |
| 902 | 935 | const glm::vec3& cuboidSize, int value) { |
| 936 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 937 | + | |
| 903 | 938 | return setVoxels(entityID, [lowPosition, cuboidSize, value](PolyVoxEntityItem& polyVoxEntity) { |
| 904 | 939 | return polyVoxEntity.setCuboid(lowPosition, cuboidSize, value); |
| 905 | 940 | }); |
| 906 | 941 | } |
| 907 | 942 | |
| 908 | 943 | bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) { |
| 944 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 945 | + | |
| 909 | 946 | EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID)); |
| 910 | 947 | if (!entity) { |
| 911 | 948 | qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID; |
| @@ -924,6 +961,8 @@ bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::v · 12 unmodified lines | ||
| 924 | 961 | } |
| 925 | 962 | |
| 926 | 963 | bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& point) { |
| 964 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 965 | + | |
| 927 | 966 | EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID)); |
| 928 | 967 | if (!entity) { |
| 929 | 968 | qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID; |
| @@ -999,6 +1038,8 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID, · 69 unmodified lines | ||
| 999 | 1038 | QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, |
| 1000 | 1039 | const QUuid& entityID, |
| 1001 | 1040 | const QVariantMap& arguments) { |
| 1041 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1042 | + | |
| 1002 | 1043 | QUuid actionID = QUuid::createUuid(); |
| 1003 | 1044 | auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>(); |
| 1004 | 1045 | bool success = false; |
| @@ -1030,6 +1071,8 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 25 unmodified lines | ||
| 1030 | 1071 | |
| 1031 | 1072 | |
| 1032 | 1073 | bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& actionID, const QVariantMap& arguments) { |
| 1074 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1075 | + | |
| 1033 | 1076 | return actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) { |
| 1034 | 1077 | bool success = entity->updateAction(simulation, actionID, arguments); |
| 1035 | 1078 | if (success) { |
| @@ -1040,6 +1083,8 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& · 4 unmodified lines | ||
| 1040 | 1083 | } |
| 1041 | 1084 | |
| 1042 | 1085 | bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) { |
| 1086 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1087 | + | |
| 1043 | 1088 | bool success = false; |
| 1044 | 1089 | actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) { |
| 1045 | 1090 | success = entity->removeAction(simulation, actionID); |
| @@ -1053,6 +1098,8 @@ bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& · 7 unmodified lines | ||
| 1053 | 1098 | } |
| 1054 | 1099 | |
| 1055 | 1100 | QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { |
| 1101 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1102 | + | |
| 1056 | 1103 | QVector<QUuid> result; |
| 1057 | 1104 | actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) { |
| 1058 | 1105 | QList<QUuid> actionIDs = entity->getActionIDs(); |
| @@ -1063,6 +1110,8 @@ QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) { · 4 unmodified lines | ||
| 1063 | 1110 | } |
| 1064 | 1111 | |
| 1065 | 1112 | QVariantMap EntityScriptingInterface::getActionArguments(const QUuid& entityID, const QUuid& actionID) { |
| 1113 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1114 | + | |
| 1066 | 1115 | QVariantMap result; |
| 1067 | 1116 | actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) { |
| 1068 | 1117 | result = entity->getActionArguments(actionID); |