Changes from CR and decreased looking at angle to mitigate freaky eyes

This commit is contained in:
luiscuenca 2018-06-29 14:34:17 -07:00
parent 2264425f9f
commit 24d03ace4c
6 changed files with 44 additions and 36 deletions

View file

@ -1434,9 +1434,9 @@ void Rig::updateEyeJoint(int index, const glm::vec3& modelTranslation, const glm
glm::quat deltaQuat = desiredQuat * glm::inverse(headQuat);
// limit swing rotation of the deltaQuat by a 30 degree cone.
// limit swing rotation of the deltaQuat by a 25 degree cone.
// TODO: use swing twist decomposition constraint instead, for off axis rotation clamping.
const float MAX_ANGLE = 30.0f * RADIANS_PER_DEGREE;
const float MAX_ANGLE = 25.0f * RADIANS_PER_DEGREE;
if (fabsf(glm::angle(deltaQuat)) > MAX_ANGLE) {
deltaQuat = glm::angleAxis(glm::clamp(glm::angle(deltaQuat), -MAX_ANGLE, MAX_ANGLE), glm::axis(deltaQuat));
}

View file

@ -225,10 +225,6 @@ void Head::applyEyelidOffset(glm::quat headOrientation) {
return;
}
const std::vector<QString> eyeBlinkBlendShapes = { "EyeBlink_L", "EyeBlink_R" };
const std::vector<QString> eyeOpenBlendShapes = { "EyeOpen_L", "EyeOpen_R" };
const std::vector<QString> browsBlendShapes = { "BrowsU_L", "BrowsU_R" };
const float EYE_PITCH_TO_COEFFICIENT = 3.5f; // Empirically determined
const float MAX_EYELID_OFFSET = 1.5f;
const float BLINK_DOWN_MULTIPLIER = 0.25f;
@ -236,40 +232,33 @@ void Head::applyEyelidOffset(glm::quat headOrientation) {
const float BROW_UP_MULTIPLIER = 0.5f;
glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FORWARD, getLookAtPosition() - _eyePosition);
eyeRotation = eyeRotation * glm::angleAxis(safeEulerAngles(headOrientation).y, IDENTITY_UP); // Rotation w.r.t. head
auto worldUpDirection = _owningAvatar->getWorldOrientation() * Vectors::UNIT_Y;
eyeRotation = eyeRotation * glm::angleAxis(safeEulerAngles(headOrientation).y, worldUpDirection); // Rotation w.r.t. head
float eyePitch = safeEulerAngles(eyeRotation).x;
float eyelidOffset = glm::clamp(abs(eyePitch * EYE_PITCH_TO_COEFFICIENT), 0.0f, MAX_EYELID_OFFSET);
std::vector<int> eyeBlinkIndices, eyeOpenIndices, browsIndices;
getBlendshapeIndices(eyeBlinkBlendShapes, eyeBlinkIndices);
getBlendshapeIndices(eyeOpenBlendShapes, eyeOpenIndices);
getBlendshapeIndices(browsBlendShapes, browsIndices);
float blinkUpCoefficient = -eyelidOffset;
float blinkDownCoefficient = BLINK_DOWN_MULTIPLIER * eyelidOffset;
float openUpCoefficient = eyelidOffset;
float openDownCoefficient = OPEN_DOWN_MULTIPLIER * eyelidOffset;
float browsUpCoefficient = BROW_UP_MULTIPLIER * eyelidOffset;
float browsDownCoefficient = 0.0f;
bool isLookingUp = (eyePitch > 0);
for (auto& blinkIndex : eyeBlinkIndices) {
float lookingUpCoefficient = -eyelidOffset;
float lookingDownCoefficient = BLINK_DOWN_MULTIPLIER * eyelidOffset;
if (blinkIndex >= 0 && blinkIndex < _transientBlendshapeCoefficients.size()) {
_transientBlendshapeCoefficients[blinkIndex] = isLookingUp ? lookingUpCoefficient : lookingDownCoefficient;
}
}
for (auto& openIndex : eyeOpenIndices) {
float lookingUpCoefficient = eyelidOffset;
float lookingDownCoefficient = OPEN_DOWN_MULTIPLIER * eyelidOffset;
if (openIndex >= 0 && openIndex < _transientBlendshapeCoefficients.size()) {
_transientBlendshapeCoefficients[openIndex] = isLookingUp ? lookingUpCoefficient : lookingDownCoefficient;
}
}
for (auto& browIndex : browsIndices) {
float lookingUpCoefficient = BROW_UP_MULTIPLIER * eyelidOffset;
float lookingDownCoefficient = 0.0f;
if (browIndex >= 0 && browIndex < _transientBlendshapeCoefficients.size()) {
_transientBlendshapeCoefficients[browIndex] = isLookingUp ? lookingUpCoefficient : lookingDownCoefficient;
if (isLookingUp) {
for (int i = 0; i < 2; i++) {
_transientBlendshapeCoefficients[EYE_BLINK_INDICES[i]] = blinkUpCoefficient;
_transientBlendshapeCoefficients[EYE_OPEN_INDICES[i]] = openUpCoefficient;
_transientBlendshapeCoefficients[BROWS_U_INDICES[i]] = browsUpCoefficient;
}
} else {
for (int i = 0; i < 2; i++) {
_transientBlendshapeCoefficients[EYE_BLINK_INDICES[i]] = blinkDownCoefficient;
_transientBlendshapeCoefficients[EYE_OPEN_INDICES[i]] = openDownCoefficient;
_transientBlendshapeCoefficients[BROWS_U_INDICES[i]] = browsDownCoefficient;
}
}
}

View file

@ -17,7 +17,6 @@
#include <QtCore/QJsonArray>
#include <QVector>
#include <FaceshiftConstants.h>
#include <GLMHelpers.h>
#include <shared/JSONHelpers.h>

View file

@ -20,6 +20,7 @@
#include <glm/gtc/quaternion.hpp>
#include <SharedUtil.h>
#include <FaceshiftConstants.h>
// degrees
const float MIN_HEAD_YAW = -180.0f;

View file

@ -64,3 +64,18 @@ const char* FACESHIFT_BLENDSHAPES[] = {
};
const int NUM_FACESHIFT_BLENDSHAPES = sizeof(FACESHIFT_BLENDSHAPES) / sizeof(char*);
const int EYE_BLINK_L_INDEX = 0;
const int EYE_BLINK_R_INDEX = 1;
const int EYE_SQUINT_L_INDEX = 2;
const int EYE_SQUINT_R_INDEX = 3;
const int EYE_OPEN_L_INDEX = 8;
const int EYE_OPEN_R_INDEX = 9;
const int BROWS_U_L_INDEX = 17;
const int BROWS_U_R_INDEX = 18;
const int EYE_BLINK_INDICES[] = { EYE_BLINK_L_INDEX, EYE_BLINK_R_INDEX };
const int EYE_SQUINT_INDICES[] = { EYE_SQUINT_L_INDEX, EYE_SQUINT_R_INDEX };
const int EYE_OPEN_INDICES[] = { EYE_OPEN_L_INDEX, EYE_OPEN_R_INDEX };
const int BROWS_U_INDICES[] = { BROWS_U_L_INDEX, BROWS_U_R_INDEX };

View file

@ -16,5 +16,9 @@
extern const char* FACESHIFT_BLENDSHAPES[];
/// The size of FACESHIFT_BLENDSHAPES
extern const int NUM_FACESHIFT_BLENDSHAPES;
// Eyes and Brows indices
extern const int EYE_BLINK_INDICES[];
extern const int EYE_OPEN_INDICES[];
extern const int BROWS_U_INDICES[];
extern const int EYE_SQUINT_INDICES[];
#endif // hifi_FaceshiftConstants_h