mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 07:18:02 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into voxel_animation
This commit is contained in:
commit
77601c880c
5 changed files with 51 additions and 20 deletions
|
@ -301,7 +301,6 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
deltaTime *
|
deltaTime *
|
||||||
_orientation.getUp();
|
_orientation.getUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,11 +381,28 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
const float ACCELERATION_PITCH_DECAY = 0.4f;
|
const float ACCELERATION_PITCH_DECAY = 0.4f;
|
||||||
const float ACCELERATION_YAW_DECAY = 0.4f;
|
const float ACCELERATION_YAW_DECAY = 0.4f;
|
||||||
|
|
||||||
|
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
||||||
|
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
||||||
|
|
||||||
// Decay HeadPitch as a function of acceleration, so that you look straight ahead when
|
// Decay HeadPitch as a function of acceleration, so that you look straight ahead when
|
||||||
// you start moving, but don't do this with an HMD like the Oculus.
|
// you start moving, but don't do this with an HMD like the Oculus.
|
||||||
if (!OculusManager::isConnected()) {
|
if (!OculusManager::isConnected()) {
|
||||||
_head.setPitch(_head.getPitch() * (1.f - acceleration * ACCELERATION_PITCH_DECAY * deltaTime));
|
_head.setPitch(_head.getPitch() * (1.f - acceleration * ACCELERATION_PITCH_DECAY * deltaTime));
|
||||||
_head.setYaw(_head.getYaw() * (1.f - acceleration * ACCELERATION_YAW_DECAY * deltaTime));
|
_head.setYaw(_head.getYaw() * (1.f - acceleration * ACCELERATION_YAW_DECAY * deltaTime));
|
||||||
|
} else if (fabsf(acceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD
|
||||||
|
&& fabs(_head.getYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) {
|
||||||
|
// if we're wearing the oculus
|
||||||
|
// and this acceleration is above the pull threshold
|
||||||
|
// and the head yaw if off the body by more than OCULUS_YAW_OFFSET_THRESHOLD
|
||||||
|
|
||||||
|
// match the body yaw to the oculus yaw
|
||||||
|
_bodyYaw = getAbsoluteHeadYaw();
|
||||||
|
|
||||||
|
// set the head yaw to zero for this draw
|
||||||
|
_head.setYaw(0);
|
||||||
|
|
||||||
|
// correct the oculus yaw offset
|
||||||
|
OculusManager::updateYawOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply the head lean values to the springy position...
|
//apply the head lean values to the springy position...
|
||||||
|
|
|
@ -16,6 +16,7 @@ Ptr<DeviceManager> OculusManager::_deviceManager;
|
||||||
Ptr<HMDDevice> OculusManager::_hmdDevice;
|
Ptr<HMDDevice> OculusManager::_hmdDevice;
|
||||||
Ptr<SensorDevice> OculusManager::_sensorDevice;
|
Ptr<SensorDevice> OculusManager::_sensorDevice;
|
||||||
SensorFusion OculusManager::_sensorFusion;
|
SensorFusion OculusManager::_sensorFusion;
|
||||||
|
float OculusManager::_yawOffset = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OculusManager::connect() {
|
void OculusManager::connect() {
|
||||||
|
@ -36,12 +37,19 @@ void OculusManager::connect() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OculusManager::updateYawOffset() {
|
||||||
|
float yaw, pitch, roll;
|
||||||
|
_sensorFusion.GetOrientation().GetEulerAngles<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&yaw, &pitch, &roll);
|
||||||
|
_yawOffset = yaw;
|
||||||
|
}
|
||||||
|
|
||||||
void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
|
void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
_sensorFusion.GetOrientation().GetEulerAngles<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&yaw, &pitch, &roll);
|
_sensorFusion.GetOrientation().GetEulerAngles<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&yaw, &pitch, &roll);
|
||||||
|
|
||||||
// convert each angle to degrees
|
// convert each angle to degrees
|
||||||
yaw = glm::degrees(yaw);
|
// remove the yaw offset from the returned yaw
|
||||||
|
yaw = glm::degrees(yaw - _yawOffset);
|
||||||
pitch = glm::degrees(pitch);
|
pitch = glm::degrees(pitch);
|
||||||
roll = glm::degrees(roll);
|
roll = glm::degrees(roll);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,12 +21,15 @@ public:
|
||||||
static bool isConnected() { return _isConnected; }
|
static bool isConnected() { return _isConnected; }
|
||||||
|
|
||||||
static void getEulerAngles(float& yaw, float& pitch, float& roll);
|
static void getEulerAngles(float& yaw, float& pitch, float& roll);
|
||||||
|
|
||||||
|
static void updateYawOffset();
|
||||||
private:
|
private:
|
||||||
static bool _isConnected;
|
static bool _isConnected;
|
||||||
static Ptr<DeviceManager> _deviceManager;
|
static Ptr<DeviceManager> _deviceManager;
|
||||||
static Ptr<HMDDevice> _hmdDevice;
|
static Ptr<HMDDevice> _hmdDevice;
|
||||||
static Ptr<SensorDevice> _sensorDevice;
|
static Ptr<SensorDevice> _sensorDevice;
|
||||||
static SensorFusion _sensorFusion;
|
static SensorFusion _sensorFusion;
|
||||||
|
static float _yawOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__OculusManager__) */
|
#endif /* defined(__hifi__OculusManager__) */
|
||||||
|
|
|
@ -69,6 +69,9 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure we have enough bytes left for this to be the right amount of audio
|
||||||
|
// otherwise we should not copy that data, and leave the buffer pointers where they are
|
||||||
|
if (numBytes - (dataBuffer - sourceBuffer) == _bufferLengthSamples * sizeof(int16_t)) {
|
||||||
if (!_endOfLastWrite) {
|
if (!_endOfLastWrite) {
|
||||||
_endOfLastWrite = _buffer;
|
_endOfLastWrite = _buffer;
|
||||||
} else if (diffLastWriteNextOutput() > _ringBufferLengthSamples - _bufferLengthSamples) {
|
} else if (diffLastWriteNextOutput() > _ringBufferLengthSamples - _bufferLengthSamples) {
|
||||||
|
@ -84,6 +87,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
if (_endOfLastWrite >= _buffer + _ringBufferLengthSamples) {
|
if (_endOfLastWrite >= _buffer + _ringBufferLengthSamples) {
|
||||||
_endOfLastWrite = _buffer;
|
_endOfLastWrite = _buffer;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return numBytes;
|
return numBytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
const float MIN_HEAD_YAW = -85;
|
const float MIN_HEAD_YAW = -110;
|
||||||
const float MAX_HEAD_YAW = 85;
|
const float MAX_HEAD_YAW = 110;
|
||||||
const float MIN_HEAD_PITCH = -60;
|
const float MIN_HEAD_PITCH = -60;
|
||||||
const float MAX_HEAD_PITCH = 60;
|
const float MAX_HEAD_PITCH = 60;
|
||||||
const float MIN_HEAD_ROLL = -50;
|
const float MIN_HEAD_ROLL = -50;
|
||||||
|
|
Loading…
Reference in a new issue