mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 21:53:47 +02:00
Added acceleration decay of pitch (you look up/straight if you start moving)
This commit is contained in:
parent
2be597beb0
commit
e55efb81a8
1 changed files with 16 additions and 17 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include <AgentList.h>
|
#include <AgentList.h>
|
||||||
#include <AgentTypes.h>
|
#include <AgentTypes.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
|
#include <OculusManager.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -29,8 +30,6 @@ const float THRUST_MAG = 1200.0;
|
||||||
const float YAW_MAG = 500.0;
|
const float YAW_MAG = 500.0;
|
||||||
const float BODY_SPIN_FRICTION = 5.0;
|
const float BODY_SPIN_FRICTION = 5.0;
|
||||||
const float BODY_UPRIGHT_FORCE = 10.0;
|
const float BODY_UPRIGHT_FORCE = 10.0;
|
||||||
const float BODY_PITCH_WHILE_WALKING = 40.0;
|
|
||||||
const float BODY_ROLL_WHILE_TURNING = 0.1;
|
|
||||||
const float VELOCITY_DECAY = 5.0;
|
const float VELOCITY_DECAY = 5.0;
|
||||||
const float MY_HAND_HOLDING_PULL = 0.2;
|
const float MY_HAND_HOLDING_PULL = 0.2;
|
||||||
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
||||||
|
@ -50,7 +49,6 @@ const float HEAD_MAX_YAW = 85;
|
||||||
const float HEAD_MIN_YAW = -85;
|
const float HEAD_MIN_YAW = -85;
|
||||||
const float AVATAR_BRAKING_RANGE = 1.6f;
|
const float AVATAR_BRAKING_RANGE = 1.6f;
|
||||||
const float AVATAR_BRAKING_STRENGTH = 30.0f;
|
const float AVATAR_BRAKING_STRENGTH = 30.0f;
|
||||||
//const float MAX_JOINT_TOUCH_DOT = 0.995f;
|
|
||||||
const float JOINT_TOUCH_RANGE = 0.0005f;
|
const float JOINT_TOUCH_RANGE = 0.0005f;
|
||||||
|
|
||||||
float skinColor [] = {1.0, 0.84, 0.66};
|
float skinColor [] = {1.0, 0.84, 0.66};
|
||||||
|
@ -188,15 +186,6 @@ Avatar::Avatar(const Avatar &otherAvatar) {
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
/*
|
|
||||||
if (iris_texture.size() == 0) {
|
|
||||||
switchToResourcesParentIfRequired();
|
|
||||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
|
||||||
if (error != 0) {
|
|
||||||
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar::~Avatar() {
|
Avatar::~Avatar() {
|
||||||
|
@ -332,7 +321,10 @@ void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int scree
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime) {
|
void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
//figure out if the mouse cursor is over any body spheres...
|
// copy velocity so we can use it later for acceleration
|
||||||
|
glm::vec3 oldVelocity = getVelocity();
|
||||||
|
|
||||||
|
// figure out if the mouse cursor is over any body spheres...
|
||||||
checkForMouseRayTouching();
|
checkForMouseRayTouching();
|
||||||
|
|
||||||
// update balls
|
// update balls
|
||||||
|
@ -403,10 +395,12 @@ void Avatar::simulate(float deltaTime) {
|
||||||
// add thrust to velocity
|
// add thrust to velocity
|
||||||
_velocity += _thrust * deltaTime;
|
_velocity += _thrust * deltaTime;
|
||||||
|
|
||||||
// calculate speed
|
// calculate speed
|
||||||
_speed = glm::length(_velocity);
|
_speed = glm::length(_velocity);
|
||||||
|
|
||||||
//pitch and roll the body as a function of forward speed and turning delta
|
//pitch and roll the body as a function of forward speed and turning delta
|
||||||
|
const float BODY_PITCH_WHILE_WALKING = 20.0;
|
||||||
|
const float BODY_ROLL_WHILE_TURNING = 0.2;
|
||||||
float forwardComponentOfVelocity = glm::dot(_orientation.getFront(), _velocity);
|
float forwardComponentOfVelocity = glm::dot(_orientation.getFront(), _velocity);
|
||||||
_bodyPitch += BODY_PITCH_WHILE_WALKING * deltaTime * forwardComponentOfVelocity;
|
_bodyPitch += BODY_PITCH_WHILE_WALKING * deltaTime * forwardComponentOfVelocity;
|
||||||
_bodyRoll += BODY_ROLL_WHILE_TURNING * deltaTime * _speed * _bodyYawDelta;
|
_bodyRoll += BODY_ROLL_WHILE_TURNING * deltaTime * _speed * _bodyYawDelta;
|
||||||
|
@ -442,10 +436,15 @@ void Avatar::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute instantaneous acceleration
|
||||||
|
float acceleration = glm::distance(getVelocity(), oldVelocity) / deltaTime;
|
||||||
|
const float ACCELERATION_PITCH_DECAY = 0.4f;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
if (!OculusManager::isConnected()) {
|
||||||
|
setHeadPitch(getHeadPitch() * (1.f - acceleration * ACCELERATION_PITCH_DECAY * deltaTime));
|
||||||
|
}
|
||||||
// Get head position data from network for other people
|
// Get head position data from network for other people
|
||||||
if (!_isMine) {
|
if (!_isMine) {
|
||||||
_head.leanSideways = getHeadLeanSideways();
|
_head.leanSideways = getHeadLeanSideways();
|
||||||
|
|
Loading…
Reference in a new issue