Conditionally apply ReadyPlayerMe synonyms

This commit is contained in:
David Rowe 2021-04-21 10:14:46 +12:00
parent a6d8e150f0
commit f4af0be95b

View file

@ -1571,17 +1571,30 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
}
}
// Augment list of blendshapes from synonyms in model.
QMap<QString, QPair<QString, float>>::const_iterator synonym = READYPLAYERME_BLENDSHAPES_MAP.constBegin();
while (synonym != READYPLAYERME_BLENDSHAPES_MAP.constEnd()) {
if (_file.meshes[node.mesh].extras.targetNames.contains(synonym.key())) {
auto blendshape = BLENDSHAPE_LOOKUP_MAP.find(synonym.value().first);
if (blendshape != BLENDSHAPE_LOOKUP_MAP.end()) {
blendshapeIndices.insert(synonym.key(),
WeightedIndex(blendshape.value(), synonym.value().second));
// If an FST isn't being used and the model is likely from ReadyPlayerMe, add blendshape synonyms.
auto fileTargetNames = _file.meshes[node.mesh].extras.targetNames;
bool likelyReadyPlayerMeFile =
fileTargetNames.contains("browOuterUpLeft")
&& fileTargetNames.contains("browInnerUp")
&& fileTargetNames.contains("browDownLeft")
&& fileTargetNames.contains("eyeBlinkLeft")
&& fileTargetNames.contains("eyeWideLeft")
&& fileTargetNames.contains("mouthLeft")
&& fileTargetNames.contains("viseme_O")
&& fileTargetNames.contains("mouthShrugLower");
if (fileTargetNames.count() == 0 && likelyReadyPlayerMeFile) {
QMap<QString, QPair<QString, float>>::const_iterator synonym
= READYPLAYERME_BLENDSHAPES_MAP.constBegin();
while (synonym != READYPLAYERME_BLENDSHAPES_MAP.constEnd()) {
if (fileTargetNames.contains(synonym.key())) {
auto blendshape = BLENDSHAPE_LOOKUP_MAP.find(synonym.value().first);
if (blendshape != BLENDSHAPE_LOOKUP_MAP.end()) {
blendshapeIndices.insert(synonym.key(),
WeightedIndex(blendshape.value(), synonym.value().second));
}
}
++synonym;
}
++synonym;
}
// Create blendshapes.