From f4af0be95b1e1fe400b7ae284ad08e1dfcbff368 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 21 Apr 2021 10:14:46 +1200 Subject: [PATCH] Conditionally apply ReadyPlayerMe synonyms --- .../model-serializers/src/GLTFSerializer.cpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/libraries/model-serializers/src/GLTFSerializer.cpp b/libraries/model-serializers/src/GLTFSerializer.cpp index 1c1e45fbf3..dd9471f77b 100755 --- a/libraries/model-serializers/src/GLTFSerializer.cpp +++ b/libraries/model-serializers/src/GLTFSerializer.cpp @@ -1571,17 +1571,30 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash& } } - // Augment list of blendshapes from synonyms in model. - QMap>::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>::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.