mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
fix #2567 thrust + oculus doesn't change body rot
This commit is contained in:
parent
a57002038b
commit
01c42c741c
3 changed files with 6 additions and 28 deletions
|
@ -510,7 +510,7 @@ void Application::paintGL() {
|
||||||
_myCamera.setDistance(0.0f);
|
_myCamera.setDistance(0.0f);
|
||||||
_myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
|
_myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
|
||||||
_myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
|
_myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation());
|
_myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||||
|
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||||
_myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
|
_myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include "devices/OculusManager.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -198,6 +199,9 @@ glm::quat Head::getFinalOrientation() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Head::getCameraOrientation () const {
|
glm::quat Head::getCameraOrientation () const {
|
||||||
|
if (OculusManager::isConnected()) {
|
||||||
|
return getOrientation();
|
||||||
|
}
|
||||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.f, 0.0f)));
|
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.f, 0.0f)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,9 +169,6 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
// Collect thrust forces from keyboard and devices
|
// Collect thrust forces from keyboard and devices
|
||||||
updateThrust(deltaTime);
|
updateThrust(deltaTime);
|
||||||
|
|
||||||
// copy velocity so we can use it later for acceleration
|
|
||||||
glm::vec3 oldVelocity = getVelocity();
|
|
||||||
|
|
||||||
// calculate speed
|
// calculate speed
|
||||||
_speed = glm::length(_velocity);
|
_speed = glm::length(_velocity);
|
||||||
|
|
||||||
|
@ -231,29 +228,6 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
// update the euler angles
|
// update the euler angles
|
||||||
setOrientation(orientation);
|
setOrientation(orientation);
|
||||||
|
|
||||||
// Compute instantaneous acceleration
|
|
||||||
float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime;
|
|
||||||
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
|
||||||
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
|
||||||
|
|
||||||
if (!Application::getInstance()->getFaceshift()->isActive() && OculusManager::isConnected() &&
|
|
||||||
fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD &&
|
|
||||||
fabs(getHead()->getBaseYaw()) > 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
|
|
||||||
getHead()->setBaseYaw(0);
|
|
||||||
|
|
||||||
// correct the oculus yaw offset
|
|
||||||
OculusManager::updateYawOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
const float WALKING_SPEED_THRESHOLD = 0.2f;
|
const float WALKING_SPEED_THRESHOLD = 0.2f;
|
||||||
// use speed and angular velocity to determine walking vs. standing
|
// use speed and angular velocity to determine walking vs. standing
|
||||||
if (_speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) {
|
if (_speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) {
|
||||||
|
@ -308,7 +282,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
head->simulate(deltaTime, true);
|
head->simulate(deltaTime, true);
|
||||||
|
|
||||||
// Zero thrust out now that we've added it to velocity in this frame
|
// Zero thrust out now that we've added it to velocity in this frame
|
||||||
_thrust = glm::vec3(0, 0, 0);
|
_thrust = glm::vec3(0.f);
|
||||||
|
|
||||||
// now that we're done stepping the avatar forward in time, compute new collisions
|
// now that we're done stepping the avatar forward in time, compute new collisions
|
||||||
if (_collisionFlags != 0) {
|
if (_collisionFlags != 0) {
|
||||||
|
|
Loading…
Reference in a new issue