Merge branch 'master' of https://github.com/highfidelity/hifi into 20061

This commit is contained in:
stojce 2014-10-03 14:03:13 +02:00
commit be5f348e22
14 changed files with 133 additions and 56 deletions

View file

@ -302,7 +302,7 @@ void OctreeServer::initHTTPManager(int port) {
_httpManager = new HTTPManager(port, documentRoot, this, this); _httpManager = new HTTPManager(port, documentRoot, this, this);
} }
bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) { bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
#ifdef FORCE_CRASH #ifdef FORCE_CRASH
if (connection->requestOperation() == QNetworkAccessManager::GetOperation if (connection->requestOperation() == QNetworkAccessManager::GetOperation

View file

@ -115,7 +115,7 @@ public:
static int howManyThreadsDidHandlePacketSend(quint64 since = 0); static int howManyThreadsDidHandlePacketSend(quint64 since = 0);
static int howManyThreadsDidCallWriteDatagram(quint64 since = 0); static int howManyThreadsDidCallWriteDatagram(quint64 since = 0);
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url); bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler);
virtual void aboutToFinish(); virtual void aboutToFinish();
void forceNodeShutdown(SharedNodePointer node); void forceNodeShutdown(SharedNodePointer node);

View file

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View file

@ -33,9 +33,24 @@ var viewHelpers = {
input_type = _.has(setting, 'type') ? setting.type : "text" input_type = _.has(setting, 'type') ? setting.type : "text"
form_group += "<label for='" + setting_name + "' class='" + label_class + "'>" + setting.label + "</label>"; form_group += "<label for='" + setting_name + "' class='" + label_class + "'>" + setting.label + "</label>";
form_group += "<input type='" + input_type + "' class='form-control' name='" + setting_name +
"' placeholder='" + (_.has(setting, 'placeholder') ? setting.placeholder : "") + if (setting.type === 'select') {
"' value='" + setting_value + "'" + (isLocked ? " disabled" : "") + "/>" form_group += "<select class='form-control' data-hidden-input='" + setting_name + "'>'"
_.each(setting.options, function(option) {
form_group += "<option value='" + option.value + "'" +
(option.value == setting_value ? 'selected' : '') + ">" + option.label + "</option>"
})
form_group += "</select>"
form_group += "<input type='hidden' name='" + setting_name + "' value='" + setting_value + "'>"
} else {
form_group += "<input type='" + input_type + "' class='form-control' name='" + setting_name +
"' placeholder='" + (_.has(setting, 'placeholder') ? setting.placeholder : "") +
"' value='" + setting_value + "'" + (isLocked ? " disabled" : "") + "/>"
}
form_group += "<span class='help-block'>" + setting.help + "</span>" form_group += "<span class='help-block'>" + setting.help + "</span>"
} }
@ -90,6 +105,11 @@ $(document).ready(function(){
$('#settings-form').on('click', '#choose-domain-btn', function(){ $('#settings-form').on('click', '#choose-domain-btn', function(){
chooseFromHighFidelityDomains($(this)) chooseFromHighFidelityDomains($(this))
}) })
$('#settings-form').on('change', 'select', function(){
console.log("Changed" + $(this))
$("input[name='" + $(this).attr('data-hidden-input') + "']").val($(this).val()).change()
})
var panelsSource = $('#panels-template').html() var panelsSource = $('#panels-template').html()
Settings.panelsTemplate = _.template(panelsSource) Settings.panelsTemplate = _.template(panelsSource)

View file

@ -1047,16 +1047,17 @@ const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment";
QString pathForAssignmentScript(const QUuid& assignmentUUID) { QString pathForAssignmentScript(const QUuid& assignmentUUID) {
QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION); QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION);
newPath += "/"; newPath += "/scripts/";
// append the UUID for this script as the new filename, remove the curly braces // append the UUID for this script as the new filename, remove the curly braces
newPath += uuidStringWithoutCurlyBraces(assignmentUUID); newPath += uuidStringWithoutCurlyBraces(assignmentUUID);
return newPath; return newPath;
} }
bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) { bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
const QString JSON_MIME_TYPE = "application/json"; const QString JSON_MIME_TYPE = "application/json";
const QString URI_ASSIGNMENT = "/assignment"; const QString URI_ASSIGNMENT = "/assignment";
const QString URI_ASSIGNMENT_SCRIPTS = URI_ASSIGNMENT + "/scripts";
const QString URI_NODES = "/nodes"; const QString URI_NODES = "/nodes";
const QString UUID_REGEX_STRING = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; const QString UUID_REGEX_STRING = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
@ -1067,7 +1068,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
} }
// check if this is a request for a scripted assignment (with a temp unique UUID) // check if this is a request for a scripted assignment (with a temp unique UUID)
const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING); const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING);
QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING); QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING);
if (connection->requestOperation() == QNetworkAccessManager::GetOperation if (connection->requestOperation() == QNetworkAccessManager::GetOperation
@ -1086,11 +1087,11 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
// via correct URL for the script so the client can download // via correct URL for the script so the client can download
QUrl scriptURL = url; QUrl scriptURL = url;
scriptURL.setPath(URI_ASSIGNMENT + "/" scriptURL.setPath(URI_ASSIGNMENT + "/scripts/"
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID())); + uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
// have the HTTPManager serve the appropriate script file // have the HTTPManager serve the appropriate script file
return _httpManager.handleHTTPRequest(connection, scriptURL); return _httpManager.handleHTTPRequest(connection, scriptURL, true);
} }
} }
} }
@ -1261,16 +1262,21 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
// create a file with the GUID of the assignment in the script host location // create a file with the GUID of the assignment in the script host location
QFile scriptFile(newPath); QFile scriptFile(newPath);
scriptFile.open(QIODevice::WriteOnly); if (scriptFile.open(QIODevice::WriteOnly)) {
scriptFile.write(formData[0].second); scriptFile.write(formData[0].second);
qDebug() << qPrintable(QString("Saved a script for assignment at %1%2") qDebug() << qPrintable(QString("Saved a script for assignment at %1%2")
.arg(newPath).arg(assignmentPool == emptyPool ? "" : " - pool is " + assignmentPool)); .arg(newPath).arg(assignmentPool == emptyPool ? "" : " - pool is " + assignmentPool));
// add the script assigment to the assignment queue // add the script assigment to the assignment queue
SharedAssignmentPointer sharedScriptedAssignment(scriptAssignment); SharedAssignmentPointer sharedScriptedAssignment(scriptAssignment);
_unfulfilledAssignments.enqueue(sharedScriptedAssignment); _unfulfilledAssignments.enqueue(sharedScriptedAssignment);
_allAssignments.insert(sharedScriptedAssignment->getUUID(), sharedScriptedAssignment); _allAssignments.insert(sharedScriptedAssignment->getUUID(), sharedScriptedAssignment);
} else {
// unable to save script for assignment - we shouldn't be here but debug it out
qDebug() << "Unable to save a script for assignment at" << newPath;
qDebug() << "Script will not be added to queue";
}
} }
// respond with a 200 code for successful upload // respond with a 200 code for successful upload
@ -1319,7 +1325,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
const QString HIFI_SESSION_COOKIE_KEY = "DS_WEB_SESSION_UUID"; const QString HIFI_SESSION_COOKIE_KEY = "DS_WEB_SESSION_UUID";
bool DomainServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl &url) { bool DomainServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl &url, bool skipSubHandler) {
const QString URI_OAUTH = "/oauth"; const QString URI_OAUTH = "/oauth";
qDebug() << "HTTPS request received at" << url.toString(); qDebug() << "HTTPS request received at" << url.toString();
if (url.path() == URI_OAUTH) { if (url.path() == URI_OAUTH) {

View file

@ -43,8 +43,8 @@ public:
static int const EXIT_CODE_REBOOT; static int const EXIT_CODE_REBOOT;
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url); bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url); bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false);
public slots: public slots:
/// Called by NodeList to inform us a node has been added /// Called by NodeList to inform us a node has been added

View file

@ -2395,7 +2395,7 @@ function Tooltip() {
this.x = 285; this.x = 285;
this.y = 115; this.y = 115;
this.width = 500; this.width = 500;
this.height = 180; // 145; this.height = 300; // 145;
this.margin = 5; this.margin = 5;
this.decimals = 3; this.decimals = 3;
@ -2406,8 +2406,8 @@ function Tooltip() {
height: this.height, height: this.height,
margin: this.margin, margin: this.margin,
text: "", text: "",
color: { red: 128, green: 128, blue: 128 }, color: { red: 228, green: 228, blue: 228 },
alpha: 0.2, alpha: 0.5,
visible: false visible: false
}); });
this.show = function (doShow) { this.show = function (doShow) {

View file

@ -14,6 +14,7 @@
var leapHands = (function () { var leapHands = (function () {
var isOnHMD, var isOnHMD,
LEAP_ON_HMD_MENU_ITEM = "Leap Motion on HMD",
LEAP_OFFSET = 0.019, // Thickness of Leap Motion plus HMD clip LEAP_OFFSET = 0.019, // Thickness of Leap Motion plus HMD clip
HMD_OFFSET = 0.100, // Eyeballs to front surface of Oculus DK2 TODO: Confirm and make depend on device and eye relief HMD_OFFSET = 0.100, // Eyeballs to front surface of Oculus DK2 TODO: Confirm and make depend on device and eye relief
hands, hands,
@ -30,7 +31,11 @@ var leapHands = (function () {
CALIBRATED = 2, CALIBRATED = 2,
CALIBRATION_TIME = 1000, // milliseconds CALIBRATION_TIME = 1000, // milliseconds
PI = 3.141593, PI = 3.141593,
isWindows; isWindows,
avatarScale,
avatarFaceModelURL,
avatarSkeletonModelURL,
settingsTimer;
function printSkeletonJointNames() { function printSkeletonJointNames() {
var jointNames, var jointNames,
@ -164,6 +169,10 @@ var leapHands = (function () {
calibrationStatus = CALIBRATING; calibrationStatus = CALIBRATING;
avatarScale = MyAvatar.scale;
avatarFaceModelURL = MyAvatar.faceModelURL;
avatarSkeletonModelURL = MyAvatar.skeletonModelURL;
// Set avatar arms vertical, forearms horizontal, as "zero" position for calibration // Set avatar arms vertical, forearms horizontal, as "zero" position for calibration
MyAvatar.setJointData("LeftArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, -90.0)); MyAvatar.setJointData("LeftArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, -90.0));
MyAvatar.setJointData("LeftForeArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, 180.0)); MyAvatar.setJointData("LeftForeArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, 180.0));
@ -189,6 +198,37 @@ var leapHands = (function () {
return false; return false;
} }
function setIsOnHMD() {
isOnHMD = Menu.isOptionChecked(LEAP_ON_HMD_MENU_ITEM);
if (isOnHMD) {
print("Leap Motion: Is on HMD");
// Offset of Leap Motion origin from physical eye position
hands[0].zeroPosition = { x: 0.0, y: 0.0, z: HMD_OFFSET + LEAP_OFFSET };
hands[1].zeroPosition = { x: 0.0, y: 0.0, z: HMD_OFFSET + LEAP_OFFSET };
calibrationStatus = CALIBRATED;
} else {
print("Leap Motion: Is on desk");
calibrationStatus = UNCALIBRATED;
}
}
function checkSettings() {
// There is no "scale changed" event so we need check periodically.
if (!isOnHMD && calibrationStatus > UNCALIBRATED && (MyAvatar.scale !== avatarScale
|| MyAvatar.faceModelURL !== avatarFaceModelURL
|| MyAvatar.skeletonModelURL !== avatarSkeletonModelURL)) {
print("Leap Motion: Recalibrate because avatar body or scale changed");
calibrationStatus = UNCALIBRATED;
}
// There is a "menu changed" event but we may as well check here.
if (isOnHMD !== Menu.isOptionChecked(LEAP_ON_HMD_MENU_ITEM)) {
setIsOnHMD();
}
}
function setUp() { function setUp() {
// TODO: Leap Motion controller joint naming doesn't match up with skeleton joint naming; numbers are out by 1. // TODO: Leap Motion controller joint naming doesn't match up with skeleton joint naming; numbers are out by 1.
@ -267,19 +307,9 @@ var leapHands = (function () {
] ]
]; ];
isOnHMD = Menu.isOptionChecked("Leap Motion on HMD"); setIsOnHMD();
if (isOnHMD) {
print("Leap Motion is on HMD");
// Offset of Leap Motion origin from physical eye position settingsTimer = Script.setInterval(checkSettings, 2000);
hands[0].zeroPosition = { x: 0.0, y: 0.0, z: HMD_OFFSET + LEAP_OFFSET };
hands[1].zeroPosition = { x: 0.0, y: 0.0, z: HMD_OFFSET + LEAP_OFFSET };
calibrationStatus = CALIBRATED;
} else {
print("Leap Motion is on desk");
calibrationStatus = UNCALIBRATED;
}
} }
function moveHands() { function moveHands() {
@ -302,7 +332,7 @@ var leapHands = (function () {
if (hands[h].controller.isActive()) { if (hands[h].controller.isActive()) {
// Calibrate when and if a controller is first active. // Calibrate if necessary.
if (!checkCalibration()) { if (!checkCalibration()) {
return; return;
} }
@ -430,6 +460,8 @@ var leapHands = (function () {
i, i,
j; j;
Script.clearInterval(settingsTimer);
for (h = 0; h < NUM_HANDS; h += 1) { for (h = 0; h < NUM_HANDS; h += 1) {
Controller.releaseInputController(hands[h].controller); Controller.releaseInputController(hands[h].controller);
Controller.releaseInputController(wrists[h].controller); Controller.releaseInputController(wrists[h].controller);

View file

@ -139,6 +139,8 @@ foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
if (NOT APPLE OR NOT ${${EXTERNAL}_UPPERCASE} MATCHES "SIXENSE") if (NOT APPLE OR NOT ${${EXTERNAL}_UPPERCASE} MATCHES "SIXENSE")
target_link_libraries(${TARGET_NAME} ${${${EXTERNAL}_UPPERCASE}_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${${${EXTERNAL}_UPPERCASE}_LIBRARIES})
elseif (APPLE AND NOT INSTALLER_BUILD)
add_definitions(-DSIXENSE_LIB_FILENAME=\"${${${EXTERNAL}_UPPERCASE}_LIBRARY_RELEASE}\")
endif () endif ()
endif () endif ()
endforeach() endforeach()

View file

@ -96,15 +96,28 @@ void SixenseManager::initialize() {
#ifdef __APPLE__ #ifdef __APPLE__
if (!_sixenseLibrary) { if (!_sixenseLibrary) {
const QString SIXENSE_LIBRARY_NAME = "libsixense_x64.dylib";
_sixenseLibrary = new QLibrary(SIXENSE_LIBRARY_NAME); #ifdef SIXENSE_LIB_FILENAME
_sixenseLibrary = new QLibrary(SIXENSE_LIB_FILENAME);
#else
const QString SIXENSE_LIBRARY_NAME = "libsixense_x64";
QString frameworkSixenseLibrary = QCoreApplication::applicationDirPath() + "../Frameworks/"
+ SIXENSE_LIBRARY_NAME;
_sixenseLibrary = new QLibrary(frameworkSixenseLibrary);
#endif
}
if (_sixenseLibrary->load()){
qDebug() << "Loaded sixense library for hydra support -" << _sixenseLibrary->fileName();
} else {
qDebug() << "Sixense library at" << _sixenseLibrary->fileName() << "failed to load."
<< "Continuing without hydra support.";
return;
} }
qDebug() << "Initializing sixense library for hydra support - libsixense_x64.dylib load state is"
<< _sixenseLibrary->isLoaded();
SixenseBaseFunction sixenseInit = (SixenseBaseFunction) _sixenseLibrary->resolve("sixenseInit"); SixenseBaseFunction sixenseInit = (SixenseBaseFunction) _sixenseLibrary->resolve("sixenseInit");
#endif #endif
sixenseInit(); sixenseInit();
_isInitialized = true; _isInitialized = true;

View file

@ -40,8 +40,8 @@ void HTTPManager::incomingConnection(qintptr socketDescriptor) {
} }
} }
bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) { bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
if (requestHandledByRequestHandler(connection, url)) { if (!skipSubHandler && requestHandledByRequestHandler(connection, url)) {
// this request was handled by our request handler object // this request was handled by our request handler object
// so we don't need to attempt to do so in the document root // so we don't need to attempt to do so in the document root
return true; return true;

View file

@ -24,7 +24,7 @@ class HTTPSConnection;
class HTTPRequestHandler { class HTTPRequestHandler {
public: public:
/// Handles an HTTP request. /// Handles an HTTP request.
virtual bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url) = 0; virtual bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) = 0;
}; };
/// Handles HTTP connections /// Handles HTTP connections
@ -34,7 +34,7 @@ public:
/// Initializes the manager. /// Initializes the manager.
HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0); HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0);
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url); bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
protected: protected:
/// Accepts all pending connections /// Accepts all pending connections

View file

@ -38,12 +38,12 @@ void HTTPSManager::incomingConnection(qintptr socketDescriptor) {
} }
} }
bool HTTPSManager::handleHTTPRequest(HTTPConnection* connection, const QUrl &url) { bool HTTPSManager::handleHTTPRequest(HTTPConnection* connection, const QUrl &url, bool skipSubHandler) {
return handleHTTPSRequest(reinterpret_cast<HTTPSConnection*>(connection), url); return handleHTTPSRequest(reinterpret_cast<HTTPSConnection*>(connection), url, skipSubHandler);
} }
bool HTTPSManager::handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url) { bool HTTPSManager::handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler) {
return HTTPManager::handleHTTPRequest(connection, url); return HTTPManager::handleHTTPRequest(connection, url, skipSubHandler);
} }
bool HTTPSManager::requestHandledByRequestHandler(HTTPConnection* connection, const QUrl& url) { bool HTTPSManager::requestHandledByRequestHandler(HTTPConnection* connection, const QUrl& url) {

View file

@ -20,7 +20,7 @@
class HTTPSRequestHandler : public HTTPRequestHandler { class HTTPSRequestHandler : public HTTPRequestHandler {
public: public:
/// Handles an HTTPS request /// Handles an HTTPS request
virtual bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url) = 0; virtual bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) = 0;
}; };
class HTTPSManager : public HTTPManager, public HTTPSRequestHandler { class HTTPSManager : public HTTPManager, public HTTPSRequestHandler {
@ -35,8 +35,8 @@ public:
void setCertificate(const QSslCertificate& certificate) { _certificate = certificate; } void setCertificate(const QSslCertificate& certificate) { _certificate = certificate; }
void setPrivateKey(const QSslKey& privateKey) { _privateKey = privateKey; } void setPrivateKey(const QSslKey& privateKey) { _privateKey = privateKey; }
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url); bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url); bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false);
protected: protected:
void incomingConnection(qintptr socketDescriptor); void incomingConnection(qintptr socketDescriptor);