mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 03:04:33 +02:00
Tiny sliding with gravity removed
This commit is contained in:
parent
984332e638
commit
4272f4da57
2 changed files with 12 additions and 8 deletions
|
@ -98,6 +98,7 @@ Avatar::Avatar(Node* owningNode) :
|
|||
_elapsedTimeMoving(0.0f),
|
||||
_elapsedTimeStopped(0.0f),
|
||||
_elapsedTimeSinceCollision(0.0f),
|
||||
_lastCollisionPosition(0, 0, 0),
|
||||
_speedBrakes(false),
|
||||
_isThrustOn(false),
|
||||
_voxels(this)
|
||||
|
@ -541,11 +542,12 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
// 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 += _scale * _gravity * (GRAVITY_EARTH * deltaTime);
|
||||
_position += _scale * _gravity * (GRAVITY_EARTH * deltaTime) * deltaTime;
|
||||
const float MIN_DISTANCE_AFTER_COLLISION_FOR_GRAVITY = 0.01f;
|
||||
if (glm::length(_position - _lastCollisionPosition) > MIN_DISTANCE_AFTER_COLLISION_FOR_GRAVITY) {
|
||||
_velocity += _scale * _gravity * (GRAVITY_EARTH * deltaTime);
|
||||
_position += _scale * _gravity * (GRAVITY_EARTH * deltaTime) * deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
updateCollisionWithEnvironment(deltaTime);
|
||||
updateCollisionWithVoxels(deltaTime);
|
||||
updateAvatarCollisions(deltaTime);
|
||||
|
@ -890,11 +892,9 @@ void Avatar::updateCollisionWithEnvironment(float deltaTime) {
|
|||
if (velocityTowardCollision > VISIBLE_GROUND_COLLISION_VELOCITY) {
|
||||
Application::getInstance()->setGroundPlaneImpact(1.0f);
|
||||
}
|
||||
_lastCollisionPosition = _position;
|
||||
updateCollisionSound(penetration, deltaTime, ENVIRONMENT_COLLISION_FREQUENCY);
|
||||
|
||||
applyHardCollision(penetration, ENVIRONMENT_SURFACE_ELASTICITY, ENVIRONMENT_SURFACE_DAMPING);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,6 +908,7 @@ void Avatar::updateCollisionWithVoxels(float deltaTime) {
|
|||
if (Application::getInstance()->getVoxels()->findCapsulePenetration(
|
||||
_position - glm::vec3(0.0f, _pelvisFloatingHeight - radius, 0.0f),
|
||||
_position + glm::vec3(0.0f, _height - _pelvisFloatingHeight - radius, 0.0f), radius, penetration)) {
|
||||
_lastCollisionPosition = _position;
|
||||
updateCollisionSound(penetration, deltaTime, VOXEL_COLLISION_FREQUENCY);
|
||||
applyHardCollision(penetration, VOXEL_ELASTICITY, VOXEL_DAMPING);
|
||||
}
|
||||
|
|
|
@ -118,7 +118,8 @@ public:
|
|||
const glm::vec3& amplifyAngle,
|
||||
float yawFromTouch,
|
||||
float pitchFromTouch);
|
||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||
void addBodyYaw(float bodyYaw) {_bodyYaw += bodyYaw;};
|
||||
void addBodyYawDelta(float bodyYawDelta) {_bodyYawDelta += bodyYawDelta;}
|
||||
void render(bool lookingInMirror, bool renderAvatarBalls);
|
||||
|
||||
//setters
|
||||
|
@ -155,6 +156,7 @@ public:
|
|||
float getElapsedTimeStopped () const { return _elapsedTimeStopped;}
|
||||
float getElapsedTimeMoving () const { return _elapsedTimeMoving;}
|
||||
float getElapsedTimeSinceCollision() const { return _elapsedTimeSinceCollision;}
|
||||
const glm::vec3& getLastCollisionPosition () const { return _lastCollisionPosition;}
|
||||
float getAbsoluteHeadYaw () const;
|
||||
float getAbsoluteHeadPitch () const;
|
||||
Head& getHead () {return _head; }
|
||||
|
@ -245,6 +247,7 @@ private:
|
|||
float _elapsedTimeMoving; // Timers to drive camera transitions when moving
|
||||
float _elapsedTimeStopped;
|
||||
float _elapsedTimeSinceCollision;
|
||||
glm::vec3 _lastCollisionPosition;
|
||||
bool _speedBrakes;
|
||||
bool _isThrustOn;
|
||||
|
||||
|
|
Loading…
Reference in a new issue