Sum of blendshapes is used for recording

This commit is contained in:
David Rowe 2017-05-11 18:17:12 +12:00
parent 1b855f2c6b
commit 21f9594f81

View file

@ -132,15 +132,17 @@ QJsonObject HeadData::toJson() const {
QJsonObject blendshapesJson; QJsonObject blendshapesJson;
for (auto name : blendshapeLookupMap.keys()) { for (auto name : blendshapeLookupMap.keys()) {
auto index = blendshapeLookupMap[name]; auto index = blendshapeLookupMap[name];
if (index >= _blendshapeCoefficients.size()) { float value = 0.0f;
continue; if (index < _blendshapeCoefficients.size()) {
value += _blendshapeCoefficients[index];
} }
auto value = _blendshapeCoefficients[index]; if (index < _transientBlendshapeCoefficients.size()) {
if (value == 0.0f) { value += _transientBlendshapeCoefficients[index];
continue;
} }
if (value != 0.0f) {
blendshapesJson[name] = value; blendshapesJson[name] = value;
} }
}
if (!blendshapesJson.isEmpty()) { if (!blendshapesJson.isEmpty()) {
headJson[JSON_AVATAR_HEAD_BLENDSHAPE_COEFFICIENTS] = blendshapesJson; headJson[JSON_AVATAR_HEAD_BLENDSHAPE_COEFFICIENTS] = blendshapesJson;
} }
@ -164,8 +166,8 @@ void HeadData::fromJson(const QJsonObject& json) {
QJsonArray blendshapeCoefficientsJson = jsonValue.toArray(); QJsonArray blendshapeCoefficientsJson = jsonValue.toArray();
for (const auto& blendshapeCoefficient : blendshapeCoefficientsJson) { for (const auto& blendshapeCoefficient : blendshapeCoefficientsJson) {
blendshapeCoefficients.push_back((float)blendshapeCoefficient.toDouble()); blendshapeCoefficients.push_back((float)blendshapeCoefficient.toDouble());
setBlendshapeCoefficients(blendshapeCoefficients);
} }
setBlendshapeCoefficients(blendshapeCoefficients);
} else if (jsonValue.isObject()) { } else if (jsonValue.isObject()) {
QJsonObject blendshapeCoefficientsJson = jsonValue.toObject(); QJsonObject blendshapeCoefficientsJson = jsonValue.toObject();
for (const QString& name : blendshapeCoefficientsJson.keys()) { for (const QString& name : blendshapeCoefficientsJson.keys()) {