From ef5cfdc3abecce59a4e31d77ba5b3c1d086dd778 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sat, 17 Jan 2015 21:35:25 -0800 Subject: [PATCH] Move Faceshift related member out of Menu Moved it to Faceshift class --- interface/src/Application.cpp | 2 +- interface/src/Menu.cpp | 5 +---- interface/src/Menu.h | 7 ------- interface/src/devices/Faceshift.cpp | 2 +- interface/src/devices/Faceshift.h | 9 +++++++++ interface/src/ui/PreferencesDialog.cpp | 16 ++++++++++------ 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1c1a57f3a7..5ebbd7a8dd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1893,7 +1893,7 @@ void Application::updateMyAvatarLookAtPosition() { // deflect using Faceshift gaze data glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; - float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); + float deflection = DependencyManager::get()->getEyeDeflection(); if (isLookingAtSomeone) { deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT; } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 62b607fdd1..6af174585a 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -44,6 +44,7 @@ #include "Audio.h" #include "audio/AudioIOStatsRenderer.h" #include "audio/AudioScope.h" +#include "devices/Faceshift.h" #include "devices/RealSense.h" #include "devices/Visage.h" #include "Menu.h" @@ -591,8 +592,6 @@ void Menu::loadSettings(QSettings* settings) { _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); _realWorldFieldOfView = loadSetting(settings, "realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES); - _faceshiftEyeDeflection = loadSetting(settings, "faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION); - _faceshiftHostname = settings->value("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME).toString(); _maxOctreePacketsPerSecond = loadSetting(settings, "maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); _snapshotsLocation = settings->value("snapshotsLocation", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString(); @@ -638,8 +637,6 @@ void Menu::saveSettings(QSettings* settings) { settings->setValue("audioOutputBufferSize", audio->getOutputBufferSize()); settings->setValue("fieldOfView", _fieldOfView); - settings->setValue("faceshiftEyeDeflection", _faceshiftEyeDeflection); - settings->setValue("faceshiftHostname", _faceshiftHostname); settings->setValue("maxOctreePPS", _maxOctreePacketsPerSecond); settings->setValue("snapshotsLocation", _snapshotsLocation); settings->setValue("scriptsLocation", _scriptsLocation); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 881a3c9a4d..d17f82de9d 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -26,7 +26,6 @@ #include "SpeechRecognizer.h" #endif -#include "devices/Faceshift.h" #include "devices/SixenseManager.h" #include "ui/ChatWindow.h" #include "ui/JSConsole.h" @@ -141,10 +140,6 @@ public: bool getInvertSixenseButtons() const { return _invertSixenseButtons; } void setInvertSixenseButtons(bool invertSixenseButtons) { _invertSixenseButtons = invertSixenseButtons; bumpSettings(); } - float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; } - void setFaceshiftEyeDeflection(float faceshiftEyeDeflection) { _faceshiftEyeDeflection = faceshiftEyeDeflection; bumpSettings(); } - const QString& getFaceshiftHostname() const { return _faceshiftHostname; } - void setFaceshiftHostname(const QString& hostname) { _faceshiftHostname = hostname; bumpSettings(); } QString getSnapshotsLocation() const; void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; bumpSettings(); } @@ -215,8 +210,6 @@ private: float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES; // The actual FOV set by the user's monitor size and view distance float _realWorldFieldOfView = DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES; - float _faceshiftEyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION; - QString _faceshiftHostname = DEFAULT_FACESHIFT_HOSTNAME; QDialog* _jsConsole = nullptr; #if defined(Q_OS_MAC) || defined(Q_OS_WIN) diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 5c1bbfe709..164d6ee477 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -159,7 +159,7 @@ void Faceshift::connectSocket() { qDebug("Faceshift: Connecting..."); } - _tcpSocket.connectToHost(Menu::getInstance()->getFaceshiftHostname(), FACESHIFT_PORT); + _tcpSocket.connectToHost(_hostname, FACESHIFT_PORT); _tracking = false; } } diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index 466f2eaddf..f48309abf4 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -61,6 +61,12 @@ public: float getMouthSize() const { return getBlendshapeCoefficient(_jawOpenIndex); } float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); } float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); } + + float getEyeDeflection() const { return _eyeDeflection; } + void setEyeDeflection(float faceshiftEyeDeflection) { _eyeDeflection = faceshiftEyeDeflection; } + + const QString& getHostname() const { return _hostname; } + void setHostname(const QString& hostname) { _hostname = hostname; } void update(); void reset(); @@ -145,6 +151,9 @@ private: float _longTermAverageEyeYaw; bool _longTermAverageInitialized; + float _eyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION; + QString _hostname = DEFAULT_FACESHIFT_HOSTNAME; + }; #endif // hifi_Faceshift_h diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 4a5ac317e5..2ff572f24b 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -11,6 +11,8 @@ #include +#include + #include "Application.h" #include "Audio.h" #include "MainWindow.h" @@ -124,10 +126,11 @@ void PreferencesDialog::loadPreferences() { ui.pupilDilationSlider->setValue(myAvatar->getHead()->getPupilDilation() * ui.pupilDilationSlider->maximum()); - ui.faceshiftEyeDeflectionSider->setValue(menuInstance->getFaceshiftEyeDeflection() * + auto faceshift = DependencyManager::get(); + ui.faceshiftEyeDeflectionSider->setValue(faceshift->getEyeDeflection() * ui.faceshiftEyeDeflectionSider->maximum()); - ui.faceshiftHostnameEdit->setText(menuInstance->getFaceshiftHostname()); + ui.faceshiftHostnameEdit->setText(faceshift->getHostname()); auto audio = DependencyManager::get