mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-15 05:30:10 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into word-align--memorystorage
This commit is contained in:
commit
19401af3e1
6 changed files with 44 additions and 41 deletions
|
@ -48,7 +48,7 @@ void MyHead::simulate(float deltaTime) {
|
|||
FaceTracker* faceTracker = qApp->getActiveFaceTracker();
|
||||
_isFaceTrackerConnected = faceTracker != NULL && !faceTracker->isMuted();
|
||||
if (_isFaceTrackerConnected) {
|
||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||
_transientBlendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||
|
||||
if (typeid(*faceTracker) == typeid(DdeFaceTracker)) {
|
||||
|
||||
|
@ -60,11 +60,11 @@ void MyHead::simulate(float deltaTime) {
|
|||
const int FUNNEL_BLENDSHAPE = 40;
|
||||
const int SMILE_LEFT_BLENDSHAPE = 28;
|
||||
const int SMILE_RIGHT_BLENDSHAPE = 29;
|
||||
_blendshapeCoefficients[JAW_OPEN_BLENDSHAPE] += _audioJawOpen;
|
||||
_blendshapeCoefficients[SMILE_LEFT_BLENDSHAPE] += _mouth4;
|
||||
_blendshapeCoefficients[SMILE_RIGHT_BLENDSHAPE] += _mouth4;
|
||||
_blendshapeCoefficients[MMMM_BLENDSHAPE] += _mouth2;
|
||||
_blendshapeCoefficients[FUNNEL_BLENDSHAPE] += _mouth3;
|
||||
_transientBlendshapeCoefficients[JAW_OPEN_BLENDSHAPE] += _audioJawOpen;
|
||||
_transientBlendshapeCoefficients[SMILE_LEFT_BLENDSHAPE] += _mouth4;
|
||||
_transientBlendshapeCoefficients[SMILE_RIGHT_BLENDSHAPE] += _mouth4;
|
||||
_transientBlendshapeCoefficients[MMMM_BLENDSHAPE] += _mouth2;
|
||||
_transientBlendshapeCoefficients[FUNNEL_BLENDSHAPE] += _mouth3;
|
||||
}
|
||||
applyEyelidOffset(getFinalOrientationInWorldFrame());
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ void Head::simulate(float deltaTime) {
|
|||
_mouth2,
|
||||
_mouth3,
|
||||
_mouth4,
|
||||
_blendshapeCoefficients);
|
||||
_transientBlendshapeCoefficients);
|
||||
|
||||
applyEyelidOffset(getOrientation());
|
||||
|
||||
|
@ -234,15 +234,15 @@ void Head::applyEyelidOffset(glm::quat headOrientation) {
|
|||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
const int LEFT_EYE = 8;
|
||||
float eyeCoefficient = _blendshapeCoefficients[i] - _blendshapeCoefficients[LEFT_EYE + i]; // Raw value
|
||||
float eyeCoefficient = _transientBlendshapeCoefficients[i] - _transientBlendshapeCoefficients[LEFT_EYE + i];
|
||||
eyeCoefficient = glm::clamp(eyelidOffset + eyeCoefficient * (1.0f - eyelidOffset), -1.0f, 1.0f);
|
||||
if (eyeCoefficient > 0.0f) {
|
||||
_blendshapeCoefficients[i] = eyeCoefficient;
|
||||
_blendshapeCoefficients[LEFT_EYE + i] = 0.0f;
|
||||
_transientBlendshapeCoefficients[i] = eyeCoefficient;
|
||||
_transientBlendshapeCoefficients[LEFT_EYE + i] = 0.0f;
|
||||
|
||||
} else {
|
||||
_blendshapeCoefficients[i] = 0.0f;
|
||||
_blendshapeCoefficients[LEFT_EYE + i] = -eyeCoefficient;
|
||||
_transientBlendshapeCoefficients[i] = 0.0f;
|
||||
_transientBlendshapeCoefficients[LEFT_EYE + i] = -eyeCoefficient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -445,17 +445,17 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
|||
if (hasFaceTrackerInfo) {
|
||||
auto startSection = destinationBuffer;
|
||||
auto faceTrackerInfo = reinterpret_cast<AvatarDataPacket::FaceTrackerInfo*>(destinationBuffer);
|
||||
auto blendshapeCoefficients = _headData->getSummedBlendshapeCoefficients();
|
||||
|
||||
faceTrackerInfo->leftEyeBlink = _headData->_leftEyeBlink;
|
||||
faceTrackerInfo->rightEyeBlink = _headData->_rightEyeBlink;
|
||||
faceTrackerInfo->averageLoudness = _headData->_averageLoudness;
|
||||
faceTrackerInfo->browAudioLift = _headData->_browAudioLift;
|
||||
faceTrackerInfo->numBlendshapeCoefficients = _headData->_blendshapeCoefficients.size();
|
||||
faceTrackerInfo->numBlendshapeCoefficients = blendshapeCoefficients.size();
|
||||
destinationBuffer += sizeof(AvatarDataPacket::FaceTrackerInfo);
|
||||
|
||||
// followed by a variable number of float coefficients
|
||||
memcpy(destinationBuffer, _headData->_blendshapeCoefficients.data(), _headData->_blendshapeCoefficients.size() * sizeof(float));
|
||||
destinationBuffer += _headData->_blendshapeCoefficients.size() * sizeof(float);
|
||||
memcpy(destinationBuffer, blendshapeCoefficients.data(), blendshapeCoefficients.size() * sizeof(float));
|
||||
destinationBuffer += blendshapeCoefficients.size() * sizeof(float);
|
||||
|
||||
int numBytes = destinationBuffer - startSection;
|
||||
if (outboundDataRateOut) {
|
||||
|
@ -965,7 +965,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
const int coefficientsSize = sizeof(float) * numCoefficients;
|
||||
PACKET_READ_CHECK(FaceTrackerCoefficients, coefficientsSize);
|
||||
_headData->_blendshapeCoefficients.resize(numCoefficients); // make sure there's room for the copy!
|
||||
_headData->_baseBlendshapeCoefficients.resize(numCoefficients);
|
||||
_headData->_transientBlendshapeCoefficients.resize(numCoefficients);
|
||||
memcpy(_headData->_blendshapeCoefficients.data(), sourceBuffer, coefficientsSize);
|
||||
sourceBuffer += coefficientsSize;
|
||||
int numBytesRead = sourceBuffer - startSection;
|
||||
|
|
|
@ -34,8 +34,9 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
|||
_rightEyeBlink(0.0f),
|
||||
_averageLoudness(0.0f),
|
||||
_browAudioLift(0.0f),
|
||||
_baseBlendshapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_currBlendShapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_blendshapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_transientBlendshapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_summedBlendshapeCoefficients(QVector<float>(0, 0.0f)),
|
||||
_owningAvatar(owningAvatar)
|
||||
{
|
||||
|
||||
|
@ -85,22 +86,22 @@ static const QMap<QString, int>& getBlendshapesLookupMap() {
|
|||
}
|
||||
|
||||
const QVector<float>& HeadData::getSummedBlendshapeCoefficients() {
|
||||
int maxSize = std::max(_baseBlendshapeCoefficients.size(), _blendshapeCoefficients.size());
|
||||
if (_currBlendShapeCoefficients.size() != maxSize) {
|
||||
_currBlendShapeCoefficients.resize(maxSize);
|
||||
int maxSize = std::max(_blendshapeCoefficients.size(), _transientBlendshapeCoefficients.size());
|
||||
if (_summedBlendshapeCoefficients.size() != maxSize) {
|
||||
_summedBlendshapeCoefficients.resize(maxSize);
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxSize; i++) {
|
||||
if (i >= _baseBlendshapeCoefficients.size()) {
|
||||
_currBlendShapeCoefficients[i] = _blendshapeCoefficients[i];
|
||||
} else if (i >= _blendshapeCoefficients.size()) {
|
||||
_currBlendShapeCoefficients[i] = _baseBlendshapeCoefficients[i];
|
||||
if (i >= _blendshapeCoefficients.size()) {
|
||||
_summedBlendshapeCoefficients[i] = _transientBlendshapeCoefficients[i];
|
||||
} else if (i >= _transientBlendshapeCoefficients.size()) {
|
||||
_summedBlendshapeCoefficients[i] = _blendshapeCoefficients[i];
|
||||
} else {
|
||||
_currBlendShapeCoefficients[i] = _baseBlendshapeCoefficients[i] + _blendshapeCoefficients[i];
|
||||
_summedBlendshapeCoefficients[i] = _blendshapeCoefficients[i] + _transientBlendshapeCoefficients[i];
|
||||
}
|
||||
}
|
||||
|
||||
return _currBlendShapeCoefficients;
|
||||
return _summedBlendshapeCoefficients;
|
||||
}
|
||||
|
||||
void HeadData::setBlendshape(QString name, float val) {
|
||||
|
@ -112,10 +113,10 @@ void HeadData::setBlendshape(QString name, float val) {
|
|||
if (_blendshapeCoefficients.size() <= it.value()) {
|
||||
_blendshapeCoefficients.resize(it.value() + 1);
|
||||
}
|
||||
if (_baseBlendshapeCoefficients.size() <= it.value()) {
|
||||
_baseBlendshapeCoefficients.resize(it.value() + 1);
|
||||
if (_transientBlendshapeCoefficients.size() <= it.value()) {
|
||||
_transientBlendshapeCoefficients.resize(it.value() + 1);
|
||||
}
|
||||
_baseBlendshapeCoefficients[it.value()] = val;
|
||||
_blendshapeCoefficients[it.value()] = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,14 +132,16 @@ QJsonObject HeadData::toJson() const {
|
|||
QJsonObject blendshapesJson;
|
||||
for (auto name : blendshapeLookupMap.keys()) {
|
||||
auto index = blendshapeLookupMap[name];
|
||||
if (index >= _blendshapeCoefficients.size()) {
|
||||
continue;
|
||||
float value = 0.0f;
|
||||
if (index < _blendshapeCoefficients.size()) {
|
||||
value += _blendshapeCoefficients[index];
|
||||
}
|
||||
auto value = _blendshapeCoefficients[index];
|
||||
if (value == 0.0f) {
|
||||
continue;
|
||||
if (index < _transientBlendshapeCoefficients.size()) {
|
||||
value += _transientBlendshapeCoefficients[index];
|
||||
}
|
||||
if (value != 0.0f) {
|
||||
blendshapesJson[name] = value;
|
||||
}
|
||||
blendshapesJson[name] = value;
|
||||
}
|
||||
if (!blendshapesJson.isEmpty()) {
|
||||
headJson[JSON_AVATAR_HEAD_BLENDSHAPE_COEFFICIENTS] = blendshapesJson;
|
||||
|
@ -163,8 +166,8 @@ void HeadData::fromJson(const QJsonObject& json) {
|
|||
QJsonArray blendshapeCoefficientsJson = jsonValue.toArray();
|
||||
for (const auto& blendshapeCoefficient : blendshapeCoefficientsJson) {
|
||||
blendshapeCoefficients.push_back((float)blendshapeCoefficient.toDouble());
|
||||
setBlendshapeCoefficients(blendshapeCoefficients);
|
||||
}
|
||||
setBlendshapeCoefficients(blendshapeCoefficients);
|
||||
} else if (jsonValue.isObject()) {
|
||||
QJsonObject blendshapeCoefficientsJson = jsonValue.toObject();
|
||||
for (const QString& name : blendshapeCoefficientsJson.keys()) {
|
||||
|
|
|
@ -93,8 +93,8 @@ protected:
|
|||
float _browAudioLift;
|
||||
|
||||
QVector<float> _blendshapeCoefficients;
|
||||
QVector<float> _baseBlendshapeCoefficients;
|
||||
QVector<float> _currBlendShapeCoefficients;
|
||||
QVector<float> _transientBlendshapeCoefficients;
|
||||
QVector<float> _summedBlendshapeCoefficients;
|
||||
AvatarData* _owningAvatar;
|
||||
|
||||
private:
|
||||
|
|
|
@ -111,7 +111,7 @@ function onMessage(message) {
|
|||
case 'openSettings':
|
||||
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
||||
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", true))) {
|
||||
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "General Preferences");
|
||||
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");
|
||||
} else {
|
||||
tablet.loadQMLOnTop("TabletGeneralPreferences.qml");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue