mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels
This commit is contained in:
commit
e32c214e4d
13 changed files with 82 additions and 52 deletions
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
int const DomainServer::EXIT_CODE_REBOOT = 234923;
|
int const DomainServer::EXIT_CODE_REBOOT = 234923;
|
||||||
|
|
||||||
|
const QString ICE_SERVER_DEFAULT_HOSTNAME = "ice.highfidelity.io";
|
||||||
|
|
||||||
DomainServer::DomainServer(int argc, char* argv[]) :
|
DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
_shutdownEventListener(this),
|
_shutdownEventListener(this),
|
||||||
|
@ -52,7 +54,8 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
_webAuthenticationStateSet(),
|
_webAuthenticationStateSet(),
|
||||||
_cookieSessionHash(),
|
_cookieSessionHash(),
|
||||||
_automaticNetworkingSetting(),
|
_automaticNetworkingSetting(),
|
||||||
_settingsManager()
|
_settingsManager(),
|
||||||
|
_iceServerSocket(ICE_SERVER_DEFAULT_HOSTNAME, ICE_SERVER_DEFAULT_PORT)
|
||||||
{
|
{
|
||||||
LogUtils::init();
|
LogUtils::init();
|
||||||
|
|
||||||
|
@ -346,6 +349,9 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
QTimer* dynamicIPTimer = new QTimer(this);
|
QTimer* dynamicIPTimer = new QTimer(this);
|
||||||
connect(dynamicIPTimer, &QTimer::timeout, this, &DomainServer::requestCurrentPublicSocketViaSTUN);
|
connect(dynamicIPTimer, &QTimer::timeout, this, &DomainServer::requestCurrentPublicSocketViaSTUN);
|
||||||
|
|
||||||
|
_automaticNetworkingSetting =
|
||||||
|
_settingsManager.valueOrDefaultValueForKeyPath(METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH).toString();
|
||||||
|
|
||||||
if (_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) {
|
if (_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) {
|
||||||
dynamicIPTimer->start(STUN_REFLEXIVE_KEEPALIVE_INTERVAL_MSECS);
|
dynamicIPTimer->start(STUN_REFLEXIVE_KEEPALIVE_INTERVAL_MSECS);
|
||||||
|
|
||||||
|
@ -354,9 +360,17 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
connect(iceHeartbeatTimer, &QTimer::timeout, this, &DomainServer::performICEUpdates);
|
connect(iceHeartbeatTimer, &QTimer::timeout, this, &DomainServer::performICEUpdates);
|
||||||
iceHeartbeatTimer->start(ICE_HEARBEAT_INTERVAL_MSECS);
|
iceHeartbeatTimer->start(ICE_HEARBEAT_INTERVAL_MSECS);
|
||||||
|
|
||||||
// call our sendHeartbeaToIceServer immediately anytime a local or public socket changes
|
// call our sendHeartbeatToIceServer immediately anytime a local or public socket changes
|
||||||
connect(nodeList, &LimitedNodeList::localSockAddrChanged, this, &DomainServer::sendHeartbeatToIceServer);
|
connect(nodeList, &LimitedNodeList::localSockAddrChanged, this, &DomainServer::sendHeartbeatToIceServer);
|
||||||
connect(nodeList, &LimitedNodeList::publicSockAddrChanged, this, &DomainServer::sendHeartbeatToIceServer);
|
connect(nodeList, &LimitedNodeList::publicSockAddrChanged, this, &DomainServer::sendHeartbeatToIceServer);
|
||||||
|
|
||||||
|
// attempt to update our public socket now, this will send a heartbeat once we get public socket
|
||||||
|
requestCurrentPublicSocketViaSTUN();
|
||||||
|
|
||||||
|
// in case the STUN lookup is still happening we should re-request a public socket once we get that address
|
||||||
|
connect(&nodeList->getSTUNSockAddr(), &HifiSockAddr::lookupCompleted,
|
||||||
|
this, &DomainServer::requestCurrentPublicSocketViaSTUN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didSetupAccountManagerWithAccessToken()) {
|
if (!didSetupAccountManagerWithAccessToken()) {
|
||||||
|
@ -366,9 +380,6 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_automaticNetworkingSetting =
|
|
||||||
_settingsManager.valueOrDefaultValueForKeyPath(METAVERSE_AUTOMATIC_NETWORKING_KEY_PATH).toString();
|
|
||||||
|
|
||||||
if (_automaticNetworkingSetting == IP_ONLY_AUTOMATIC_NETWORKING_VALUE ||
|
if (_automaticNetworkingSetting == IP_ONLY_AUTOMATIC_NETWORKING_VALUE ||
|
||||||
_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) {
|
_automaticNetworkingSetting == FULL_AUTOMATIC_NETWORKING_VALUE) {
|
||||||
|
|
||||||
|
@ -383,14 +394,13 @@ void DomainServer::setupAutomaticNetworking() {
|
||||||
|
|
||||||
// send public socket changes to the data server so nodes can find us at our new IP
|
// send public socket changes to the data server so nodes can find us at our new IP
|
||||||
connect(nodeList, &LimitedNodeList::publicSockAddrChanged, this, &DomainServer::performIPAddressUpdate);
|
connect(nodeList, &LimitedNodeList::publicSockAddrChanged, this, &DomainServer::performIPAddressUpdate);
|
||||||
|
|
||||||
|
// attempt to update our sockets now
|
||||||
|
requestCurrentPublicSocketViaSTUN();
|
||||||
} else {
|
} else {
|
||||||
// send our heartbeat to data server so it knows what our network settings are
|
// send our heartbeat to data server so it knows what our network settings are
|
||||||
sendHeartbeatToDataServer();
|
sendHeartbeatToDataServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to update our sockets now
|
|
||||||
requestCurrentPublicSocketViaSTUN();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Cannot enable domain-server automatic networking without a domain ID."
|
qDebug() << "Cannot enable domain-server automatic networking without a domain ID."
|
||||||
<< "Please add an ID to your config file or via the web interface.";
|
<< "Please add an ID to your config file or via the web interface.";
|
||||||
|
@ -1167,8 +1177,7 @@ void DomainServer::performICEUpdates() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::sendHeartbeatToIceServer() {
|
void DomainServer::sendHeartbeatToIceServer() {
|
||||||
static HifiSockAddr ICE_SERVER_SOCK_ADDR = HifiSockAddr("ice.highfidelity.io", ICE_SERVER_DEFAULT_PORT);
|
LimitedNodeList::getInstance()->sendHeartbeatToIceServer(_iceServerSocket);
|
||||||
LimitedNodeList::getInstance()->sendHeartbeatToIceServer(ICE_SERVER_SOCK_ADDR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::sendICEPingPackets() {
|
void DomainServer::sendICEPingPackets() {
|
||||||
|
|
|
@ -154,6 +154,8 @@ private:
|
||||||
QString _automaticNetworkingSetting;
|
QString _automaticNetworkingSetting;
|
||||||
|
|
||||||
DomainServerSettingsManager _settingsManager;
|
DomainServerSettingsManager _settingsManager;
|
||||||
|
|
||||||
|
HifiSockAddr _iceServerSocket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ var BUTTON_TURN_AROUND = Joysticks.BUTTON_RIGHT_STICK;
|
||||||
|
|
||||||
var BUTTON_FLY_UP = Joysticks.BUTTON_RIGHT_SHOULDER;
|
var BUTTON_FLY_UP = Joysticks.BUTTON_RIGHT_SHOULDER;
|
||||||
var BUTTON_FLY_DOWN = Joysticks.BUTTON_LEFT_SHOULDER;
|
var BUTTON_FLY_DOWN = Joysticks.BUTTON_LEFT_SHOULDER;
|
||||||
var BUTTON_WARP = Joysticks.BUTTON_FACE_BOTTOM;
|
var BUTTON_WARP = Joysticks.BUTTON_FACE_RIGHT;
|
||||||
|
|
||||||
var BUTTON_WARP_FORWARD = Joysticks.BUTTON_DPAD_UP;
|
var BUTTON_WARP_FORWARD = Joysticks.BUTTON_DPAD_UP;
|
||||||
var BUTTON_WARP_BACKWARD = Joysticks.BUTTON_DPAD_DOWN;
|
var BUTTON_WARP_BACKWARD = Joysticks.BUTTON_DPAD_DOWN;
|
||||||
|
|
|
@ -4042,20 +4042,20 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
||||||
return scriptEngine;
|
return scriptEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::handleScriptEngineLoaded(const QUrl& scriptURL) {
|
void Application::handleScriptEngineLoaded(const QString& scriptFilename) {
|
||||||
ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender());
|
ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender());
|
||||||
|
|
||||||
_scriptEnginesHash.insertMulti(scriptURL.toString(), scriptEngine);
|
_scriptEnginesHash.insertMulti(scriptFilename, scriptEngine);
|
||||||
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
||||||
UserActivityLogger::getInstance().loadedScript(scriptURL.toString());
|
UserActivityLogger::getInstance().loadedScript(scriptFilename);
|
||||||
|
|
||||||
// register our application services and set it off on its own thread
|
// register our application services and set it off on its own thread
|
||||||
registerScriptEngineWithApplicationServices(scriptEngine);
|
registerScriptEngineWithApplicationServices(scriptEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::handleScriptLoadError(const QUrl& scriptURL) {
|
void Application::handleScriptLoadError(const QString& scriptFilename) {
|
||||||
qDebug() << "Application::loadScript(), script failed to load...";
|
qDebug() << "Application::loadScript(), script failed to load...";
|
||||||
QMessageBox::warning(getWindow(), "Error Loading Script", scriptURL.toString() + " failed to load.");
|
QMessageBox::warning(getWindow(), "Error Loading Script", scriptFilename + " failed to load.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::scriptFinished(const QString& scriptName) {
|
void Application::scriptFinished(const QString& scriptName) {
|
||||||
|
|
|
@ -394,8 +394,8 @@ private slots:
|
||||||
void idle();
|
void idle();
|
||||||
void aboutToQuit();
|
void aboutToQuit();
|
||||||
|
|
||||||
void handleScriptEngineLoaded(const QUrl& scriptURL);
|
void handleScriptEngineLoaded(const QString& scriptFilename);
|
||||||
void handleScriptLoadError(const QUrl& scriptURL);
|
void handleScriptLoadError(const QString& scriptFilename);
|
||||||
|
|
||||||
void connectedToDomain(const QString& hostname);
|
void connectedToDomain(const QString& hostname);
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
const float HAIR_DAMPING = 0.99f;
|
const float HAIR_DAMPING = 0.99f;
|
||||||
const float CONSTRAINT_RELAXATION = 10.0f;
|
const float CONSTRAINT_RELAXATION = 10.0f;
|
||||||
const float HAIR_ACCELERATION_COUPLING = 0.045f;
|
const float HAIR_ACCELERATION_COUPLING = 0.045f;
|
||||||
const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.020f;
|
const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.001f;
|
||||||
const float HAIR_ANGULAR_ACCELERATION_COUPLING = 0.003f;
|
const float HAIR_ANGULAR_ACCELERATION_COUPLING = 0.001f;
|
||||||
const float HAIR_MAX_LINEAR_ACCELERATION = 4.0f;
|
const float HAIR_MAX_LINEAR_ACCELERATION = 4.0f;
|
||||||
const float HAIR_STIFFNESS = 0.00f;
|
const float HAIR_STIFFNESS = 0.00f;
|
||||||
const glm::vec3 HAIR_COLOR1(0.98f, 0.76f, 0.075f);
|
const glm::vec3 HAIR_COLOR1(0.98f, 0.76f, 0.075f);
|
||||||
|
|
|
@ -68,8 +68,7 @@ const int SCRIPTED_MOTOR_WORLD_FRAME = 2;
|
||||||
MyAvatar::MyAvatar() :
|
MyAvatar::MyAvatar() :
|
||||||
Avatar(),
|
Avatar(),
|
||||||
_mousePressed(false),
|
_mousePressed(false),
|
||||||
_bodyPitchDelta(0.0f),
|
_turningKeyPressTime(0.0f),
|
||||||
_bodyRollDelta(0.0f),
|
|
||||||
_gravity(0.0f, 0.0f, 0.0f),
|
_gravity(0.0f, 0.0f, 0.0f),
|
||||||
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
||||||
_shouldJump(false),
|
_shouldJump(false),
|
||||||
|
@ -1169,26 +1168,41 @@ bool MyAvatar::shouldRenderHead(const glm::vec3& cameraPosition, RenderMode rend
|
||||||
|
|
||||||
void MyAvatar::updateOrientation(float deltaTime) {
|
void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
// Gather rotation information from keyboard
|
// Gather rotation information from keyboard
|
||||||
_bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime;
|
const float TIME_BETWEEN_HMD_TURNS = 0.5f;
|
||||||
_bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime;
|
const float HMD_TURN_DEGREES = 22.5f;
|
||||||
|
if (!OculusManager::isConnected()) {
|
||||||
|
// Smoothly rotate body with arrow keys if not in HMD
|
||||||
|
_bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime;
|
||||||
|
_bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime;
|
||||||
|
} else {
|
||||||
|
// Jump turns if in HMD
|
||||||
|
if (_driveKeys[ROT_RIGHT] || _driveKeys[ROT_LEFT]) {
|
||||||
|
if (_turningKeyPressTime == 0.0f) {
|
||||||
|
setOrientation(getOrientation() *
|
||||||
|
glm::quat(glm::radians(glm::vec3(0.f, _driveKeys[ROT_LEFT] ? HMD_TURN_DEGREES : -HMD_TURN_DEGREES, 0.0f))));
|
||||||
|
}
|
||||||
|
_turningKeyPressTime += deltaTime;
|
||||||
|
if (_turningKeyPressTime > TIME_BETWEEN_HMD_TURNS) {
|
||||||
|
_turningKeyPressTime = 0.0f;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_turningKeyPressTime = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
||||||
|
|
||||||
// update body yaw by body yaw delta
|
// update body orientation by movement inputs
|
||||||
glm::quat orientation = getOrientation() * glm::quat(glm::radians(
|
setOrientation(getOrientation() *
|
||||||
glm::vec3(_bodyPitchDelta, _bodyYawDelta, _bodyRollDelta) * deltaTime));
|
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta, 0.0f) * deltaTime)));
|
||||||
|
|
||||||
// decay body rotation momentum
|
// decay body rotation momentum
|
||||||
const float BODY_SPIN_FRICTION = 7.5f;
|
const float BODY_SPIN_FRICTION = 7.5f;
|
||||||
float bodySpinMomentum = 1.0f - BODY_SPIN_FRICTION * deltaTime;
|
float bodySpinMomentum = 1.0f - BODY_SPIN_FRICTION * deltaTime;
|
||||||
if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; }
|
if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; }
|
||||||
_bodyPitchDelta *= bodySpinMomentum;
|
|
||||||
_bodyYawDelta *= bodySpinMomentum;
|
_bodyYawDelta *= bodySpinMomentum;
|
||||||
_bodyRollDelta *= bodySpinMomentum;
|
|
||||||
|
|
||||||
float MINIMUM_ROTATION_RATE = 2.0f;
|
float MINIMUM_ROTATION_RATE = 2.0f;
|
||||||
if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; }
|
if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; }
|
||||||
if (fabs(_bodyRollDelta) < MINIMUM_ROTATION_RATE) { _bodyRollDelta = 0.0f; }
|
|
||||||
if (fabs(_bodyPitchDelta) < MINIMUM_ROTATION_RATE) { _bodyPitchDelta = 0.0f; }
|
|
||||||
|
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
// these angles will be in radians
|
// these angles will be in radians
|
||||||
|
@ -1201,8 +1215,11 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
|
|
||||||
// Record the angular velocity
|
// Record the angular velocity
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
glm::vec3 angularVelocity(yaw - head->getBaseYaw(), pitch - head->getBasePitch(), roll - head->getBaseRoll());
|
if (deltaTime > 0.0f) {
|
||||||
head->setAngularVelocity(angularVelocity);
|
glm::vec3 angularVelocity(pitch - head->getBasePitch(), yaw - head->getBaseYaw(), roll - head->getBaseRoll());
|
||||||
|
angularVelocity *= 1.0f / deltaTime;
|
||||||
|
head->setAngularVelocity(angularVelocity);
|
||||||
|
}
|
||||||
|
|
||||||
//Invert yaw and roll when in mirror mode
|
//Invert yaw and roll when in mirror mode
|
||||||
if (Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) {
|
if (Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) {
|
||||||
|
@ -1217,8 +1234,6 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the euler angles
|
|
||||||
setOrientation(orientation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVelocity, bool hasFloor) {
|
glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVelocity, bool hasFloor) {
|
||||||
|
|
|
@ -204,8 +204,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _mousePressed;
|
bool _mousePressed;
|
||||||
float _bodyPitchDelta; // degrees
|
float _turningKeyPressTime;
|
||||||
float _bodyRollDelta; // degrees
|
|
||||||
glm::vec3 _gravity;
|
glm::vec3 _gravity;
|
||||||
float _distanceToNearestAvatar; // How close is the nearest avatar?
|
float _distanceToNearestAvatar; // How close is the nearest avatar?
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ bool HifiSockAddr::operator==(const HifiSockAddr& rhsSockAddr) const {
|
||||||
void HifiSockAddr::handleLookupResult(const QHostInfo& hostInfo) {
|
void HifiSockAddr::handleLookupResult(const QHostInfo& hostInfo) {
|
||||||
if (hostInfo.error() != QHostInfo::NoError) {
|
if (hostInfo.error() != QHostInfo::NoError) {
|
||||||
qDebug() << "Lookup failed for" << hostInfo.lookupId() << ":" << hostInfo.errorString();
|
qDebug() << "Lookup failed for" << hostInfo.lookupId() << ":" << hostInfo.errorString();
|
||||||
|
emit lookupFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QHostAddress& address, hostInfo.addresses()) {
|
foreach(const QHostAddress& address, hostInfo.addresses()) {
|
||||||
|
@ -94,6 +95,7 @@ void HifiSockAddr::handleLookupResult(const QHostInfo& hostInfo) {
|
||||||
_address = address;
|
_address = address;
|
||||||
qDebug() << "QHostInfo lookup result for"
|
qDebug() << "QHostInfo lookup result for"
|
||||||
<< hostInfo.hostName() << "with lookup ID" << hostInfo.lookupId() << "is" << address.toString();
|
<< hostInfo.hostName() << "with lookup ID" << hostInfo.lookupId() << "is" << address.toString();
|
||||||
|
emit lookupCompleted();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,9 @@ public:
|
||||||
friend QDataStream& operator>>(QDataStream& dataStream, HifiSockAddr& sockAddr);
|
friend QDataStream& operator>>(QDataStream& dataStream, HifiSockAddr& sockAddr);
|
||||||
private slots:
|
private slots:
|
||||||
void handleLookupResult(const QHostInfo& hostInfo);
|
void handleLookupResult(const QHostInfo& hostInfo);
|
||||||
|
signals:
|
||||||
|
void lookupCompleted();
|
||||||
|
void lookupFailed();
|
||||||
private:
|
private:
|
||||||
QHostAddress _address;
|
QHostAddress _address;
|
||||||
quint16 _port;
|
quint16 _port;
|
||||||
|
|
|
@ -105,6 +105,7 @@ public:
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
||||||
|
|
||||||
const HifiSockAddr& getLocalSockAddr() const { return _localSockAddr; }
|
const HifiSockAddr& getLocalSockAddr() const { return _localSockAddr; }
|
||||||
|
const HifiSockAddr& getSTUNSockAddr() const { return _stunSockAddr; }
|
||||||
|
|
||||||
void processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
|
void processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
|
||||||
void processKillNode(const QByteArray& datagram);
|
void processKillNode(const QByteArray& datagram);
|
||||||
|
|
|
@ -156,31 +156,30 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) {
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString scriptURLString = scriptURL.toString();
|
_fileNameString = scriptURL.toString();
|
||||||
_fileNameString = scriptURLString;
|
|
||||||
|
|
||||||
QUrl url(scriptURL);
|
QUrl url(scriptURL);
|
||||||
|
|
||||||
// if the scheme length is one or lower, maybe they typed in a file, let's try
|
// if the scheme length is one or lower, maybe they typed in a file, let's try
|
||||||
const int WINDOWS_DRIVE_LETTER_SIZE = 1;
|
const int WINDOWS_DRIVE_LETTER_SIZE = 1;
|
||||||
if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) {
|
if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) {
|
||||||
url = QUrl::fromLocalFile(scriptURLString);
|
url = QUrl::fromLocalFile(_fileNameString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, let's see if it's valid... and if so, load it
|
// ok, let's see if it's valid... and if so, load it
|
||||||
if (url.isValid()) {
|
if (url.isValid()) {
|
||||||
if (url.scheme() == "file") {
|
if (url.scheme() == "file") {
|
||||||
QString fileName = url.toLocalFile();
|
_fileNameString = url.toLocalFile();
|
||||||
QFile scriptFile(fileName);
|
QFile scriptFile(_fileNameString);
|
||||||
if (scriptFile.open(QFile::ReadOnly | QFile::Text)) {
|
if (scriptFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
qDebug() << "Loading file:" << fileName;
|
qDebug() << "ScriptEngine loading file:" << _fileNameString;
|
||||||
QTextStream in(&scriptFile);
|
QTextStream in(&scriptFile);
|
||||||
_scriptContents = in.readAll();
|
_scriptContents = in.readAll();
|
||||||
emit scriptLoaded(url);
|
emit scriptLoaded(_fileNameString);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "ERROR Loading file:" << fileName;
|
qDebug() << "ERROR Loading file:" << _fileNameString;
|
||||||
emit errorLoadingScript(url);
|
emit errorLoadingScript(_fileNameString);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
|
@ -195,10 +194,10 @@ void ScriptEngine::handleScriptDownload() {
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
|
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
|
||||||
_scriptContents = reply->readAll();
|
_scriptContents = reply->readAll();
|
||||||
emit scriptLoaded(reply->url());
|
emit scriptLoaded(_fileNameString);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "ERROR Loading file:" << reply->url().toString();
|
qDebug() << "ERROR Loading file:" << reply->url().toString();
|
||||||
emit errorLoadingScript(reply->url());
|
emit errorLoadingScript(_fileNameString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,8 @@ public slots:
|
||||||
void nodeKilled(SharedNodePointer node);
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void scriptLoaded(const QUrl& scriptURL);
|
void scriptLoaded(const QString& scriptFilename);
|
||||||
void errorLoadingScript(const QUrl& scriptURL);
|
void errorLoadingScript(const QString& scriptFilename);
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
void scriptEnding();
|
void scriptEnding();
|
||||||
void finished(const QString& fileNameString);
|
void finished(const QString& fileNameString);
|
||||||
|
|
Loading…
Reference in a new issue