mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 05:53:29 +02:00
Better thrust values and no jittering when standing
This commit is contained in:
parent
678b30f494
commit
4b95f2bae5
1 changed files with 28 additions and 30 deletions
|
@ -364,10 +364,10 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
|||
glm::vec3 up = orientation * IDENTITY_UP;
|
||||
|
||||
const float THRUST_MAG_UP = 800.0f;
|
||||
const float THRUST_MAG_DOWN = 200.f;
|
||||
const float THRUST_MAG_FWD = 300.f;
|
||||
const float THRUST_MAG_BACK = 150.f;
|
||||
const float THRUST_MAG_LATERAL = 200.f;
|
||||
const float THRUST_MAG_DOWN = 300.f;
|
||||
const float THRUST_MAG_FWD = 500.f;
|
||||
const float THRUST_MAG_BACK = 300.f;
|
||||
const float THRUST_MAG_LATERAL = 250.f;
|
||||
const float THRUST_JUMP = 120.f;
|
||||
|
||||
// Add Thrusts from keyboard
|
||||
|
@ -422,7 +422,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
glm::quat orientation = getOrientation();
|
||||
glm::vec3 front = orientation * IDENTITY_FRONT;
|
||||
glm::vec3 right = orientation * IDENTITY_RIGHT;
|
||||
|
||||
|
||||
// Update movement timers
|
||||
if (isMyAvatar()) {
|
||||
_elapsedTimeSinceCollision += deltaTime;
|
||||
|
@ -445,9 +445,6 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
glm::vec3 oldVelocity = getVelocity();
|
||||
|
||||
if (isMyAvatar()) {
|
||||
// update position by velocity
|
||||
_position += _velocity * deltaTime;
|
||||
|
||||
// calculate speed
|
||||
_speed = glm::length(_velocity);
|
||||
}
|
||||
|
@ -482,7 +479,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
enableHandMovement &= (it->jointID != AVATAR_JOINT_RIGHT_WRIST);
|
||||
}
|
||||
|
||||
// update avatar skeleton
|
||||
// update avatar skeleton
|
||||
_skeleton.update(deltaTime, getOrientation(), _position);
|
||||
|
||||
//determine the lengths of the body springs now that we have updated the skeleton at least once
|
||||
|
@ -503,42 +500,41 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
_ballSpringsInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
// if this is not my avatar, then hand position comes from transmitted data
|
||||
if (!isMyAvatar()) {
|
||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handPosition;
|
||||
}
|
||||
|
||||
//detect and respond to collisions with other avatars...
|
||||
if (isMyAvatar()) {
|
||||
updateAvatarCollisions(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
//update the movement of the hand and process handshaking with other avatars...
|
||||
updateHandMovementAndTouching(deltaTime, enableHandMovement);
|
||||
_avatarTouch.simulate(deltaTime);
|
||||
|
||||
// apply gravity and collision with the ground/floor
|
||||
if (isMyAvatar() && USING_AVATAR_GRAVITY) {
|
||||
_velocity += _gravity * (GRAVITY_EARTH * deltaTime);
|
||||
}
|
||||
if (isMyAvatar()) {
|
||||
|
||||
// apply gravity
|
||||
if (USING_AVATAR_GRAVITY) {
|
||||
// For gravity, always move the avatar by the amount driven by gravity, so that the collision
|
||||
// routines will detect it and collide every frame when pulled by gravity to a surface
|
||||
//
|
||||
_velocity += _gravity * (GRAVITY_EARTH * deltaTime);
|
||||
_position += _gravity * (GRAVITY_EARTH * deltaTime) * deltaTime;
|
||||
}
|
||||
|
||||
updateCollisionWithEnvironment();
|
||||
updateCollisionWithVoxels();
|
||||
updateAvatarCollisions(deltaTime);
|
||||
}
|
||||
|
||||
// update body balls
|
||||
updateBodyBalls(deltaTime);
|
||||
|
||||
|
||||
// test for avatar collision response with the big sphere
|
||||
if (usingBigSphereCollisionTest) {
|
||||
updateCollisionWithSphere(_TEST_bigSpherePosition, _TEST_bigSphereRadius, deltaTime);
|
||||
}
|
||||
|
||||
// collision response with voxels
|
||||
if (isMyAvatar()) {
|
||||
updateCollisionWithVoxels();
|
||||
}
|
||||
|
||||
|
||||
if (isMyAvatar()) {
|
||||
|
||||
// add thrust to velocity
|
||||
|
@ -547,7 +543,6 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
// update body yaw by body yaw delta
|
||||
orientation = orientation * glm::quat(glm::radians(
|
||||
glm::vec3(_bodyPitchDelta, _bodyYawDelta, _bodyRollDelta) * deltaTime));
|
||||
|
||||
// decay body rotation momentum
|
||||
float bodySpinMomentum = 1.0 - BODY_SPIN_FRICTION * deltaTime;
|
||||
if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; }
|
||||
|
@ -555,14 +550,14 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
_bodyYawDelta *= bodySpinMomentum;
|
||||
_bodyRollDelta *= bodySpinMomentum;
|
||||
|
||||
const float MAX_STATIC_FRICTION_VELOCITY = 0.25f;
|
||||
const float MAX_STATIC_FRICTION_VELOCITY = 0.5f;
|
||||
const float STATIC_FRICTION_STRENGTH = 20.f;
|
||||
applyStaticFriction(deltaTime, _velocity, MAX_STATIC_FRICTION_VELOCITY, STATIC_FRICTION_STRENGTH);
|
||||
|
||||
const float LINEAR_DAMPING_STRENGTH = 0.2f;
|
||||
const float SQUARED_DAMPING_STRENGTH = 0.1f;
|
||||
const float LINEAR_DAMPING_STRENGTH = 3.0f;
|
||||
const float SQUARED_DAMPING_STRENGTH = 0.2f;
|
||||
applyDamping(deltaTime, _velocity, LINEAR_DAMPING_STRENGTH, SQUARED_DAMPING_STRENGTH);
|
||||
|
||||
|
||||
//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;
|
||||
|
@ -653,6 +648,9 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
_mode = AVATAR_MODE_INTERACTING;
|
||||
}
|
||||
|
||||
// update position by velocity, and subtract the change added earlier for gravity
|
||||
_position += _velocity * deltaTime;
|
||||
|
||||
// Zero thrust out now that we've added it to velocity in this frame
|
||||
_thrust = glm::vec3(0, 0, 0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue