History

merge from upstream

Seth Alves committed 9 years ago

Commit e8a9ff82 parents 9881dd2 546f324463 files · +21986 −6894Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+121−59
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include "ZoneEntityItem.h"27#include "ZoneEntityItem.h"
28#include "WebEntityItem.h"28#include "WebEntityItem.h"
29#include <EntityScriptClient.h>29#include <EntityScriptClient.h>
30#include <Profile.h>
30 31
31 32
32EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership) :33EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership) :
@@ -178,6 +179,8 @@ EntityItemProperties convertLocationFromScriptSemantics(const EntityItemProperti · 145 unmodified lines
178 179
179 180
180QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, bool clientOnly) {181QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, bool clientOnly) {
182 PROFILE_RANGE(script_entities, __FUNCTION__);
183
181 _activityTracking.addedEntityCount++;184 _activityTracking.addedEntityCount++;
182 185
183 EntityItemProperties propertiesWithSimID = convertLocationFromScriptSemantics(properties);186 EntityItemProperties propertiesWithSimID = convertLocationFromScriptSemantics(properties);
@@ -259,6 +262,8 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 75 unmodified lines
259}262}
260 263
261EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identity, EntityPropertyFlags desiredProperties) {264EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identity, EntityPropertyFlags desiredProperties) {
265 PROFILE_RANGE(script_entities, __FUNCTION__);
266
262 EntityItemProperties results;267 EntityItemProperties results;
263 if (_entityTree) {268 if (_entityTree) {
264 _entityTree->withReadLock([&] {269 _entityTree->withReadLock([&] {
@@ -280,7 +285,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 15 unmodified lines
280 desiredProperties = entity->getEntityProperties(params);285 desiredProperties = entity->getEntityProperties(params);
281 desiredProperties.setHasProperty(PROP_LOCAL_POSITION);286 desiredProperties.setHasProperty(PROP_LOCAL_POSITION);
282 desiredProperties.setHasProperty(PROP_LOCAL_ROTATION);287 desiredProperties.setHasProperty(PROP_LOCAL_ROTATION);
283 }288 }
284 289
285 results = entity->getProperties(desiredProperties);290 results = entity->getProperties(desiredProperties);
286 291
@@ -305,6 +310,8 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit · 18 unmodified lines
305}310}
306 311
307QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) {312QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) {
313 PROFILE_RANGE(script_entities, __FUNCTION__);
314
308 _activityTracking.editedEntityCount++;315 _activityTracking.editedEntityCount++;
309 316
310 EntityItemProperties properties = scriptSideProperties;317 EntityItemProperties properties = scriptSideProperties;
@@ -456,6 +463,8 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 145 unmodified lines
456}463}
457 464
458void EntityScriptingInterface::deleteEntity(QUuid id) {465void EntityScriptingInterface::deleteEntity(QUuid id) {
466 PROFILE_RANGE(script_entities, __FUNCTION__);
467
459 _activityTracking.deletedEntityCount++;468 _activityTracking.deletedEntityCount++;
460 469
461 EntityItemID entityID(id);470 EntityItemID entityID(id);
@@ -511,6 +520,8 @@ void EntityScriptingInterface::setEntitiesScriptEngine(EntitiesScriptEngineProvi · 49 unmodified lines
511}520}
512 521
513void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, const QStringList& params) {522void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, const QStringList& params) {
523 PROFILE_RANGE(script_entities, __FUNCTION__);
524
514 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);525 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);
515 if (_entitiesScriptEngine) {526 if (_entitiesScriptEngine) {
516 EntityItemID entityID{ id };527 EntityItemID entityID{ id };
@@ -519,6 +530,8 @@ void EntityScriptingInterface::callEntityMethod(QUuid id, const QString& method, · 2 unmodified lines
519}530}
520 531
521QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {532QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
533 PROFILE_RANGE(script_entities, __FUNCTION__);
534
522 EntityItemID result;535 EntityItemID result;
523 if (_entityTree) {536 if (_entityTree) {
524 EntityItemPointer closestEntity;537 EntityItemPointer closestEntity;
@@ -542,6 +555,8 @@ void EntityScriptingInterface::dumpTree() const { · 17 unmodified lines
542}555}
543 556
544QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {557QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {
558 PROFILE_RANGE(script_entities, __FUNCTION__);
559
545 QVector<QUuid> result;560 QVector<QUuid> result;
546 if (_entityTree) {561 if (_entityTree) {
547 QVector<EntityItemPointer> entities;562 QVector<EntityItemPointer> entities;
@@ -557,6 +572,8 @@ QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, f · 9 unmodified lines
557}572}
558 573
559QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {574QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
575 PROFILE_RANGE(script_entities, __FUNCTION__);
576
560 QVector<QUuid> result;577 QVector<QUuid> result;
561 if (_entityTree) {578 if (_entityTree) {
562 QVector<EntityItemPointer> entities;579 QVector<EntityItemPointer> entities;
@@ -573,6 +590,8 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corn · 10 unmodified lines
573}590}
574 591
575QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum) const {592QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum) const {
593 PROFILE_RANGE(script_entities, __FUNCTION__);
594
576 QVector<QUuid> result;595 QVector<QUuid> result;
577 596
578 const QString POSITION_PROPERTY = "position";597 const QString POSITION_PROPERTY = "position";
@@ -616,6 +635,7 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust · 37 unmodified lines
616 635
617RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, 636RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking,
618 const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) {637 const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) {
638 PROFILE_RANGE(script_entities, __FUNCTION__);
619 639
620 QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude);640 QVector<EntityItemID> entitiesToInclude = qVectorEntityItemIDFromScriptValue(entityIdsToInclude);
621 QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard);641 QVector<EntityItemID> entitiesToDiscard = qVectorEntityItemIDFromScriptValue(entityIdsToDiscard);
@@ -664,22 +684,8 @@ bool EntityScriptingInterface::getServerScriptStatus(QUuid entityID, QScriptValu · 42 unmodified lines
664 auto client = DependencyManager::get<EntityScriptClient>();684 auto client = DependencyManager::get<EntityScriptClient>();
665 auto request = client->createScriptStatusRequest(entityID);685 auto request = client->createScriptStatusRequest(entityID);
666 connect(request, &GetScriptStatusRequest::finished, callback.engine(), [callback](GetScriptStatusRequest* request) mutable {686 connect(request, &GetScriptStatusRequest::finished, callback.engine(), [callback](GetScriptStatusRequest* request) mutable {
667 QString statusString;687 QString statusString = EntityScriptStatus_::valueToKey(request->getStatus());;
668 switch (request->getStatus()) {688 QScriptValueList args { request->getResponseReceived(), request->getIsRunning(), statusString.toLower(), request->getErrorInfo() };
669 case RUNNING:
670 statusString = "running";
671 break;
672 case ERROR_LOADING_SCRIPT:
673 statusString = "error_loading_script";
674 break;
675 case ERROR_RUNNING_SCRIPT:
676 statusString = "error_running_script";
677 break;
678 default:
679 statusString = "";
680 break;
681 }
682 QScriptValueList args { request->getResponseReceived(), request->getIsRunning(), statusString, request->getErrorInfo() };
683 callback.call(QScriptValue(), args);689 callback.call(QScriptValue(), args);
684 request->deleteLater();690 request->deleteLater();
685 });691 });
@@ -723,6 +729,8 @@ RayToEntityIntersectionResult::RayToEntityIntersectionResult() : · 37 unmodified lines
723}729}
724 730
725QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {731QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {
732 PROFILE_RANGE(script_entities, __FUNCTION__);
733
726 QScriptValue obj = engine->newObject();734 QScriptValue obj = engine->newObject();
727 obj.setProperty("intersects", value.intersects);735 obj.setProperty("intersects", value.intersects);
728 obj.setProperty("accurate", value.accurate);736 obj.setProperty("accurate", value.accurate);
@@ -770,6 +778,8 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 41 unmodified lines
770}778}
771 779
772void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {780void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
781 PROFILE_RANGE(script_entities, __FUNCTION__);
782
773 value.intersects = object.property("intersects").toVariant().toBool();783 value.intersects = object.property("intersects").toVariant().toBool();
774 value.accurate = object.property("accurate").toVariant().toBool();784 value.accurate = object.property("accurate").toVariant().toBool();
775 QScriptValue entityIDValue = object.property("entityID");785 QScriptValue entityIDValue = object.property("entityID");
@@ -806,13 +816,15 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra · 30 unmodified lines
806}816}
807 817
808bool EntityScriptingInterface::polyVoxWorker(QUuid entityID, std::function<bool(PolyVoxEntityItem&)> actor) {818bool EntityScriptingInterface::polyVoxWorker(QUuid entityID, std::function<bool(PolyVoxEntityItem&)> actor) {
819 PROFILE_RANGE(script_entities, __FUNCTION__);
820
809 if (!_entityTree) {821 if (!_entityTree) {
810 return false;822 return false;
811 }823 }
812 824
813 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);825 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
814 if (!entity) {826 if (!entity) {
815 qCDebug(entities) << "EntityScriptingInterface::setVoxelSphere no entity with ID" << entityID;827 qCDebug(entities) << "EntityScriptingInterface::setVoxels no entity with ID" << entityID;
816 return false;828 return false;
817 }829 }
818 830
@@ -830,6 +842,8 @@ bool EntityScriptingInterface::polyVoxWorker(QUuid entityID, std::function<bool( · 11 unmodified lines
830}842}
831 843
832bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(LineEntityItem&)> actor) {844bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(LineEntityItem&)> actor) {
845 PROFILE_RANGE(script_entities, __FUNCTION__);
846
833 if (!_entityTree) {847 if (!_entityTree) {
834 return false;848 return false;
835 }849 }
@@ -869,18 +883,41 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(Line · 33 unmodified lines
869 883
870 884
871bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value) {885bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value) {
886 PROFILE_RANGE(script_entities, __FUNCTION__);
872 return polyVoxWorker(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) {887 return polyVoxWorker(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) {
873 return polyVoxEntity.setSphere(center, radius, value);888 return polyVoxEntity.setSphere(center, radius, value);
874 });889 });
875}890}
876 891
877bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) {892bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) {
893 PROFILE_RANGE(script_entities, __FUNCTION__);
894
878 return polyVoxWorker(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {895 return polyVoxWorker(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {
896 return polyVoxEntity.setSphere(center, radius, value);
897 });
898}
899
900bool EntityScriptingInterface::setVoxelCapsule(QUuid entityID,
901 const glm::vec3& start, const glm::vec3& end,
902 float radius, int value) {
903 PROFILE_RANGE(script_entities, __FUNCTION__);
904
905 return setVoxels(entityID, [start, end, radius, value](PolyVoxEntityItem& polyVoxEntity) {
906 return polyVoxEntity.setCapsule(start, end, radius, value);
907 });
908}
909
910bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) {
911 PROFILE_RANGE(script_entities, __FUNCTION__);
912
913 return setVoxels(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {
879 return polyVoxEntity.setVoxelInVolume(position, value);914 return polyVoxEntity.setVoxelInVolume(position, value);
880 });915 });
881}916}
882 917
883bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {918bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {
919 PROFILE_RANGE(script_entities, __FUNCTION__);
920
884 return polyVoxWorker(entityID, [value](PolyVoxEntityItem& polyVoxEntity) {921 return polyVoxWorker(entityID, [value](PolyVoxEntityItem& polyVoxEntity) {
885 return polyVoxEntity.setAll(value);922 return polyVoxEntity.setAll(value);
886 });923 });
@@ -888,12 +925,16 @@ bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) { · 1 unmodified line
888 925
889bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition,926bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition,
890 const glm::vec3& cuboidSize, int value) {927 const glm::vec3& cuboidSize, int value) {
928 PROFILE_RANGE(script_entities, __FUNCTION__);
929
891 return polyVoxWorker(entityID, [lowPosition, cuboidSize, value](PolyVoxEntityItem& polyVoxEntity) {930 return polyVoxWorker(entityID, [lowPosition, cuboidSize, value](PolyVoxEntityItem& polyVoxEntity) {
892 return polyVoxEntity.setCuboid(lowPosition, cuboidSize, value);931 return polyVoxEntity.setCuboid(lowPosition, cuboidSize, value);
893 });932 });
894}933}
895 934
896void EntityScriptingInterface::voxelsToMesh(QUuid entityID, QScriptValue callback) {935void EntityScriptingInterface::voxelsToMesh(QUuid entityID, QScriptValue callback) {
936 PROFILE_RANGE(script_entities, __FUNCTION__);
937
897 polyVoxWorker(entityID, [callback](PolyVoxEntityItem& polyVoxEntity) mutable {938 polyVoxWorker(entityID, [callback](PolyVoxEntityItem& polyVoxEntity) mutable {
898 QScriptValue mesh;939 QScriptValue mesh;
899 polyVoxEntity.getMeshAsScriptValue(callback.engine(), mesh);940 polyVoxEntity.getMeshAsScriptValue(callback.engine(), mesh);
@@ -904,6 +945,8 @@ void EntityScriptingInterface::voxelsToMesh(QUuid entityID, QScriptValue callbac · 4 unmodified lines
904}945}
905 946
906bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {947bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {
948 PROFILE_RANGE(script_entities, __FUNCTION__);
949
907 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));950 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
908 if (!entity) {951 if (!entity) {
909 qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID;952 qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID;
@@ -922,6 +965,8 @@ bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::v · 12 unmodified lines
922}965}
923 966
924bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& point) {967bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& point) {
968 PROFILE_RANGE(script_entities, __FUNCTION__);
969
925 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));970 EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
926 if (!entity) {971 if (!entity) {
927 qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID;972 qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID;
@@ -997,29 +1042,31 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID, · 69 unmodified lines
997QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,1042QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
998 const QUuid& entityID,1043 const QUuid& entityID,
999 const QVariantMap& arguments) {1044 const QVariantMap& arguments) {
1045 PROFILE_RANGE(script_entities, __FUNCTION__);
1046
1000 QUuid actionID = QUuid::createUuid();1047 QUuid actionID = QUuid::createUuid();
1001 auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>();1048 auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>();
1002 bool success = false;1049 bool success = false;
1003 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {1050 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {
1004 // create this action even if the entity doesn't have physics info. it will often be the1051 // create this action even if the entity doesn't have physics info. it will often be the
1005 // case that a script adds an action immediately after an object is created, and the physicsInfo1052 // case that a script adds an action immediately after an object is created, and the physicsInfo
1006 // is computed asynchronously.1053 // is computed asynchronously.
1007 // if (!entity->getPhysicsInfo()) {1054 // if (!entity->getPhysicsInfo()) {
1008 // return false;1055 // return false;
1009 // }1056 // }
1010 EntityActionType actionType = EntityActionInterface::actionTypeFromString(actionTypeString);1057 EntityActionType actionType = EntityActionInterface::actionTypeFromString(actionTypeString);
1011 if (actionType == ACTION_TYPE_NONE) {1058 if (actionType == ACTION_TYPE_NONE) {
1012 return false;1059 return false;
1013 }1060 }
1014 EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments);1061 EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments);
1015 if (!action) {1062 if (!action) {
1016 return false;1063 return false;
1017 }1064 }
1018 action->setIsMine(true);1065 action->setIsMine(true);
1019 success = entity->addAction(simulation, action);1066 success = entity->addAction(simulation, action);
1020 entity->grabSimulationOwnership();1067 entity->grabSimulationOwnership();
1021 return false; // Physics will cause a packet to be sent, so don't send from here.1068 return false; // Physics will cause a packet to be sent, so don't send from here.
1022 });1069 });
1023 if (success) {1070 if (success) {
1024 return actionID;1071 return actionID;
1025 }1072 }
@@ -1028,44 +1075,52 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 2 unmodified lines
1028 1075
1029 1076
1030bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& actionID, const QVariantMap& arguments) {1077bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& actionID, const QVariantMap& arguments) {
1078 PROFILE_RANGE(script_entities, __FUNCTION__);
1079
1031 return actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {1080 return actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {
1032 bool success = entity->updateAction(simulation, actionID, arguments);1081 bool success = entity->updateAction(simulation, actionID, arguments);
1033 if (success) {1082 if (success) {
1034 entity->grabSimulationOwnership();1083 entity->grabSimulationOwnership();
1035 }1084 }
1036 return success;1085 return success;
1037 });1086 });
1038}1087}
1039 1088
1040bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) {1089bool EntityScriptingInterface::deleteAction(const QUuid& entityID, const QUuid& actionID) {
1090 PROFILE_RANGE(script_entities, __FUNCTION__);
1091
1041 bool success = false;1092 bool success = false;
1042 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {1093 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {
1043 success = entity->removeAction(simulation, actionID);1094 success = entity->removeAction(simulation, actionID);
1044 if (success) {1095 if (success) {
1045 // reduce from grab to poke1096 // reduce from grab to poke
1046 entity->pokeSimulationOwnership();1097 entity->pokeSimulationOwnership();
1047 }1098 }
1048 return false; // Physics will cause a packet to be sent, so don't send from here.1099 return false; // Physics will cause a packet to be sent, so don't send from here.
1049 });1100 });
1050 return success;1101 return success;
1051}1102}
1052 1103
1053QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) {1104QVector<QUuid> EntityScriptingInterface::getActionIDs(const QUuid& entityID) {
1105 PROFILE_RANGE(script_entities, __FUNCTION__);
1106
1054 QVector<QUuid> result;1107 QVector<QUuid> result;
1055 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {1108 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {
1056 QList<QUuid> actionIDs = entity->getActionIDs();1109 QList<QUuid> actionIDs = entity->getActionIDs();
1057 result = QVector<QUuid>::fromList(actionIDs);1110 result = QVector<QUuid>::fromList(actionIDs);
1058 return false; // don't send an edit packet1111 return false; // don't send an edit packet
1059 });1112 });
1060 return result;1113 return result;
1061}1114}
1062 1115
1063QVariantMap EntityScriptingInterface::getActionArguments(const QUuid& entityID, const QUuid& actionID) {1116QVariantMap EntityScriptingInterface::getActionArguments(const QUuid& entityID, const QUuid& actionID) {
1117 PROFILE_RANGE(script_entities, __FUNCTION__);
1118
1064 QVariantMap result;1119 QVariantMap result;
1065 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {1120 actionWorker(entityID, [&](EntitySimulationPointer simulation, EntityItemPointer entity) {
1066 result = entity->getActionArguments(actionID);1121 result = entity->getActionArguments(actionID);
1067 return false; // don't send an edit packet1122 return false; // don't send an edit packet
1068 });1123 });
1069 return result;1124 return result;
1070}1125}
1071 1126
@@ -1392,8 +1447,7 @@ QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& pare · 320 unmodified lines
1392 return;1447 return;
1393 }1448 }
1394 parent->forEachChild([&](SpatiallyNestablePointer child) {1449 parent->forEachChild([&](SpatiallyNestablePointer child) {
1395 if (child->getParentJointIndex() == jointIndex &&1450 if (child->getParentJointIndex() == jointIndex) {
1396 child->getNestableType() != NestableType::Overlay) {
1397 result.push_back(child->getID());1451 result.push_back(child->getID());
1398 }1452 }
1399 });1453 });
@@ -1497,3 +1551,11 @@ QObject* EntityScriptingInterface::getWebViewRoot(const QUuid& entityID) { · 97 unmodified lines
1497 return nullptr;1551 return nullptr;
1498 }1552 }
1499}1553}
1554
1555// TODO move this someplace that makes more sense...
1556bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, const glm::vec3& dimensions,
1557 const glm::vec3& start, const glm::vec3& end, float radius) {
1558 glm::vec3 penetration;
1559 AABox aaBox(low, dimensions);
1560 return aaBox.findCapsulePenetration(start, end, radius, penetration);
1561}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t