mirror of
https://github.com/overte-org/overte.git
synced 2025-07-19 16:08:45 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into OculusOverlay
Conflicts: interface/src/ui/ApplicationOverlay.cpp
This commit is contained in:
commit
2eda35ff1d
14 changed files with 202 additions and 117 deletions
|
@ -335,7 +335,7 @@ void AudioMixer::prepareMixForListeningNode(Node* node) {
|
||||||
AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData();
|
AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData();
|
||||||
|
|
||||||
// enumerate the ARBs attached to the otherNode and add all that should be added to mix
|
// enumerate the ARBs attached to the otherNode and add all that should be added to mix
|
||||||
for (unsigned int i = 0; i < otherNodeClientData->getRingBuffers().size(); i++) {
|
for (int i = 0; i < otherNodeClientData->getRingBuffers().size(); i++) {
|
||||||
PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i];
|
PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i];
|
||||||
|
|
||||||
if ((*otherNode != *node
|
if ((*otherNode != *node
|
||||||
|
|
|
@ -25,14 +25,14 @@ AudioMixerClientData::AudioMixerClientData() :
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioMixerClientData::~AudioMixerClientData() {
|
AudioMixerClientData::~AudioMixerClientData() {
|
||||||
for (unsigned int i = 0; i < _ringBuffers.size(); i++) {
|
for (int i = 0; i < _ringBuffers.size(); i++) {
|
||||||
// delete this attached PositionalAudioRingBuffer
|
// delete this attached PositionalAudioRingBuffer
|
||||||
delete _ringBuffers[i];
|
delete _ringBuffers[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarAudioRingBuffer* AudioMixerClientData::getAvatarAudioRingBuffer() const {
|
AvatarAudioRingBuffer* AudioMixerClientData::getAvatarAudioRingBuffer() const {
|
||||||
for (unsigned int i = 0; i < _ringBuffers.size(); i++) {
|
for (int i = 0; i < _ringBuffers.size(); i++) {
|
||||||
if (_ringBuffers[i]->getType() == PositionalAudioRingBuffer::Microphone) {
|
if (_ringBuffers[i]->getType() == PositionalAudioRingBuffer::Microphone) {
|
||||||
return (AvatarAudioRingBuffer*) _ringBuffers[i];
|
return (AvatarAudioRingBuffer*) _ringBuffers[i];
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ int AudioMixerClientData::parseData(const QByteArray& packet) {
|
||||||
|
|
||||||
InjectedAudioRingBuffer* matchingInjectedRingBuffer = NULL;
|
InjectedAudioRingBuffer* matchingInjectedRingBuffer = NULL;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < _ringBuffers.size(); i++) {
|
for (int i = 0; i < _ringBuffers.size(); i++) {
|
||||||
if (_ringBuffers[i]->getType() == PositionalAudioRingBuffer::Injector
|
if (_ringBuffers[i]->getType() == PositionalAudioRingBuffer::Injector
|
||||||
&& ((InjectedAudioRingBuffer*) _ringBuffers[i])->getStreamIdentifier() == streamIdentifier) {
|
&& ((InjectedAudioRingBuffer*) _ringBuffers[i])->getStreamIdentifier() == streamIdentifier) {
|
||||||
matchingInjectedRingBuffer = (InjectedAudioRingBuffer*) _ringBuffers[i];
|
matchingInjectedRingBuffer = (InjectedAudioRingBuffer*) _ringBuffers[i];
|
||||||
|
@ -99,7 +99,7 @@ int AudioMixerClientData::parseData(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixerClientData::checkBuffersBeforeFrameSend(int jitterBufferLengthSamples) {
|
void AudioMixerClientData::checkBuffersBeforeFrameSend(int jitterBufferLengthSamples) {
|
||||||
for (unsigned int i = 0; i < _ringBuffers.size(); i++) {
|
for (int i = 0; i < _ringBuffers.size(); i++) {
|
||||||
if (_ringBuffers[i]->shouldBeAddedToMix(jitterBufferLengthSamples)) {
|
if (_ringBuffers[i]->shouldBeAddedToMix(jitterBufferLengthSamples)) {
|
||||||
// this is a ring buffer that is ready to go
|
// this is a ring buffer that is ready to go
|
||||||
// set its flag so we know to push its buffer when all is said and done
|
// set its flag so we know to push its buffer when all is said and done
|
||||||
|
@ -113,7 +113,7 @@ void AudioMixerClientData::checkBuffersBeforeFrameSend(int jitterBufferLengthSam
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixerClientData::pushBuffersAfterFrameSend() {
|
void AudioMixerClientData::pushBuffersAfterFrameSend() {
|
||||||
for (unsigned int i = 0; i < _ringBuffers.size(); i++) {
|
for (int i = 0; i < _ringBuffers.size(); i++) {
|
||||||
// this was a used buffer, push the output pointer forwards
|
// this was a used buffer, push the output pointer forwards
|
||||||
PositionalAudioRingBuffer* audioBuffer = _ringBuffers[i];
|
PositionalAudioRingBuffer* audioBuffer = _ringBuffers[i];
|
||||||
|
|
||||||
|
|
|
@ -659,7 +659,7 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
wasNoisyTimerStarted = true;
|
wasNoisyTimerStarted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const quint64 NOISY_MESSAGE_INTERVAL_MSECS = 5 * 1000;
|
const qint64 NOISY_MESSAGE_INTERVAL_MSECS = 5 * 1000;
|
||||||
|
|
||||||
if (requestAssignment.getType() != Assignment::AgentType
|
if (requestAssignment.getType() != Assignment::AgentType
|
||||||
|| noisyMessageTimer.elapsed() > NOISY_MESSAGE_INTERVAL_MSECS) {
|
|| noisyMessageTimer.elapsed() > NOISY_MESSAGE_INTERVAL_MSECS) {
|
||||||
|
|
|
@ -691,6 +691,10 @@ function rayPlaneIntersection(pickRay, point, normal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
|
if (altIsPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mouseLastPosition = { x: event.x, y: event.y };
|
mouseLastPosition = { x: event.x, y: event.y };
|
||||||
modelSelected = false;
|
modelSelected = false;
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||||
|
@ -790,6 +794,10 @@ var oldModifier = 0;
|
||||||
var modifier = 0;
|
var modifier = 0;
|
||||||
var wasShifted = false;
|
var wasShifted = false;
|
||||||
function mouseMoveEvent(event) {
|
function mouseMoveEvent(event) {
|
||||||
|
if (altIsPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
|
||||||
if (!modelSelected) {
|
if (!modelSelected) {
|
||||||
|
@ -894,6 +902,10 @@ function mouseMoveEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseReleaseEvent(event) {
|
function mouseReleaseEvent(event) {
|
||||||
|
if (altIsPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
modelSelected = false;
|
modelSelected = false;
|
||||||
|
|
||||||
glowedModelID.id = -1;
|
glowedModelID.id = -1;
|
||||||
|
@ -962,4 +974,16 @@ Menu.menuItemEvent.connect(function(menuItem){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// handling of inspect.js concurrence
|
||||||
|
altIsPressed = false;
|
||||||
|
Controller.keyPressEvent.connect(function(event) {
|
||||||
|
if (event.text == "ALT") {
|
||||||
|
altIsPressed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Controller.keyReleaseEvent.connect(function(event) {
|
||||||
|
if (event.text == "ALT") {
|
||||||
|
altIsPressed = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ var noMode = 0;
|
||||||
var orbitMode = 1;
|
var orbitMode = 1;
|
||||||
var radialMode = 2;
|
var radialMode = 2;
|
||||||
var panningMode = 3;
|
var panningMode = 3;
|
||||||
|
var detachedMode = 4;
|
||||||
|
|
||||||
var mode = noMode;
|
var mode = noMode;
|
||||||
|
|
||||||
|
@ -48,6 +49,9 @@ var radius = 0.0;
|
||||||
var azimuth = 0.0;
|
var azimuth = 0.0;
|
||||||
var altitude = 0.0;
|
var altitude = 0.0;
|
||||||
|
|
||||||
|
var avatarPosition;
|
||||||
|
var avatarOrientation;
|
||||||
|
|
||||||
|
|
||||||
function handleRadialMode(dx, dy) {
|
function handleRadialMode(dx, dy) {
|
||||||
azimuth += dx / AZIMUTH_RATE;
|
azimuth += dx / AZIMUTH_RATE;
|
||||||
|
@ -108,7 +112,7 @@ function restoreCameraState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleModes() {
|
function handleModes() {
|
||||||
var newMode = noMode;
|
var newMode = (mode == noMode) ? noMode : detachedMode;
|
||||||
if (alt) {
|
if (alt) {
|
||||||
if (control) {
|
if (control) {
|
||||||
if (shift) {
|
if (shift) {
|
||||||
|
@ -121,6 +125,22 @@ function handleModes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if entering detachMode
|
||||||
|
if (newMode == detachedMode && mode != detachedMode) {
|
||||||
|
avatarPosition = MyAvatar.position;
|
||||||
|
avatarOrientation = MyAvatar.orientation;
|
||||||
|
}
|
||||||
|
// if leaving detachMode
|
||||||
|
if (mode == detachedMode && newMode == detachedMode &&
|
||||||
|
(avatarPosition.x != MyAvatar.position.x ||
|
||||||
|
avatarPosition.y != MyAvatar.position.y ||
|
||||||
|
avatarPosition.z != MyAvatar.position.z ||
|
||||||
|
avatarOrientation.x != MyAvatar.orientation.x ||
|
||||||
|
avatarOrientation.y != MyAvatar.orientation.y ||
|
||||||
|
avatarOrientation.z != MyAvatar.orientation.z ||
|
||||||
|
avatarOrientation.w != MyAvatar.orientation.w)) {
|
||||||
|
newMode = noMode;
|
||||||
|
}
|
||||||
// if leaving noMode
|
// if leaving noMode
|
||||||
if (mode == noMode && newMode != noMode) {
|
if (mode == noMode && newMode != noMode) {
|
||||||
saveCameraState();
|
saveCameraState();
|
||||||
|
@ -177,30 +197,45 @@ function keyReleaseEvent(event) {
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
if (alt && !isActive) {
|
if (alt && !isActive) {
|
||||||
isActive = true;
|
|
||||||
mouseLastX = event.x;
|
mouseLastX = event.x;
|
||||||
mouseLastY = event.y;
|
mouseLastY = event.y;
|
||||||
|
|
||||||
// Compute trajectories related values
|
// Compute trajectories related values
|
||||||
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
||||||
var intersection = Voxels.findRayIntersection(pickRay);
|
var voxelIntersection = Voxels.findRayIntersection(pickRay);
|
||||||
|
var modelIntersection = Models.findRayIntersection(pickRay);
|
||||||
|
|
||||||
position = Camera.getPosition();
|
position = Camera.getPosition();
|
||||||
|
|
||||||
avatarTarget = MyAvatar.getTargetAvatarPosition();
|
var avatarTarget = MyAvatar.getTargetAvatarPosition();
|
||||||
voxelTarget = intersection.intersection;
|
var voxelTarget = voxelIntersection.intersection;
|
||||||
if (Vec3.length(Vec3.subtract(avatarTarget, position)) < Vec3.length(Vec3.subtract(voxelTarget, position))) {
|
|
||||||
if (avatarTarget.x != 0 || avatarTarget.y != 0 || avatarTarget.z != 0) {
|
|
||||||
center = avatarTarget;
|
var distance = -1;
|
||||||
} else {
|
var string;
|
||||||
center = voxelTarget;
|
|
||||||
}
|
if (modelIntersection.intersects && modelIntersection.accurate) {
|
||||||
} else {
|
distance = modelIntersection.distance;
|
||||||
if (voxelTarget.x != 0 || voxelTarget.y != 0 || voxelTarget.z != 0) {
|
center = modelIntersection.modelProperties.position;
|
||||||
center = voxelTarget;
|
string = "Inspecting model";
|
||||||
} else {
|
}
|
||||||
center = avatarTarget;
|
|
||||||
}
|
if ((distance == -1 || Vec3.length(Vec3.subtract(avatarTarget, position)) < distance) &&
|
||||||
|
(avatarTarget.x != 0 || avatarTarget.y != 0 || avatarTarget.z != 0)) {
|
||||||
|
distance = Vec3.length(Vec3.subtract(avatarTarget, position));
|
||||||
|
center = avatarTarget;
|
||||||
|
string = "Inspecting avatar";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((distance == -1 || Vec3.length(Vec3.subtract(voxelTarget, position)) < distance) &&
|
||||||
|
(voxelTarget.x != 0 || voxelTarget.y != 0 || voxelTarget.z != 0)) {
|
||||||
|
distance = Vec3.length(Vec3.subtract(voxelTarget, position));
|
||||||
|
center = voxelTarget;
|
||||||
|
string = "Inspecting voxel";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance == -1) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector = Vec3.subtract(position, center);
|
vector = Vec3.subtract(position, center);
|
||||||
|
@ -209,6 +244,8 @@ function mousePressEvent(event) {
|
||||||
altitude = Math.asin(vector.y / Vec3.length(vector));
|
altitude = Math.asin(vector.y / Vec3.length(vector));
|
||||||
|
|
||||||
Camera.keepLookingAt(center);
|
Camera.keepLookingAt(center);
|
||||||
|
print(string);
|
||||||
|
isActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +272,10 @@ function mouseMoveEvent(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
handleModes();
|
||||||
|
}
|
||||||
|
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
if (mode != noMode) {
|
if (mode != noMode) {
|
||||||
restoreCameraState();
|
restoreCameraState();
|
||||||
|
@ -248,4 +289,5 @@ Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||||
|
|
||||||
|
Script.update.connect(update);
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
|
@ -1419,7 +1419,7 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo)
|
||||||
// proportional to the accelerator ratio.
|
// proportional to the accelerator ratio.
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
const float Audio::CALLBACK_ACCELERATOR_RATIO = 0.4f;
|
const float Audio::CALLBACK_ACCELERATOR_RATIO = 0.1f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
|
|
@ -170,6 +170,8 @@ Menu::Menu() :
|
||||||
Qt::Key_At,
|
Qt::Key_At,
|
||||||
this,
|
this,
|
||||||
SLOT(goTo()));
|
SLOT(goTo()));
|
||||||
|
connect(&LocationManager::getInstance(), &LocationManager::multipleDestinationsFound,
|
||||||
|
this, &Menu::multipleDestinationsDecision);
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Upload Avatar Model");
|
addDisabledActionAndSeparator(fileMenu, "Upload Avatar Model");
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadHead, 0, Application::getInstance(), SLOT(uploadHead()));
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadHead, 0, Application::getInstance(), SLOT(uploadHead()));
|
||||||
|
@ -1076,9 +1078,7 @@ bool Menu::goToURL(QString location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::goToUser(const QString& user) {
|
void Menu::goToUser(const QString& user) {
|
||||||
LocationManager* manager = &LocationManager::getInstance();
|
LocationManager::getInstance().goTo(user);
|
||||||
manager->goTo(user);
|
|
||||||
connect(manager, &LocationManager::multipleDestinationsFound, this, &Menu::multipleDestinationsDecision);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open a url, shortcutting any "hifi" scheme URLs to the local application.
|
/// Open a url, shortcutting any "hifi" scheme URLs to the local application.
|
||||||
|
@ -1100,13 +1100,10 @@ void Menu::multipleDestinationsDecision(const QJsonObject& userData, const QJson
|
||||||
int userResponse = msgBox.exec();
|
int userResponse = msgBox.exec();
|
||||||
|
|
||||||
if (userResponse == QMessageBox::Ok) {
|
if (userResponse == QMessageBox::Ok) {
|
||||||
Application::getInstance()->getAvatar()->goToLocationFromResponse(userData);
|
Application::getInstance()->getAvatar()->goToLocationFromAddress(userData["address"].toObject());
|
||||||
} else if (userResponse == QMessageBox::Open) {
|
} else if (userResponse == QMessageBox::Open) {
|
||||||
Application::getInstance()->getAvatar()->goToLocationFromResponse(userData);
|
Application::getInstance()->getAvatar()->goToLocationFromAddress(placeData["address"].toObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationManager* manager = reinterpret_cast<LocationManager*>(sender());
|
|
||||||
disconnect(manager, &LocationManager::multipleDestinationsFound, this, &Menu::multipleDestinationsDecision);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::muteEnvironment() {
|
void Menu::muteEnvironment() {
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
#include "ui/TextRenderer.h"
|
#include "ui/TextRenderer.h"
|
||||||
#include "VoxelConstants.h"
|
#include "VoxelConstants.h"
|
||||||
|
@ -409,8 +411,44 @@ void runTimingTests() {
|
||||||
|
|
||||||
float NSEC_TO_USEC = 1.0f / 1000.0f;
|
float NSEC_TO_USEC = 1.0f / 1000.0f;
|
||||||
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
qDebug("QElapsedTimer::nsecElapsed() usecs: %f", elapsedUsecs / (float) numTests);
|
qDebug("QElapsedTimer::nsecElapsed() usecs: %f", elapsedUsecs);
|
||||||
|
|
||||||
|
// Test sleep functions for accuracy
|
||||||
|
startTime.start();
|
||||||
|
QThread::msleep(1);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("QThread::msleep(1) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
|
startTime.start();
|
||||||
|
QThread::sleep(1);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("QThread::sleep(1) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
|
startTime.start();
|
||||||
|
usleep(1);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("usleep(1) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
|
startTime.start();
|
||||||
|
usleep(10);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("usleep(10) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
|
startTime.start();
|
||||||
|
usleep(100);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("usleep(100) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
|
startTime.start();
|
||||||
|
usleep(1000);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("usleep(1000) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
|
startTime.start();
|
||||||
|
usleep(15000);
|
||||||
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
qDebug("usleep(15000) ms: %f", elapsedUsecs / 1000.0f);
|
||||||
|
|
||||||
// Random number generation
|
// Random number generation
|
||||||
startTime.start();
|
startTime.start();
|
||||||
for (int i = 0; i < numTests; i++) {
|
for (int i = 0; i < numTests; i++) {
|
||||||
|
|
|
@ -1626,44 +1626,46 @@ void MyAvatar::resetSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) {
|
void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) {
|
||||||
|
|
||||||
if (jsonObject["status"].toString() == "success") {
|
if (jsonObject["status"].toString() == "success") {
|
||||||
|
|
||||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
|
||||||
sendKillAvatar();
|
|
||||||
|
|
||||||
QJsonObject locationObject = jsonObject["data"].toObject()["address"].toObject();
|
QJsonObject locationObject = jsonObject["data"].toObject()["address"].toObject();
|
||||||
QString positionString = locationObject["position"].toString();
|
goToLocationFromAddress(locationObject);
|
||||||
QString orientationString = locationObject["orientation"].toString();
|
|
||||||
QString domainHostnameString = locationObject["domain"].toString();
|
|
||||||
|
|
||||||
qDebug() << "Changing domain to" << domainHostnameString <<
|
|
||||||
", position to" << positionString <<
|
|
||||||
", and orientation to" << orientationString;
|
|
||||||
|
|
||||||
QStringList coordinateItems = positionString.split(',');
|
|
||||||
QStringList orientationItems = orientationString.split(',');
|
|
||||||
|
|
||||||
NodeList::getInstance()->getDomainHandler().setHostname(domainHostnameString);
|
|
||||||
|
|
||||||
// orient the user to face the target
|
|
||||||
glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
|
|
||||||
orientationItems[1].toFloat(),
|
|
||||||
orientationItems[2].toFloat())))
|
|
||||||
* glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
|
||||||
setOrientation(newOrientation);
|
|
||||||
|
|
||||||
// move the user a couple units away
|
|
||||||
const float DISTANCE_TO_USER = 2.0f;
|
|
||||||
glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
|
|
||||||
coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
|
|
||||||
setPosition(newPosition);
|
|
||||||
emit transformChanged();
|
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(Application::getInstance()->getWindow(), "", "That user or location could not be found.");
|
QMessageBox::warning(Application::getInstance()->getWindow(), "", "That user or location could not be found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::goToLocationFromAddress(const QJsonObject& locationObject) {
|
||||||
|
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||||
|
sendKillAvatar();
|
||||||
|
|
||||||
|
QString positionString = locationObject["position"].toString();
|
||||||
|
QString orientationString = locationObject["orientation"].toString();
|
||||||
|
QString domainHostnameString = locationObject["domain"].toString();
|
||||||
|
|
||||||
|
qDebug() << "Changing domain to" << domainHostnameString <<
|
||||||
|
", position to" << positionString <<
|
||||||
|
", and orientation to" << orientationString;
|
||||||
|
|
||||||
|
QStringList coordinateItems = positionString.split(',');
|
||||||
|
QStringList orientationItems = orientationString.split(',');
|
||||||
|
|
||||||
|
NodeList::getInstance()->getDomainHandler().setHostname(domainHostnameString);
|
||||||
|
|
||||||
|
// orient the user to face the target
|
||||||
|
glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
|
||||||
|
orientationItems[1].toFloat(),
|
||||||
|
orientationItems[2].toFloat())))
|
||||||
|
* glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
setOrientation(newOrientation);
|
||||||
|
|
||||||
|
// move the user a couple units away
|
||||||
|
const float DISTANCE_TO_USER = 2.0f;
|
||||||
|
glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
|
||||||
|
coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
|
||||||
|
setPosition(newPosition);
|
||||||
|
emit transformChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::updateMotionBehaviorsFromMenu() {
|
void MyAvatar::updateMotionBehaviorsFromMenu() {
|
||||||
Menu* menu = Menu::getInstance();
|
Menu* menu = Menu::getInstance();
|
||||||
if (menu->isOptionChecked(MenuOption::ObeyEnvironmentalGravity)) {
|
if (menu->isOptionChecked(MenuOption::ObeyEnvironmentalGravity)) {
|
||||||
|
|
|
@ -129,6 +129,7 @@ public slots:
|
||||||
void resetSize();
|
void resetSize();
|
||||||
|
|
||||||
void goToLocationFromResponse(const QJsonObject& jsonObject);
|
void goToLocationFromResponse(const QJsonObject& jsonObject);
|
||||||
|
void goToLocationFromAddress(const QJsonObject& jsonObject);
|
||||||
|
|
||||||
// Set/Get update the thrust that will move the avatar around
|
// Set/Get update the thrust that will move the avatar around
|
||||||
void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
|
void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
|
||||||
|
|
|
@ -16,10 +16,11 @@
|
||||||
|
|
||||||
const QString GET_USER_ADDRESS = "/api/v1/users/%1/address";
|
const QString GET_USER_ADDRESS = "/api/v1/users/%1/address";
|
||||||
const QString GET_PLACE_ADDRESS = "/api/v1/places/%1/address";
|
const QString GET_PLACE_ADDRESS = "/api/v1/places/%1/address";
|
||||||
|
const QString GET_ADDRESSES = "/api/v1/addresses/%1";
|
||||||
const QString POST_PLACE_CREATE = "/api/v1/places/";
|
const QString POST_PLACE_CREATE = "/api/v1/places/";
|
||||||
|
|
||||||
|
|
||||||
LocationManager::LocationManager() : _userData(), _placeData() {
|
LocationManager::LocationManager() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,58 +75,38 @@ void LocationManager::goTo(QString destination) {
|
||||||
|
|
||||||
// go to coordinate destination or to Username
|
// go to coordinate destination or to Username
|
||||||
if (!goToDestination(destination)) {
|
if (!goToDestination(destination)) {
|
||||||
// reset data on local variables
|
destination = QString(QUrl::toPercentEncoding(destination));
|
||||||
_userData = QJsonObject();
|
|
||||||
_placeData = QJsonObject();
|
|
||||||
|
|
||||||
JSONCallbackParameters callbackParams;
|
JSONCallbackParameters callbackParams;
|
||||||
callbackParams.jsonCallbackReceiver = this;
|
callbackParams.jsonCallbackReceiver = this;
|
||||||
callbackParams.jsonCallbackMethod = "goToUserFromResponse";
|
callbackParams.jsonCallbackMethod = "goToAddressFromResponse";
|
||||||
AccountManager::getInstance().authenticatedRequest(GET_USER_ADDRESS.arg(destination),
|
AccountManager::getInstance().authenticatedRequest(GET_ADDRESSES.arg(destination),
|
||||||
QNetworkAccessManager::GetOperation,
|
|
||||||
callbackParams);
|
|
||||||
|
|
||||||
callbackParams.jsonCallbackMethod = "goToLocationFromResponse";
|
|
||||||
AccountManager::getInstance().authenticatedRequest(GET_PLACE_ADDRESS.arg(destination),
|
|
||||||
QNetworkAccessManager::GetOperation,
|
QNetworkAccessManager::GetOperation,
|
||||||
callbackParams);
|
callbackParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationManager::goToUserFromResponse(const QJsonObject& jsonObject) {
|
void LocationManager::goToAddressFromResponse(const QJsonObject& responseData) {
|
||||||
_userData = jsonObject;
|
QJsonValue status = responseData["status"];
|
||||||
checkForMultipleDestinations();
|
qDebug() << responseData;
|
||||||
}
|
if (!status.isUndefined() && status.toString() == "success") {
|
||||||
|
const QJsonObject& data = responseData["data"].toObject();
|
||||||
|
const QJsonValue& userObject = data["user"];
|
||||||
|
const QJsonValue& placeObject = data["place"];
|
||||||
|
|
||||||
void LocationManager::goToLocationFromResponse(const QJsonObject& jsonObject) {
|
if (!placeObject.isUndefined() && !userObject.isUndefined()) {
|
||||||
_placeData = jsonObject;
|
emit multipleDestinationsFound(userObject.toObject(), placeObject.toObject());
|
||||||
checkForMultipleDestinations();
|
} else if (placeObject.isUndefined()) {
|
||||||
}
|
Application::getInstance()->getAvatar()->goToLocationFromAddress(userObject.toObject()["address"].toObject());
|
||||||
|
} else {
|
||||||
void LocationManager::checkForMultipleDestinations() {
|
Application::getInstance()->getAvatar()->goToLocationFromAddress(placeObject.toObject()["address"].toObject());
|
||||||
if (!_userData.isEmpty() && !_placeData.isEmpty()) {
|
|
||||||
if (_userData.contains("status") && _userData["status"].toString() == "success" &&
|
|
||||||
_placeData.contains("status") && _placeData["status"].toString() == "success") {
|
|
||||||
emit multipleDestinationsFound(_userData, _placeData);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (_userData.contains("status") && _userData["status"].toString() == "success") {
|
|
||||||
Application::getInstance()->getAvatar()->goToLocationFromResponse(_userData);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_placeData.contains("status") && _placeData["status"].toString() == "success") {
|
|
||||||
Application::getInstance()->getAvatar()->goToLocationFromResponse(_placeData);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMessageBox::warning(Application::getInstance()->getWindow(), "", "That user or location could not be found.");
|
QMessageBox::warning(Application::getInstance()->getWindow(), "", "That user or location could not be found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationManager::goToUser(QString userName) {
|
void LocationManager::goToUser(QString userName) {
|
||||||
|
|
||||||
JSONCallbackParameters callbackParams;
|
JSONCallbackParameters callbackParams;
|
||||||
callbackParams.jsonCallbackReceiver = Application::getInstance()->getAvatar();
|
callbackParams.jsonCallbackReceiver = Application::getInstance()->getAvatar();
|
||||||
callbackParams.jsonCallbackMethod = "goToLocationFromResponse";
|
callbackParams.jsonCallbackMethod = "goToLocationFromResponse";
|
||||||
|
|
|
@ -39,11 +39,7 @@ public:
|
||||||
bool goToDestination(QString destination);
|
bool goToDestination(QString destination);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject _userData;
|
|
||||||
QJsonObject _placeData;
|
|
||||||
|
|
||||||
void replaceLastOccurrence(const QChar search, const QChar replace, QString& string);
|
void replaceLastOccurrence(const QChar search, const QChar replace, QString& string);
|
||||||
void checkForMultipleDestinations();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void creationCompleted(LocationManager::NamedLocationCreateResponse response);
|
void creationCompleted(LocationManager::NamedLocationCreateResponse response);
|
||||||
|
@ -52,8 +48,7 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void namedLocationDataReceived(const QJsonObject& data);
|
void namedLocationDataReceived(const QJsonObject& data);
|
||||||
void errorDataReceived(QNetworkReply::NetworkError error, const QString& message);
|
void errorDataReceived(QNetworkReply::NetworkError error, const QString& message);
|
||||||
void goToLocationFromResponse(const QJsonObject& jsonObject);
|
void goToAddressFromResponse(const QJsonObject& jsonObject);
|
||||||
void goToUserFromResponse(const QJsonObject& jsonObject);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ void Sound::interpretAsWav(const QByteArray& inputAudioByteArray, QByteArray& ou
|
||||||
// Now pull out the data
|
// Now pull out the data
|
||||||
quint32 outputAudioByteArraySize = qFromLittleEndian<quint32>(dataHeader.descriptor.size);
|
quint32 outputAudioByteArraySize = qFromLittleEndian<quint32>(dataHeader.descriptor.size);
|
||||||
outputAudioByteArray.resize(outputAudioByteArraySize);
|
outputAudioByteArray.resize(outputAudioByteArraySize);
|
||||||
if (waveStream.readRawData(outputAudioByteArray.data(), outputAudioByteArraySize) != outputAudioByteArraySize) {
|
if (waveStream.readRawData(outputAudioByteArray.data(), outputAudioByteArraySize) != (int)outputAudioByteArraySize) {
|
||||||
qDebug() << "Error reading WAV file";
|
qDebug() << "Error reading WAV file";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
@ -415,13 +416,17 @@ void printVoxelCode(unsigned char* voxelCode) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void usleep(int waitTime) {
|
void usleep(int waitTime) {
|
||||||
__int64 time1 = 0, time2 = 0, sysFreq = 0;
|
const quint64 BUSY_LOOP_USECS = 2000;
|
||||||
|
quint64 compTime = waitTime + usecTimestampNow();
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)&time1);
|
quint64 compTimeSleep = compTime - BUSY_LOOP_USECS;
|
||||||
QueryPerformanceFrequency((LARGE_INTEGER *)&sysFreq);
|
while (true) {
|
||||||
do {
|
if (usecTimestampNow() < compTimeSleep) {
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)&time2);
|
QThread::msleep(1);
|
||||||
} while( (time2 - time1) < waitTime);
|
}
|
||||||
|
if (usecTimestampNow() >= compTime) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue