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
871871 return result;
872872 }
873873
874+ParabolaToEntityIntersectionResult 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+
881+ParabolaToEntityIntersectionResult 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+
874898 bool EntityScriptingInterface::reloadServerScripts(QUuid entityID) {
875899 auto client = DependencyManager::get<EntityScriptClient>();
876900 return client->reloadServerScript(entityID);
@@ -1025,75 +1049,17 @@ bool EntityScriptingInterface::getDrawZoneBoundaries() const { · 148 unmodified lines
10251049 return ZoneEntityItem::getDrawZoneBoundaries();
10261050 }
10271051
1028−RayToEntityIntersectionResult::RayToEntityIntersectionResult() :
1029− intersects(false),
1030− accurate(true), // assume it's accurate
1031− entityID(),
1032− distance(0),
1033− face()
1034−{
1035−}
1036−
10371052 QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, const RayToEntityIntersectionResult& value) {
1038− PROFILE_RANGE(script_entities, __FUNCTION__);
1039−
10401053 QScriptValue obj = engine->newObject();
10411054 obj.setProperty("intersects", value.intersects);
10421055 obj.setProperty("accurate", value.accurate);
10431056 QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
10441057 obj.setProperty("entityID", entityItemValue);
1045−
10461058 obj.setProperty("distance", value.distance);
1047−
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);
1059+ obj.setProperty("face", boxFaceToString(value.face));
10931060
10941061 QScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
10951062 obj.setProperty("intersection", intersection);
1096−
10971063 QScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
10981064 obj.setProperty("surfaceNormal", surfaceNormal);
10991065 obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
@@ -1101,29 +1067,13 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c · 1 unmodified line
11011067 }
11021068
11031069 void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
1104− PROFILE_RANGE(script_entities, __FUNCTION__);
1105−
11061070 value.intersects = object.property("intersects").toVariant().toBool();
11071071 value.accurate = object.property("accurate").toVariant().toBool();
11081072 QScriptValue entityIDValue = object.property("entityID");
1109− // EntityItemIDfromScriptValue(entityIDValue, value.entityID);
11101073 quuidFromScriptValue(entityIDValue, value.entityID);
11111074 value.distance = object.property("distance").toVariant().toFloat();
1075+ value.face = boxFaceFromString(object.property("face").toVariant().toString());
11121076
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− };
11271077 QScriptValue intersection = object.property("intersection");
11281078 if (intersection.isValid()) {
11291079 vec3FromScriptValue(intersection, value.intersection);