History

merge with master

SamGondelman committed 8 years ago

Commit 2ca217e2 parents 3b5a0d2 1b47d3f305 files · +7800 −5863Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+26−76
@@ -871,6 +871,30 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke · 870 unmodified lines
871 return result;871 return result;
872}872}
873 873
874ParabolaToEntityIntersectionResult EntityScriptingInterface::findParabolaIntersectionVector(const PickParabola& parabola, bool precisionPicking,
875 const QVector<EntityItemID>& entityIdsToInclude, const QVector<EntityItemID>& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) {
876 PROFILE_RANGE(script_entities, __FUNCTION__);
877
878 return findParabolaIntersectionWorker(parabola, Octree::Lock, precisionPicking, entityIdsToInclude, entityIdsToDiscard, visibleOnly, collidableOnly);
879}
880
881ParabolaToEntityIntersectionResult EntityScriptingInterface::findParabolaIntersectionWorker(const PickParabola& parabola,
882 Octree::lockType lockType, bool precisionPicking, const QVector<EntityItemID>& entityIdsToInclude,
883 const QVector<EntityItemID>& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) {
884
885
886 ParabolaToEntityIntersectionResult result;
887 if (_entityTree) {
888 OctreeElementPointer element;
889 result.entityID = _entityTree->findParabolaIntersection(parabola,
890 entityIdsToInclude, entityIdsToDiscard, visibleOnly, collidableOnly, precisionPicking,
891 element, result.intersection, result.distance, result.parabolicDistance, result.face, result.surfaceNormal,
892 result.extraInfo, lockType, &result.accurate);
893 result.intersects = !result.entityID.isNull();
894 }
895 return result;
896}
897
874bool EntityScriptingInterface::reloadServerScripts(QUuid entityID) {898bool EntityScriptingInterface::reloadServerScripts(QUuid entityID) {
875 auto client = DependencyManager::get<EntityScriptClient>();899 auto client = DependencyManager::get<EntityScriptClient>();
876 return client->reloadServerScript(entityID);900 return client->reloadServerScript(entityID);
@@ -1025,75 +1049,17 @@ bool EntityScriptingInterface::getDrawZoneBoundaries() const { · 148 unmodified lines
1025 return ZoneEntityItem::getDrawZoneBoundaries();1049 return ZoneEntityItem::getDrawZoneBoundaries();
1026}1050}
1027 1051
1028RayToEntityIntersectionResult::RayToEntityIntersectionResult() :
1029 intersects(false),
1030 accurate(true), // assume it's accurate
1031 entityID(),
1032 distance(0),
1033 face()
1034{
1035}
1036
1037QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {1052QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {
1038 PROFILE_RANGE(script_entities, __FUNCTION__);
1039
1040 QScriptValue obj = engine->newObject();1053 QScriptValue obj = engine->newObject();
1041 obj.setProperty("intersects", value.intersects);1054 obj.setProperty("intersects", value.intersects);
1042 obj.setProperty("accurate", value.accurate);1055 obj.setProperty("accurate", value.accurate);
1043 QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);1056 QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
1044 obj.setProperty("entityID", entityItemValue);1057 obj.setProperty("entityID", entityItemValue);
1045
1046 obj.setProperty("distance", value.distance);1058 obj.setProperty("distance", value.distance);
1047 1059 obj.setProperty("face", boxFaceToString(value.face));
1048 QString faceName = "";
1049 // handle BoxFace
1050 /**jsdoc
1051 * <p>A <code>BoxFace</code> specifies the face of an axis-aligned (AA) box.
1052 * <table>
1053 * <thead>
1054 * <tr><th>Value</th><th>Description</th></tr>
1055 * </thead>
1056 * <tbody>
1057 * <tr><td><code>"MIN_X_FACE"</code></td><td>The minimum x-axis face.</td></tr>
1058 * <tr><td><code>"MAX_X_FACE"</code></td><td>The maximum x-axis face.</td></tr>
1059 * <tr><td><code>"MIN_Y_FACE"</code></td><td>The minimum y-axis face.</td></tr>
1060 * <tr><td><code>"MAX_Y_FACE"</code></td><td>The maximum y-axis face.</td></tr>
1061 * <tr><td><code>"MIN_Z_FACE"</code></td><td>The minimum z-axis face.</td></tr>
1062 * <tr><td><code>"MAX_Z_FACE"</code></td><td>The maximum z-axis face.</td></tr>
1063 * <tr><td><code>"UNKNOWN_FACE"</code></td><td>Unknown value.</td></tr>
1064 * </tbody>
1065 * </table>
1066 * @typedef {string} BoxFace
1067 */
1068 // FIXME: Move enum to string function to BoxBase.cpp.
1069 switch (value.face) {
1070 case MIN_X_FACE:
1071 faceName = "MIN_X_FACE";
1072 break;
1073 case MAX_X_FACE:
1074 faceName = "MAX_X_FACE";
1075 break;
1076 case MIN_Y_FACE:
1077 faceName = "MIN_Y_FACE";
1078 break;
1079 case MAX_Y_FACE:
1080 faceName = "MAX_Y_FACE";
1081 break;
1082 case MIN_Z_FACE:
1083 faceName = "MIN_Z_FACE";
1084 break;
1085 case MAX_Z_FACE:
1086 faceName = "MAX_Z_FACE";
1087 break;
1088 case UNKNOWN_FACE:
1089 faceName = "UNKNOWN_FACE";
1090 break;
1091 }
1092 obj.setProperty("face", faceName);
1093 1060
1094 QScriptValue intersection = vec3ToScriptValue(engine, value.intersection);1061 QScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
1095 obj.setProperty("intersection", intersection);1062 obj.setProperty("intersection", intersection);
1096
1097 QScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);1063 QScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
1098 obj.setProperty("surfaceNormal", surfaceNormal);1064 obj.setProperty("surfaceNormal", surfaceNormal);
1099 obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));1065 obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
@@ -1101,29 +1067,13 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 1 unmodified line
1101}1067}
1102 1068
1103void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {1069void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
1104 PROFILE_RANGE(script_entities, __FUNCTION__);
1105
1106 value.intersects = object.property("intersects").toVariant().toBool();1070 value.intersects = object.property("intersects").toVariant().toBool();
1107 value.accurate = object.property("accurate").toVariant().toBool();1071 value.accurate = object.property("accurate").toVariant().toBool();
1108 QScriptValue entityIDValue = object.property("entityID");1072 QScriptValue entityIDValue = object.property("entityID");
1109 // EntityItemIDfromScriptValue(entityIDValue, value.entityID);
1110 quuidFromScriptValue(entityIDValue, value.entityID);1073 quuidFromScriptValue(entityIDValue, value.entityID);
1111 value.distance = object.property("distance").toVariant().toFloat();1074 value.distance = object.property("distance").toVariant().toFloat();
1075 value.face = boxFaceFromString(object.property("face").toVariant().toString());
1112 1076
1113 QString faceName = object.property("face").toVariant().toString();
1114 if (faceName == "MIN_X_FACE") {
1115 value.face = MIN_X_FACE;
1116 } else if (faceName == "MAX_X_FACE") {
1117 value.face = MAX_X_FACE;
1118 } else if (faceName == "MIN_Y_FACE") {
1119 value.face = MIN_Y_FACE;
1120 } else if (faceName == "MAX_Y_FACE") {
1121 value.face = MAX_Y_FACE;
1122 } else if (faceName == "MIN_Z_FACE") {
1123 value.face = MIN_Z_FACE;
1124 } else {
1125 value.face = MAX_Z_FACE;
1126 };
1127 QScriptValue intersection = object.property("intersection");1077 QScriptValue intersection = object.property("intersection");
1128 if (intersection.isValid()) {1078 if (intersection.isValid()) {
1129 vec3FromScriptValue(intersection, value.intersection);1079 vec3FromScriptValue(intersection, value.intersection);