From dc8a6c2725e50388c7f227f59ffdb0f67210d3fc Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Jun 2013 11:30:41 -0700 Subject: [PATCH 1/6] Store the avatar voxel URL along with the rest of the avatar settings. --- interface/src/Application.cpp | 9 +++------ interface/src/Avatar.cpp | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index acb82412ca..745e788232 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1023,7 +1023,7 @@ void Application::editPreferences() { QFormLayout* form = new QFormLayout(); layout->addLayout(form, 1); - QLineEdit* avatarURL = new QLineEdit(_settings->value("avatarURL").toString()); + QLineEdit* avatarURL = new QLineEdit(_myAvatar.getVoxels()->getVoxelURL().toString()); avatarURL->setMinimumWidth(400); form->addRow("Avatar URL:", avatarURL); @@ -1040,7 +1040,6 @@ void Application::editPreferences() { return; } QUrl url(avatarURL->text()); - _settings->setValue("avatarURL", url); _myAvatar.getVoxels()->setVoxelURL(url); sendAvatarVoxelURLMessage(url); @@ -1532,10 +1531,6 @@ void Application::init() { _myCamera.setModeShiftRate(1.0f); _myAvatar.setDisplayingLookatVectors(false); - QUrl avatarURL = _settings->value("avatarURL").toUrl(); - _myAvatar.getVoxels()->setVoxelURL(avatarURL); - sendAvatarVoxelURLMessage(avatarURL); - QCursor::setPos(_headMouseX, _headMouseY); OculusManager::connect(); @@ -1547,6 +1542,8 @@ void Application::init() { gettimeofday(&_lastTimeIdle, NULL); loadSettings(); + + sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); } void Application::updateAvatar(float deltaTime) { diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 918cd02c78..e5c5a76a70 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -1225,6 +1225,8 @@ void Avatar::loadData(QSettings* set) { _position.y = set->value("position_y", _position.y).toFloat(); _position.z = set->value("position_z", _position.z).toFloat(); + _voxels.setVoxelURL(set->value("voxelURL").toUrl()); + set->endGroup(); } @@ -1244,6 +1246,8 @@ void Avatar::saveData(QSettings* set) { set->setValue("position_y", _position.y); set->setValue("position_z", _position.z); + set->setValue("voxelURL", _voxels.getVoxelURL()); + set->endGroup(); } From a5c24b5333e3e8b395bcc486335980271a2d5c2b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Jun 2013 11:32:26 -0700 Subject: [PATCH 2/6] OK, we don't need this sync. Clearly the problem I was seeing on OS X lies elsewhere. --- interface/src/Application.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 745e788232..8c636bb061 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2536,8 +2536,6 @@ void Application::saveSettings(QSettings* set) { set->setValue("headCameraPitchYawScale", _headCameraPitchYawScale); scanMenuBar(&Application::saveAction, set); getAvatar()->saveData(set); - - set->sync(); } void Application::importSettings() { From 953aec35e68749e262835000f8bc730747e17b3d Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Jun 2013 11:48:29 -0700 Subject: [PATCH 3/6] Use the default QSettings constructor and let it get the application info from the QCoreApplication properties. --- interface/src/Application.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8c636bb061..3aac8f5667 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -227,8 +227,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _glWidget->setMouseTracking(true); // initialization continues in initializeGL when OpenGL context is ready - - QCoreApplication::setOrganizationDomain("highfidelity.io"); // Used by QSettings on OS X + + // these are used, for example, to identify the application's preferences + setApplicationName("Interface"); + setOrganizationDomain("highfidelity.io"); + setOrganizationName("High Fidelity"); } void Application::initializeGL() { @@ -1476,7 +1479,7 @@ void Application::initMenu() { settingsMenu->addAction("Export settings", this, SLOT(exportSettings())); _networkAccessManager = new QNetworkAccessManager(this); - _settings = new QSettings("High Fidelity", "Interface", this); + _settings = new QSettings(this); } void Application::updateFrustumRenderModeAction() { From 9da10df9f2dcefb47aa9fe232cfe2f96bbc8897d Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Jun 2013 13:12:59 -0700 Subject: [PATCH 4/6] We need to set these before initMenu, as that's where we create the QSettings. --- interface/src/Application.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3aac8f5667..ee66d13afd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -215,6 +215,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _window->setCentralWidget(_glWidget); + // these are used, for example, to identify the application's preferences + setApplicationName("Interface"); + setOrganizationDomain("highfidelity.io"); + setOrganizationName("High Fidelity"); + initMenu(); QRect available = desktop()->availableGeometry(); @@ -227,11 +232,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _glWidget->setMouseTracking(true); // initialization continues in initializeGL when OpenGL context is ready - - // these are used, for example, to identify the application's preferences - setApplicationName("Interface"); - setOrganizationDomain("highfidelity.io"); - setOrganizationName("High Fidelity"); } void Application::initializeGL() { From 75c89f2c2277a942a9db4531ecd5ffecc660a497 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Jun 2013 13:42:49 -0700 Subject: [PATCH 5/6] OK, I found the problem: duplication of state for the "autosave" option. Let's just use the QAction, as does everything else. --- interface/src/Application.cpp | 10 +++------- interface/src/Application.h | 3 --- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ee66d13afd..49e91f6352 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -215,7 +215,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _window->setCentralWidget(_glWidget); - // these are used, for example, to identify the application's preferences + // these are used, for example, to identify the application settings setApplicationName("Interface"); setOrganizationDomain("highfidelity.io"); setOrganizationName("High Fidelity"); @@ -968,7 +968,7 @@ void Application::terminate() { // Close serial port // close(serial_fd); - if (_autosave) { + if (_settingsAutosave->isChecked()) { saveSettings(); _settings->sync(); } @@ -1471,7 +1471,7 @@ void Application::initMenu() { debugMenu->addAction("Wants View Delta Sending", this, SLOT(setWantsDelta(bool)))->setCheckable(true); QMenu* settingsMenu = menuBar->addMenu("Settings"); - (_settingsAutosave = settingsMenu->addAction("Autosave", this, SLOT(setAutosave(bool))))->setCheckable(true); + (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true); _settingsAutosave->setChecked(true); settingsMenu->addAction("Load settings", this, SLOT(loadSettings())); settingsMenu->addAction("Save settings", this, SLOT(saveSettings())); @@ -2521,10 +2521,6 @@ void Application::saveAction(QSettings* set, QAction* action) { set->setValue(action->text(), action->isChecked()); } -void Application::setAutosave(bool wantsAutosave) { - _autosave = wantsAutosave; -} - void Application::loadSettings(QSettings* set) { if (!set) set = getSettings(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 3fe1e8e4b5..2316f23dc0 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -112,7 +112,6 @@ private slots: void decreaseVoxelSize(); void increaseVoxelSize(); void chooseVoxelPaintColor(); - void setAutosave(bool wantsAutosave); void loadSettings(QSettings* set = NULL); void saveSettings(QSettings* set = NULL); void importSettings(); @@ -293,8 +292,6 @@ private: int _packetsPerSecond; int _bytesPerSecond; int _bytesCount; - - bool _autosave; // True if the autosave is on. }; #endif /* defined(__interface__Application__) */ From ac2b7d7f48b89021350415aeef5873cf7383863c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Jun 2013 15:20:26 -0700 Subject: [PATCH 6/6] Fix for initial camera transition. --- interface/src/Application.cpp | 354 +++++++++++++++++----------------- interface/src/Application.h | 1 + interface/src/Camera.cpp | 2 +- 3 files changed, 181 insertions(+), 176 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 49e91f6352..05f780b422 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -292,6 +292,9 @@ void Application::initializeGL() { printLog("%s", title); _window->setWindowTitle(title); } + + // update before the first render + update(0.0f); } void Application::paintGL() { @@ -783,181 +786,7 @@ void Application::idle() { // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran if (diffclock(&_lastTimeIdle, &check) > IDLE_SIMULATE_MSECS) { - - float deltaTime = 1.f/_fps; - - // Use Transmitter Hand to move hand if connected, else use mouse - if (_myTransmitter.isConnected()) { - const float HAND_FORCE_SCALING = 0.01f; - glm::vec3 estimatedRotation = _myTransmitter.getEstimatedRotation(); - glm::vec3 handForce(-estimatedRotation.z, -estimatedRotation.x, estimatedRotation.y); - _myAvatar.setMovedHandOffset(handForce * HAND_FORCE_SCALING); - } else { - // update behaviors for avatar hand movement: handControl takes mouse values as input, - // and gives back 3D values modulated for smooth transitioning between interaction modes. - _handControl.update(_mouseX, _mouseY); - _myAvatar.setMovedHandOffset(_handControl.getValues()); - } - - // tell my avatar if the mouse is being pressed... - _myAvatar.setMousePressed(_mousePressed); - - // check what's under the mouse and update the mouse voxel - glm::vec3 mouseRayOrigin, mouseRayDirection; - _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), - _mouseY / (float)_glWidget->height(), mouseRayOrigin, mouseRayDirection); - - // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position - _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection); - - _mouseVoxel.s = 0.0f; - if (checkedVoxelModeAction() != 0) { - float distance; - BoxFace face; - if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) { - // find the nearest voxel with the desired scale - if (_mouseVoxelScale > _mouseVoxel.s) { - // choose the larger voxel that encompasses the one selected - _mouseVoxel.x = _mouseVoxelScale * floorf(_mouseVoxel.x / _mouseVoxelScale); - _mouseVoxel.y = _mouseVoxelScale * floorf(_mouseVoxel.y / _mouseVoxelScale); - _mouseVoxel.z = _mouseVoxelScale * floorf(_mouseVoxel.z / _mouseVoxelScale); - _mouseVoxel.s = _mouseVoxelScale; - - } else { - glm::vec3 faceVector = getFaceVector(face); - if (_mouseVoxelScale < _mouseVoxel.s) { - // find the closest contained voxel - glm::vec3 pt = (mouseRayOrigin + mouseRayDirection * distance) / (float)TREE_SCALE - - faceVector * (_mouseVoxelScale * 0.5f); - _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale); - _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale); - _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / _mouseVoxelScale); - _mouseVoxel.s = _mouseVoxelScale; - } - if (_addVoxelMode->isChecked()) { - // use the face to determine the side on which to create a neighbor - _mouseVoxel.x += faceVector.x * _mouseVoxel.s; - _mouseVoxel.y += faceVector.y * _mouseVoxel.s; - _mouseVoxel.z += faceVector.z * _mouseVoxel.s; - } - } - } else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) { - // place the voxel a fixed distance away - float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; - glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); - _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale); - _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale); - _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale); - _mouseVoxel.s = _mouseVoxelScale; - } - - if (_deleteVoxelMode->isChecked()) { - // red indicates deletion - _mouseVoxel.red = 255; - _mouseVoxel.green = _mouseVoxel.blue = 0; - } else if (_selectVoxelMode->isChecked()) { - // yellow indicates deletion - _mouseVoxel.red = _mouseVoxel.green = 255; - _mouseVoxel.blue = 0; - } else { // _addVoxelMode->isChecked() || _colorVoxelMode->isChecked() - QColor paintColor = _voxelPaintColor->data().value(); - _mouseVoxel.red = paintColor.red(); - _mouseVoxel.green = paintColor.green(); - _mouseVoxel.blue = paintColor.blue(); - } - - // if we just edited, use the currently selected voxel as the "last" for drag detection - if (_justEditedVoxel) { - _lastMouseVoxelPos = glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); - _justEditedVoxel = false; - } - } - - // walking triggers the handControl to stop - if (_myAvatar.getMode() == AVATAR_MODE_WALKING) { - _handControl.stop(); - } - - // Update from Mouse - if (_mouseLook->isChecked()) { - QPoint mouse = QCursor::pos(); - _myAvatar.updateFromMouse(_glWidget->mapFromGlobal(mouse).x(), - _glWidget->mapFromGlobal(mouse).y(), - _glWidget->width(), - _glWidget->height()); - } - - // Read serial port interface devices - if (_serialHeadSensor.active) { - _serialHeadSensor.readData(deltaTime); - } - - // Update transmitter - - // Sample hardware, update view frustum if needed, and send avatar data to mixer/agents - updateAvatar(deltaTime); - - // read incoming packets from network - if (!_enableNetworkThread) { - networkReceive(0); - } - - //loop through all the other avatars and simulate them... - AgentList* agentList = AgentList::getInstance(); - agentList->lock(); - for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { - if (agent->getLinkedData() != NULL) { - Avatar *avatar = (Avatar *)agent->getLinkedData(); - if (!avatar->isInitialized()) { - avatar->init(); - } - avatar->simulate(deltaTime, NULL); - avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); - } - } - agentList->unlock(); - - // Simulate myself - _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition())); - if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) { - _myAvatar.simulate(deltaTime, &_myTransmitter); - } else { - _myAvatar.simulate(deltaTime, NULL); - } - - if (TESTING_AVATAR_TOUCH) { - if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { - _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); - _myCamera.setModeShiftRate(1.0f); - } - } else { - if (_myCamera.getMode() != CAMERA_MODE_MIRROR && !OculusManager::isConnected()) { - if (_manualFirstPerson) { - if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON ) { - _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); - _myCamera.setModeShiftRate(1.0f); - } - } else { - if (_myAvatar.getIsNearInteractingOther()) { - if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { - _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); - _myCamera.setModeShiftRate(1.0f); - } - } else { - if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { - _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); - _myCamera.setModeShiftRate(1.0f); - } - } - } - } - } - - // Update audio stats for procedural sounds - #ifndef _WIN32 - _audio.setLastAcceleration(_myAvatar.getThrust()); - _audio.setLastVelocity(_myAvatar.getVelocity()); - #endif + update(1.0f / _fps); _glWidget->updateGL(); _lastTimeIdle = check; @@ -1549,6 +1378,181 @@ void Application::init() { sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); } +void Application::update(float deltaTime) { + // Use Transmitter Hand to move hand if connected, else use mouse + if (_myTransmitter.isConnected()) { + const float HAND_FORCE_SCALING = 0.01f; + glm::vec3 estimatedRotation = _myTransmitter.getEstimatedRotation(); + glm::vec3 handForce(-estimatedRotation.z, -estimatedRotation.x, estimatedRotation.y); + _myAvatar.setMovedHandOffset(handForce * HAND_FORCE_SCALING); + } else { + // update behaviors for avatar hand movement: handControl takes mouse values as input, + // and gives back 3D values modulated for smooth transitioning between interaction modes. + _handControl.update(_mouseX, _mouseY); + _myAvatar.setMovedHandOffset(_handControl.getValues()); + } + + // tell my avatar if the mouse is being pressed... + _myAvatar.setMousePressed(_mousePressed); + + // check what's under the mouse and update the mouse voxel + glm::vec3 mouseRayOrigin, mouseRayDirection; + _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), + _mouseY / (float)_glWidget->height(), mouseRayOrigin, mouseRayDirection); + + // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position + _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection); + + _mouseVoxel.s = 0.0f; + if (checkedVoxelModeAction() != 0) { + float distance; + BoxFace face; + if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) { + // find the nearest voxel with the desired scale + if (_mouseVoxelScale > _mouseVoxel.s) { + // choose the larger voxel that encompasses the one selected + _mouseVoxel.x = _mouseVoxelScale * floorf(_mouseVoxel.x / _mouseVoxelScale); + _mouseVoxel.y = _mouseVoxelScale * floorf(_mouseVoxel.y / _mouseVoxelScale); + _mouseVoxel.z = _mouseVoxelScale * floorf(_mouseVoxel.z / _mouseVoxelScale); + _mouseVoxel.s = _mouseVoxelScale; + + } else { + glm::vec3 faceVector = getFaceVector(face); + if (_mouseVoxelScale < _mouseVoxel.s) { + // find the closest contained voxel + glm::vec3 pt = (mouseRayOrigin + mouseRayDirection * distance) / (float)TREE_SCALE - + faceVector * (_mouseVoxelScale * 0.5f); + _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale); + _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale); + _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / _mouseVoxelScale); + _mouseVoxel.s = _mouseVoxelScale; + } + if (_addVoxelMode->isChecked()) { + // use the face to determine the side on which to create a neighbor + _mouseVoxel.x += faceVector.x * _mouseVoxel.s; + _mouseVoxel.y += faceVector.y * _mouseVoxel.s; + _mouseVoxel.z += faceVector.z * _mouseVoxel.s; + } + } + } else if (_addVoxelMode->isChecked() || _selectVoxelMode->isChecked()) { + // place the voxel a fixed distance away + float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; + glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); + _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale); + _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale); + _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale); + _mouseVoxel.s = _mouseVoxelScale; + } + + if (_deleteVoxelMode->isChecked()) { + // red indicates deletion + _mouseVoxel.red = 255; + _mouseVoxel.green = _mouseVoxel.blue = 0; + } else if (_selectVoxelMode->isChecked()) { + // yellow indicates deletion + _mouseVoxel.red = _mouseVoxel.green = 255; + _mouseVoxel.blue = 0; + } else { // _addVoxelMode->isChecked() || _colorVoxelMode->isChecked() + QColor paintColor = _voxelPaintColor->data().value(); + _mouseVoxel.red = paintColor.red(); + _mouseVoxel.green = paintColor.green(); + _mouseVoxel.blue = paintColor.blue(); + } + + // if we just edited, use the currently selected voxel as the "last" for drag detection + if (_justEditedVoxel) { + _lastMouseVoxelPos = glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z); + _justEditedVoxel = false; + } + } + + // walking triggers the handControl to stop + if (_myAvatar.getMode() == AVATAR_MODE_WALKING) { + _handControl.stop(); + } + + // Update from Mouse + if (_mouseLook->isChecked()) { + QPoint mouse = QCursor::pos(); + _myAvatar.updateFromMouse(_glWidget->mapFromGlobal(mouse).x(), + _glWidget->mapFromGlobal(mouse).y(), + _glWidget->width(), + _glWidget->height()); + } + + // Read serial port interface devices + if (_serialHeadSensor.active) { + _serialHeadSensor.readData(deltaTime); + } + + // Update transmitter + + // Sample hardware, update view frustum if needed, and send avatar data to mixer/agents + updateAvatar(deltaTime); + + // read incoming packets from network + if (!_enableNetworkThread) { + networkReceive(0); + } + + //loop through all the other avatars and simulate them... + AgentList* agentList = AgentList::getInstance(); + agentList->lock(); + for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { + if (agent->getLinkedData() != NULL) { + Avatar *avatar = (Avatar *)agent->getLinkedData(); + if (!avatar->isInitialized()) { + avatar->init(); + } + avatar->simulate(deltaTime, NULL); + avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); + } + } + agentList->unlock(); + + // Simulate myself + _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition())); + if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) { + _myAvatar.simulate(deltaTime, &_myTransmitter); + } else { + _myAvatar.simulate(deltaTime, NULL); + } + + if (TESTING_AVATAR_TOUCH) { + if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { + _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); + _myCamera.setModeShiftRate(1.0f); + } + } else { + if (_myCamera.getMode() != CAMERA_MODE_MIRROR && !OculusManager::isConnected()) { + if (_manualFirstPerson) { + if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON ) { + _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); + _myCamera.setModeShiftRate(1.0f); + } + } else { + if (_myAvatar.getIsNearInteractingOther()) { + if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { + _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); + _myCamera.setModeShiftRate(1.0f); + } + } else { + if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { + _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); + _myCamera.setModeShiftRate(1.0f); + } + } + } + } + } + + // Update audio stats for procedural sounds + #ifndef _WIN32 + _audio.setLastAcceleration(_myAvatar.getThrust()); + _audio.setLastVelocity(_myAvatar.getVelocity()); + #endif +} + void Application::updateAvatar(float deltaTime) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 2316f23dc0..53807e993e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -131,6 +131,7 @@ private: void initDisplay(); void init(); + void update(float deltaTime); void updateAvatar(float deltaTime); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum); diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 9fc0033fc4..84655226d8 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -71,7 +71,7 @@ void Camera::updateFollowMode(float deltaTime) { _distance = _previousDistance * (1.0f - _modeShift) + _newDistance * _modeShift; _tightness = _previousTightness * (1.0f - _modeShift) + _newTightness * _modeShift; - if (_linearModeShift > 1.0f ) { + if (_needsToInitialize || _linearModeShift > 1.0f) { _linearModeShift = 1.0f; _modeShift = 1.0f; _upShift = _newUpShift;