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. // If an FST isn't being used and the model is likely from ReadyPlayerMe, add blendshape synonyms.
QMap<QString, QPair<QString, float>>::const_iterator synonym = READYPLAYERME_BLENDSHAPES_MAP.constBegin(); auto fileTargetNames = _file.meshes[node.mesh].extras.targetNames;
while (synonym != READYPLAYERME_BLENDSHAPES_MAP.constEnd()) { bool likelyReadyPlayerMeFile =
if (_file.meshes[node.mesh].extras.targetNames.contains(synonym.key())) { fileTargetNames.contains("browOuterUpLeft")
auto blendshape = BLENDSHAPE_LOOKUP_MAP.find(synonym.value().first); && fileTargetNames.contains("browInnerUp")
if (blendshape != BLENDSHAPE_LOOKUP_MAP.end()) { && fileTargetNames.contains("browDownLeft")
blendshapeIndices.insert(synonym.key(), && fileTargetNames.contains("eyeBlinkLeft")
WeightedIndex(blendshape.value(), synonym.value().second)); && 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. // Create blendshapes.