mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 19:39:43 +02:00
Velocity damped hand positions
This commit is contained in:
parent
60dfa08b30
commit
2681312b54
2 changed files with 8 additions and 4 deletions
|
@ -50,7 +50,7 @@ var JOYSTICK_PITCH_MAG = PITCH_MAG * 0.5;
|
||||||
|
|
||||||
|
|
||||||
var LEFT_PALM = 0;
|
var LEFT_PALM = 0;
|
||||||
var LEFT_BUTTON_4 = 5;
|
var LEFT_BUTTON_4 = 4;
|
||||||
var LEFT_BUTTON_FWD = 5;
|
var LEFT_BUTTON_FWD = 5;
|
||||||
var RIGHT_PALM = 2;
|
var RIGHT_PALM = 2;
|
||||||
var RIGHT_BUTTON_4 = 10;
|
var RIGHT_BUTTON_4 = 10;
|
||||||
|
|
|
@ -120,7 +120,6 @@ void SixenseManager::update(float deltaTime) {
|
||||||
// Rotation of Palm
|
// Rotation of Palm
|
||||||
glm::quat rotation(data->rot_quat[3], -data->rot_quat[0], data->rot_quat[1], -data->rot_quat[2]);
|
glm::quat rotation(data->rot_quat[3], -data->rot_quat[0], data->rot_quat[1], -data->rot_quat[2]);
|
||||||
rotation = glm::angleAxis(PI, glm::vec3(0.f, 1.f, 0.f)) * _orbRotation * rotation;
|
rotation = glm::angleAxis(PI, glm::vec3(0.f, 1.f, 0.f)) * _orbRotation * rotation;
|
||||||
palm->setRawRotation(rotation);
|
|
||||||
|
|
||||||
// Compute current velocity from position change
|
// Compute current velocity from position change
|
||||||
glm::vec3 rawVelocity;
|
glm::vec3 rawVelocity;
|
||||||
|
@ -130,7 +129,12 @@ void SixenseManager::update(float deltaTime) {
|
||||||
rawVelocity = glm::vec3(0.0f);
|
rawVelocity = glm::vec3(0.0f);
|
||||||
}
|
}
|
||||||
palm->setRawVelocity(rawVelocity); // meters/sec
|
palm->setRawVelocity(rawVelocity); // meters/sec
|
||||||
palm->setRawPosition(position);
|
|
||||||
|
// Use a velocity sensitive filter to damp small motions and preserve large ones with
|
||||||
|
// no latency.
|
||||||
|
float velocityFilter = glm::clamp(1.0f - glm::length(rawVelocity), 0.0f, 1.0f);
|
||||||
|
palm->setRawPosition(palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter));
|
||||||
|
palm->setRawRotation(safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter));
|
||||||
|
|
||||||
// use the velocity to determine whether there's any movement (if the hand isn't new)
|
// use the velocity to determine whether there's any movement (if the hand isn't new)
|
||||||
const float MOVEMENT_DISTANCE_THRESHOLD = 0.003f;
|
const float MOVEMENT_DISTANCE_THRESHOLD = 0.003f;
|
||||||
|
|
Loading…
Reference in a new issue