Merge pull request #4353 from Atlante45/relax_face_tracker

Relax blendshapes
This commit is contained in:
Philip Rosedale 2015-02-27 13:36:22 -08:00
commit 9eee213bce
2 changed files with 20 additions and 3 deletions

View file

@ -9,10 +9,27 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <GLMHelpers.h>
#include "FaceTracker.h" #include "FaceTracker.h"
inline float FaceTracker::getBlendshapeCoefficient(int index) const { 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<float>& FaceTracker::getBlendshapeCoefficients() const {
static QVector<float> 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 { float FaceTracker::getFadeCoefficient() const {
@ -24,7 +41,7 @@ const glm::vec3 FaceTracker::getHeadTranslation() const {
} }
const glm::quat FaceTracker::getHeadRotation() 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) { void FaceTracker::update(float deltaTime) {

View file

@ -40,7 +40,7 @@ public:
int getNumBlendshapes() const { return _blendshapeCoefficients.size(); } int getNumBlendshapes() const { return _blendshapeCoefficients.size(); }
bool isValidBlendshapeIndex(int index) const { return index >= 0 && index < getNumBlendshapes(); } bool isValidBlendshapeIndex(int index) const { return index >= 0 && index < getNumBlendshapes(); }
const QVector<float>& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } const QVector<float>& getBlendshapeCoefficients() const;
float getBlendshapeCoefficient(int index) const; float getBlendshapeCoefficient(int index) const;
protected: protected: