Merge pull request #4059 from AndrewMeadows/bispinor

fix rapid attenuation of angular velocity
This commit is contained in:
Philip Rosedale 2015-01-07 13:12:35 -08:00
commit 84b9d51e90

View file

@ -647,27 +647,30 @@ void EntityItem::simulate(const quint64& now) {
glm::quat rotation = getRotation();
// angular damping
glm::vec3 angularVelocity = glm::radians(getAngularVelocity());
glm::vec3 angularVelocity = getAngularVelocity();
if (_angularDamping > 0.0f) {
angularVelocity *= powf(1.0f - _angularDamping, timeElapsed);
if (wantDebug) {
qDebug() << " angularDamping :" << _angularDamping;
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.1f; //
if (angularSpeed < EPSILON_ANGULAR_VELOCITY_LENGTH) {
angularVelocity = NO_ANGULAR_VELOCITY;
setAngularVelocity(NO_ANGULAR_VELOCITY);
} else {
float angle = timeElapsed * angularSpeed;
glm::quat dQ = glm::angleAxis(angle, glm::normalize(angularVelocity));
// NOTE: angularSpeed is currently in degrees/sec!!!
// 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);
setRotation(rotation);
}
setAngularVelocity(angularVelocity);
}
#ifdef USE_BULLET_PHYSICS