From 10ed33cb3811d7204df3a0b8d2072d51c04d6cc3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Jul 2014 14:34:15 -0700 Subject: [PATCH] further patching to conditionally build without Faceshift --- interface/src/devices/Faceshift.cpp | 42 ++++++++++++++--------------- interface/src/devices/Faceshift.h | 7 ++--- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 07e394f63f..9b2fc7e821 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -63,37 +63,31 @@ Faceshift::Faceshift() : _udpSocket.bind(FACESHIFT_PORT); } -void Faceshift::init() { - setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift)); -} - -bool Faceshift::isConnectedOrConnecting() const { - return _tcpSocket.state() == QAbstractSocket::ConnectedState || - (_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState); -} - -bool Faceshift::isActive() const { - const quint64 ACTIVE_TIMEOUT_USECS = 1000000; - return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS; -} - #else Faceshift::Faceshift() { } +#endif + +void Faceshift::init() { + setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift)); +} + bool Faceshift::isConnectedOrConnecting() const { - return false; + return _tcpSocket.state() == QAbstractSocket::ConnectedState || + (_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState); } bool Faceshift::isActive() const { - return false; -} - -#endif - #ifdef HAVE_FACESHIFT + const quint64 ACTIVE_TIMEOUT_USECS = 1000000; + return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS; +#else + return false; +#endif +} void Faceshift::update() { if (!isActive()) { @@ -120,12 +114,14 @@ void Faceshift::update() { } void Faceshift::reset() { +#ifdef HAVE_FACESHIFT if (_tcpSocket.state() == QAbstractSocket::ConnectedState) { string message; fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral()); send(message); } _longTermAverageInitialized = false; +#endif } void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp, @@ -161,11 +157,13 @@ void Faceshift::connectSocket() { } void Faceshift::noteConnected() { +#ifdef HAVE_FACESHIFT qDebug("Faceshift: Connected."); // request the list of blendshape names string message; fsBinaryStream::encode_message(message, fsMsgSendBlendshapeNames()); send(message); +#endif } void Faceshift::noteError(QAbstractSocket::SocketError error) { @@ -202,6 +200,7 @@ void Faceshift::send(const std::string& message) { } void Faceshift::receive(const QByteArray& buffer) { +#ifdef HAVE_FACESHIFT _stream.received(buffer.size(), buffer.constData()); fsMsgPtr msg; for (fsMsgPtr msg; (msg = _stream.get_message()); ) { @@ -282,6 +281,5 @@ void Faceshift::receive(const QByteArray& buffer) { break; } } -} - #endif +} diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index fd46be7567..c14bbed600 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -35,8 +35,6 @@ public: bool isConnectedOrConnecting() const; bool isActive() const; - -#ifdef HAVE_FACESHIFT const glm::vec3& getHeadAngularVelocity() const { return _headAngularVelocity; } @@ -93,7 +91,11 @@ private: QTcpSocket _tcpSocket; QUdpSocket _udpSocket; + +#ifdef HAVE_FACESHIFT fs::fsBinaryStream _stream; +#endif + bool _tcpEnabled; int _tcpRetryCount; bool _tracking; @@ -129,7 +131,6 @@ private: float _longTermAverageEyeYaw; bool _longTermAverageInitialized; -#endif // HAVE_FACESHIFT }; #endif // hifi_Faceshift_h