mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:09:24 +02:00
Exponential relaxation
This commit is contained in:
parent
5a556a06d2
commit
9849efe013
2 changed files with 8 additions and 6 deletions
|
@ -16,8 +16,7 @@ inline float FaceTracker::getBlendshapeCoefficient(int index) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
float FaceTracker::getFadeCoefficient() const {
|
float FaceTracker::getFadeCoefficient() const {
|
||||||
// TODO: apply exponential relaxation
|
return _fadeCoefficient;
|
||||||
return _relaxationStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec3 FaceTracker::getHeadTranslation() const {
|
const glm::vec3 FaceTracker::getHeadTranslation() const {
|
||||||
|
@ -29,18 +28,20 @@ const glm::quat FaceTracker::getHeadRotation() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceTracker::update(float deltaTime) {
|
void FaceTracker::update(float deltaTime) {
|
||||||
static const float RELAXATION_TIME = 0.4; // sec
|
static const float RELAXATION_TIME = 1.0f; // sec
|
||||||
|
static const float LAMBDA = 1.5;
|
||||||
|
|
||||||
if (isTracking()) {
|
if (isTracking()) {
|
||||||
if (_relaxationStatus == 1.0f) {
|
if (_relaxationStatus == 1.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_relaxationStatus += deltaTime / RELAXATION_TIME;
|
_relaxationStatus = glm::clamp(_relaxationStatus + deltaTime / RELAXATION_TIME, 0.0f, 1.0f);
|
||||||
|
_fadeCoefficient = std::exp(-LAMBDA * _relaxationStatus);
|
||||||
} else {
|
} else {
|
||||||
if (_relaxationStatus == 0.0f) {
|
if (_relaxationStatus == 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_relaxationStatus -= deltaTime / RELAXATION_TIME;
|
_relaxationStatus = glm::clamp(_relaxationStatus - deltaTime / RELAXATION_TIME, 0.0f, 1.0f);
|
||||||
|
_fadeCoefficient = 1.0f - std::exp(-LAMBDA * (1.0f - _relaxationStatus));
|
||||||
}
|
}
|
||||||
_relaxationStatus = glm::clamp(_relaxationStatus, 0.0f, 1.0f);
|
|
||||||
}
|
}
|
|
@ -51,6 +51,7 @@ protected:
|
||||||
QVector<float> _blendshapeCoefficients;
|
QVector<float> _blendshapeCoefficients;
|
||||||
|
|
||||||
float _relaxationStatus = 0.0f; // Between 0.0f and 1.0f
|
float _relaxationStatus = 0.0f; // Between 0.0f and 1.0f
|
||||||
|
float _fadeCoefficient = 0.0f; // Between 0.0f and 1.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_FaceTracker_h
|
#endif // hifi_FaceTracker_h
|
||||||
|
|
Loading…
Reference in a new issue