mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
bulletRotationStep --> computeBulletRotationStep
This commit is contained in:
parent
23bd3f90d9
commit
58bb137c4d
5 changed files with 5 additions and 7 deletions
|
@ -718,14 +718,14 @@ void EntityItem::simulateKinematicMotion(float timeElapsed) {
|
|||
glm::quat rotation = getRotation();
|
||||
float dt = timeElapsed;
|
||||
while (dt > PHYSICS_ENGINE_FIXED_SUBSTEP) {
|
||||
glm::quat dQ = bulletRotationStep(angularVelocity, PHYSICS_ENGINE_FIXED_SUBSTEP);
|
||||
glm::quat dQ = computeBulletRotationStep(angularVelocity, PHYSICS_ENGINE_FIXED_SUBSTEP);
|
||||
rotation = glm::normalize(dQ * rotation);
|
||||
dt -= PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||
}
|
||||
// NOTE: this final partial substep can drift away from a real Bullet simulation however
|
||||
// it only becomes significant for rapidly rotating objects
|
||||
// (e.g. around PI/4 radians per substep, or 7.5 rotations/sec at 60 substeps/sec).
|
||||
glm::quat dQ = bulletRotationStep(angularVelocity, dt);
|
||||
glm::quat dQ = computeBulletRotationStep(angularVelocity, dt);
|
||||
rotation = glm::normalize(dQ * rotation);
|
||||
|
||||
setRotation(rotation);
|
||||
|
|
|
@ -32,6 +32,4 @@ inline btQuaternion glmToBullet(const glm::quat& g) {
|
|||
return btQuaternion(g.x, g.y, g.z, g.w);
|
||||
}
|
||||
|
||||
glm::quat bulletRotationStep(const glm::vec3& angularVelocity, float deltaTime);
|
||||
|
||||
#endif // hifi_BulletUtil_h
|
||||
|
|
|
@ -179,7 +179,7 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
|||
// Bullet caps the effective rotation velocity inside its rotation integration step, therefore
|
||||
// we must integrate with the same algorithm and timestep in order achieve similar results.
|
||||
for (int i = 0; i < numFrames; ++i) {
|
||||
_sentRotation = glm::normalize(bulletRotationStep(_sentAngularVelocity, PHYSICS_ENGINE_FIXED_SUBSTEP) * _sentRotation);
|
||||
_sentRotation = glm::normalize(computeBulletRotationStep(_sentAngularVelocity, PHYSICS_ENGINE_FIXED_SUBSTEP) * _sentRotation);
|
||||
}
|
||||
}
|
||||
const float MIN_ROTATION_DOT = 0.99f; // 0.99 dot threshold coresponds to about 16 degrees of slop
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
* Copied and modified from LinearMath/btTransformUtil.h by AndrewMeadows on 2015.01.27.
|
||||
* */
|
||||
glm::quat bulletRotationStep(const glm::vec3& angularVelocity, float timeStep) {
|
||||
glm::quat computeBulletRotationStep(const glm::vec3& angularVelocity, float timeStep) {
|
||||
// Bullet uses an exponential map approximation technique to integrate rotation.
|
||||
// The reason for this is to make it easy to compute the derivative of angular motion for various consraints.
|
||||
// Here we reproduce the same approximation so that our extrapolations agree well with Bullet's integration.
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
const float PHYSICS_ENGINE_FIXED_SUBSTEP = 1.0f / 60.0f;
|
||||
|
||||
// return incremental rotation (Bullet-style) caused by angularVelocity over timeStep
|
||||
glm::quat bulletRotationStep(const glm::vec3& angularVelocity, float timeStep);
|
||||
glm::quat computeBulletRotationStep(const glm::vec3& angularVelocity, float timeStep);
|
||||
|
||||
#endif // hifi_PhysicsHelpers_h
|
||||
|
|
Loading…
Reference in a new issue