further patching to conditionally build without Faceshift

This commit is contained in:
Stephen Birarda 2014-07-18 14:34:15 -07:00
parent b2a99edb2e
commit 10ed33cb38
2 changed files with 24 additions and 25 deletions

View file

@ -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
}

View file

@ -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