mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 19:20:16 +02:00
Wait until we know that Faceshift didn't connect before we attempt to
initialize Visage.
This commit is contained in:
parent
007bfa8866
commit
9d1278b663
7 changed files with 35 additions and 5 deletions
|
@ -14,12 +14,12 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Application.cpp" line="3557"/>
|
<location filename="src/Application.cpp" line="3560"/>
|
||||||
<source>Open Script</source>
|
<source>Open Script</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Application.cpp" line="3558"/>
|
<location filename="src/Application.cpp" line="3561"/>
|
||||||
<source>JavaScript Files (*.js)</source>
|
<source>JavaScript Files (*.js)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -1525,6 +1525,9 @@ void Application::init() {
|
||||||
}
|
}
|
||||||
qDebug("Loaded settings");
|
qDebug("Loaded settings");
|
||||||
|
|
||||||
|
// initialize Visage after loading the menu settings
|
||||||
|
_visage.init();
|
||||||
|
|
||||||
// fire off an immediate domain-server check in now that settings are loaded
|
// fire off an immediate domain-server check in now that settings are loaded
|
||||||
NodeList::getInstance()->sendDomainServerCheckIn();
|
NodeList::getInstance()->sendDomainServerCheckIn();
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ Menu::Menu() :
|
||||||
SLOT(setTCPEnabled(bool)));
|
SLOT(setTCPEnabled(bool)));
|
||||||
#ifdef HAVE_VISAGE
|
#ifdef HAVE_VISAGE
|
||||||
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Visage, 0, true,
|
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Visage, 0, true,
|
||||||
appInstance->getVisage(), SLOT(setEnabled(bool)));
|
appInstance->getVisage(), SLOT(updateEnabled()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false);
|
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false);
|
||||||
|
|
|
@ -49,12 +49,18 @@ Faceshift::Faceshift() :
|
||||||
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
|
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
|
||||||
connect(&_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(noteError(QAbstractSocket::SocketError)));
|
connect(&_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(noteError(QAbstractSocket::SocketError)));
|
||||||
connect(&_tcpSocket, SIGNAL(readyRead()), SLOT(readFromSocket()));
|
connect(&_tcpSocket, SIGNAL(readyRead()), SLOT(readFromSocket()));
|
||||||
|
connect(&_tcpSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SIGNAL(connectionStateChanged()));
|
||||||
|
|
||||||
connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams()));
|
connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams()));
|
||||||
|
|
||||||
_udpSocket.bind(FACESHIFT_PORT);
|
_udpSocket.bind(FACESHIFT_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Faceshift::isConnectedOrConnecting() const {
|
||||||
|
return _tcpSocket.state() == QAbstractSocket::ConnectedState ||
|
||||||
|
(_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState);
|
||||||
|
}
|
||||||
|
|
||||||
bool Faceshift::isActive() const {
|
bool Faceshift::isActive() const {
|
||||||
const quint64 ACTIVE_TIMEOUT_USECS = 1000000;
|
const quint64 ACTIVE_TIMEOUT_USECS = 1000000;
|
||||||
return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS;
|
return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS;
|
||||||
|
|
|
@ -27,6 +27,8 @@ public:
|
||||||
|
|
||||||
Faceshift();
|
Faceshift();
|
||||||
|
|
||||||
|
bool isConnectedOrConnecting() const;
|
||||||
|
|
||||||
bool isActive() const;
|
bool isActive() const;
|
||||||
|
|
||||||
const glm::quat& getHeadRotation() const { return _headRotation; }
|
const glm::quat& getHeadRotation() const { return _headRotation; }
|
||||||
|
@ -66,6 +68,10 @@ public:
|
||||||
void updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
|
void updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
|
||||||
float jawOpen, std::vector<float>& coefficients) const;
|
float jawOpen, std::vector<float>& coefficients) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void connectionStateChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setTCPEnabled(bool enabled);
|
void setTCPEnabled(bool enabled);
|
||||||
|
|
|
@ -109,6 +109,11 @@ static const QMultiHash<QByteArray, QPair<int, float> >& getActionUnitNameMap()
|
||||||
|
|
||||||
const float TRANSLATION_SCALE = 20.0f;
|
const float TRANSLATION_SCALE = 20.0f;
|
||||||
|
|
||||||
|
void Visage::init() {
|
||||||
|
connect(Application::getInstance()->getFaceshift(), SIGNAL(connectionStateChanged()), SLOT(updateEnabled()));
|
||||||
|
updateEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
void Visage::update() {
|
void Visage::update() {
|
||||||
#ifdef HAVE_VISAGE
|
#ifdef HAVE_VISAGE
|
||||||
_active = (_tracker->getTrackingData(_data) == TRACK_STAT_OK);
|
_active = (_tracker->getTrackingData(_data) == TRACK_STAT_OK);
|
||||||
|
@ -153,12 +158,18 @@ void Visage::reset() {
|
||||||
_headOrigin += _headTranslation / TRANSLATION_SCALE;
|
_headOrigin += _headTranslation / TRANSLATION_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Visage::updateEnabled() {
|
||||||
|
setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Visage) &&
|
||||||
|
!(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift) &&
|
||||||
|
Application::getInstance()->getFaceshift()->isConnectedOrConnecting()));
|
||||||
|
}
|
||||||
|
|
||||||
void Visage::setEnabled(bool enabled) {
|
void Visage::setEnabled(bool enabled) {
|
||||||
#ifdef HAVE_VISAGE
|
#ifdef HAVE_VISAGE
|
||||||
if (_enabled == enabled) {
|
if (_enabled == enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_enabled = enabled) {
|
if ((_enabled = enabled)) {
|
||||||
_tracker->trackFromCam();
|
_tracker->trackFromCam();
|
||||||
} else {
|
} else {
|
||||||
_tracker->stop();
|
_tracker->stop();
|
||||||
|
|
|
@ -32,6 +32,8 @@ public:
|
||||||
Visage();
|
Visage();
|
||||||
virtual ~Visage();
|
virtual ~Visage();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
bool isActive() const { return _active; }
|
bool isActive() const { return _active; }
|
||||||
|
|
||||||
const glm::quat& getHeadRotation() const { return _headRotation; }
|
const glm::quat& getHeadRotation() const { return _headRotation; }
|
||||||
|
@ -47,7 +49,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setEnabled(bool enabled);
|
void updateEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -57,6 +59,8 @@ private:
|
||||||
QMultiHash<int, QPair<int, float> > _actionUnitIndexMap;
|
QMultiHash<int, QPair<int, float> > _actionUnitIndexMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
bool _active;
|
bool _active;
|
||||||
glm::quat _headRotation;
|
glm::quat _headRotation;
|
||||||
|
|
Loading…
Reference in a new issue