From 21f9594f81faf25a65c163ba1214ffa239f820c6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 11 May 2017 18:17:12 +1200 Subject: [PATCH] Sum of blendshapes is used for recording --- libraries/avatars/src/HeadData.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index d88b98b77e..78e87d7757 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -132,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; @@ -164,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()) {