mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 01:57:00 +02:00
fix rapid attenuation of angular velocity
This commit is contained in:
parent
476887b7ef
commit
1745548665
1 changed files with 10 additions and 7 deletions
|
@ -647,27 +647,30 @@ void EntityItem::simulate(const quint64& now) {
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getRotation();
|
||||||
|
|
||||||
// angular damping
|
// angular damping
|
||||||
glm::vec3 angularVelocity = glm::radians(getAngularVelocity());
|
glm::vec3 angularVelocity = getAngularVelocity();
|
||||||
if (_angularDamping > 0.0f) {
|
if (_angularDamping > 0.0f) {
|
||||||
angularVelocity *= powf(1.0f - _angularDamping, timeElapsed);
|
angularVelocity *= powf(1.0f - _angularDamping, timeElapsed);
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
qDebug() << " angularDamping :" << _angularDamping;
|
qDebug() << " angularDamping :" << _angularDamping;
|
||||||
qDebug() << " newAngularVelocity:" << angularVelocity;
|
qDebug() << " newAngularVelocity:" << angularVelocity;
|
||||||
}
|
}
|
||||||
|
setAngularVelocity(angularVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
float angularSpeed = glm::length(angularVelocity);
|
float angularSpeed = glm::length(_angularVelocity);
|
||||||
|
|
||||||
const float EPSILON_ANGULAR_VELOCITY_LENGTH = 0.0017453f; // ~0.1 degree/sec
|
const float EPSILON_ANGULAR_VELOCITY_LENGTH = 0.1; //
|
||||||
if (angularSpeed < EPSILON_ANGULAR_VELOCITY_LENGTH) {
|
if (angularSpeed < EPSILON_ANGULAR_VELOCITY_LENGTH) {
|
||||||
angularVelocity = NO_ANGULAR_VELOCITY;
|
setAngularVelocity(NO_ANGULAR_VELOCITY);
|
||||||
} else {
|
} else {
|
||||||
float angle = timeElapsed * angularSpeed;
|
// NOTE: angularSpeed is currently in degrees/sec!!!
|
||||||
glm::quat dQ = glm::angleAxis(angle, glm::normalize(angularVelocity));
|
// TODO: Andrew to convert to radians/sec
|
||||||
|
float angle = timeElapsed * glm::radians(angularSpeed);
|
||||||
|
glm::vec3 axis = _angularVelocity / angularSpeed;
|
||||||
|
glm::quat dQ = glm::angleAxis(angle, axis);
|
||||||
rotation = glm::normalize(dQ * rotation);
|
rotation = glm::normalize(dQ * rotation);
|
||||||
setRotation(rotation);
|
setRotation(rotation);
|
||||||
}
|
}
|
||||||
setAngularVelocity(angularVelocity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_BULLET_PHYSICS
|
#ifdef USE_BULLET_PHYSICS
|
||||||
|
|
Loading…
Reference in a new issue