mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:03:58 +02:00
Smooth gaze direction relative to window.
This commit is contained in:
parent
4f3bacdd4c
commit
08db294a5b
1 changed files with 17 additions and 4 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "Faceshift.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
using namespace fs;
|
||||
using namespace std;
|
||||
|
@ -63,11 +64,23 @@ void Faceshift::update() {
|
|||
}
|
||||
float averageEyePitch = (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f;
|
||||
float averageEyeYaw = (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f;
|
||||
|
||||
// get the gaze relative to the window
|
||||
glm::vec3 eyeEulers = safeEulerAngles(_headRotation * glm::quat(glm::radians(glm::vec3(
|
||||
averageEyePitch, averageEyeYaw, 0.0f))));
|
||||
|
||||
// smooth relative to the window
|
||||
const float LONG_TERM_AVERAGE_SMOOTHING = 0.999f;
|
||||
_longTermAverageEyePitch = glm::mix(averageEyePitch, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
|
||||
_longTermAverageEyeYaw = glm::mix(averageEyeYaw, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
|
||||
_estimatedEyePitch = averageEyePitch - _longTermAverageEyePitch;
|
||||
_estimatedEyeYaw = averageEyeYaw - _longTermAverageEyeYaw;
|
||||
_longTermAverageEyePitch = glm::mix(eyeEulers.x, _longTermAverageEyePitch, LONG_TERM_AVERAGE_SMOOTHING);
|
||||
_longTermAverageEyeYaw = glm::mix(eyeEulers.y, _longTermAverageEyeYaw, LONG_TERM_AVERAGE_SMOOTHING);
|
||||
|
||||
// back to head-relative
|
||||
float windowEyePitch = eyeEulers.x - _longTermAverageEyePitch;
|
||||
float windowEyeYaw = eyeEulers.y - _longTermAverageEyeYaw;
|
||||
glm::vec3 relativeEyeEulers = safeEulerAngles(glm::inverse(_headRotation) * glm::quat(glm::radians(glm::vec3(
|
||||
windowEyePitch, windowEyeYaw, 0.0f))));
|
||||
_estimatedEyePitch = relativeEyeEulers.x;
|
||||
_estimatedEyeYaw = relativeEyeEulers.y;
|
||||
}
|
||||
|
||||
void Faceshift::reset() {
|
||||
|
|
Loading…
Reference in a new issue