mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 18:58:37 +02:00
Added amplification of gyro rates when applying to head, for more sensitivity, and to allow easily looking to one side and another
This commit is contained in:
parent
7a0ea8bd59
commit
eb15aa602c
2 changed files with 11 additions and 11 deletions
|
@ -128,19 +128,19 @@ void Avatar::reset() {
|
||||||
|
|
||||||
// Update avatar head rotation with sensor data
|
// Update avatar head rotation with sensor data
|
||||||
void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterface, glm::vec3* gravity) {
|
void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterface, glm::vec3* gravity) {
|
||||||
float measuredPitchRate = 0.0f;
|
const float AMPLIFY_PITCH = 2.f;
|
||||||
float measuredRollRate = 0.0f;
|
const float AMPLIFY_YAW = 2.f;
|
||||||
float measuredYawRate = 0.0f;
|
const float AMPLIFY_ROLL = 2.f;
|
||||||
|
|
||||||
measuredPitchRate = serialInterface->getLastPitchRate();
|
float measuredPitchRate = serialInterface->getLastPitchRate();
|
||||||
measuredYawRate = serialInterface->getLastYawRate();
|
float measuredYawRate = serialInterface->getLastYawRate();
|
||||||
measuredRollRate = serialInterface->getLastRollRate();
|
float measuredRollRate = serialInterface->getLastRollRate();
|
||||||
|
|
||||||
// Update avatar head position based on measured gyro rates
|
// Update avatar head position based on measured gyro rates
|
||||||
|
|
||||||
_head.addPitch(measuredPitchRate * deltaTime);
|
_head.addPitch(measuredPitchRate * AMPLIFY_PITCH * deltaTime);
|
||||||
_head.addYaw (measuredYawRate * deltaTime);
|
_head.addYaw (measuredYawRate * AMPLIFY_YAW * deltaTime);
|
||||||
_head.addRoll (measuredRollRate * deltaTime);
|
_head.addRoll (measuredRollRate * AMPLIFY_ROLL * deltaTime);
|
||||||
|
|
||||||
// Update head lean distance based on accelerometer data
|
// Update head lean distance based on accelerometer data
|
||||||
glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll());
|
glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll());
|
||||||
|
|
|
@ -76,10 +76,10 @@ void Head::simulate(float deltaTime, bool isMine) {
|
||||||
_roll *= (1.0f - HEAD_MOTION_DECAY * _returnSpringScale * deltaTime);
|
_roll *= (1.0f - HEAD_MOTION_DECAY * _returnSpringScale * deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For invensense gyro, decay only slightly when roughly centered
|
// For invensense gyro, decay only slightly when near center (until we add fusion)
|
||||||
if (isMine) {
|
if (isMine) {
|
||||||
const float RETURN_RANGE = 15.0;
|
const float RETURN_RANGE = 15.0;
|
||||||
const float RETURN_STRENGTH = 2.0;
|
const float RETURN_STRENGTH = 0.5;
|
||||||
if (fabs(_pitch) < RETURN_RANGE) { _pitch *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
if (fabs(_pitch) < RETURN_RANGE) { _pitch *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
||||||
if (fabs(_yaw ) < RETURN_RANGE) { _yaw *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
if (fabs(_yaw ) < RETURN_RANGE) { _yaw *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
||||||
if (fabs(_roll ) < RETURN_RANGE) { _roll *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
if (fabs(_roll ) < RETURN_RANGE) { _roll *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
||||||
|
|
Loading…
Reference in a new issue