diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp index d3e0600057..7c1c757ec1 100644 --- a/interface/src/devices/FaceTracker.cpp +++ b/interface/src/devices/FaceTracker.cpp @@ -9,10 +9,27 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "FaceTracker.h" inline float FaceTracker::getBlendshapeCoefficient(int index) const { - return isValidBlendshapeIndex(index) ? _blendshapeCoefficients[index] : 0.0f; + return isValidBlendshapeIndex(index) ? glm::mix(0.0f, _blendshapeCoefficients[index], getFadeCoefficient()) + : 0.0f; +} + +const QVector& FaceTracker::getBlendshapeCoefficients() const { + static QVector blendshapes; + float fadeCoefficient = getFadeCoefficient(); + if (fadeCoefficient == 1.0f) { + return _blendshapeCoefficients; + } else { + blendshapes.resize(_blendshapeCoefficients.size()); + for (int i = 0; i < _blendshapeCoefficients.size(); i++) { + blendshapes[i] = glm::mix(0.0f, _blendshapeCoefficients[i], fadeCoefficient); + } + return blendshapes; + } } float FaceTracker::getFadeCoefficient() const { @@ -24,7 +41,7 @@ const glm::vec3 FaceTracker::getHeadTranslation() const { } const glm::quat FaceTracker::getHeadRotation() const { - return glm::mix(glm::quat(), _headRotation, getFadeCoefficient()); + return safeMix(glm::quat(), _headRotation, getFadeCoefficient()); } void FaceTracker::update(float deltaTime) { diff --git a/interface/src/devices/FaceTracker.h b/interface/src/devices/FaceTracker.h index 1ec0468dec..362099aaf6 100644 --- a/interface/src/devices/FaceTracker.h +++ b/interface/src/devices/FaceTracker.h @@ -40,7 +40,7 @@ public: int getNumBlendshapes() const { return _blendshapeCoefficients.size(); } bool isValidBlendshapeIndex(int index) const { return index >= 0 && index < getNumBlendshapes(); } - const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } + const QVector& getBlendshapeCoefficients() const; float getBlendshapeCoefficient(int index) const; protected: