formatting

This commit is contained in:
luiscuenca 2018-07-12 16:03:15 -07:00
parent 1ab6c7a8ac
commit 45f8ed010c

View file

@ -280,7 +280,7 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
// then the two rotations are effectively adjacent // then the two rotations are effectively adjacent
const float MIN_DOT_PRODUCT_OF_ADJACENT_QUATERNIONS = 0.99999f; // corresponds to approx 0.5 degrees const float MIN_DOT_PRODUCT_OF_ADJACENT_QUATERNIONS = 0.99999f; // corresponds to approx 0.5 degrees
if (fabsf(qDot) < MIN_DOT_PRODUCT_OF_ADJACENT_QUATERNIONS) { if (fabsf(qDot) < MIN_DOT_PRODUCT_OF_ADJACENT_QUATERNIONS) {
if (qDot < 0.0f) { if (qDot < 0.0f) {
// the quaternions are actually on opposite hyperhemispheres // the quaternions are actually on opposite hyperhemispheres
// so we move one to agree with the other and negate qDot // so we move one to agree with the other and negate qDot
desiredRot = -desiredRot; desiredRot = -desiredRot;
@ -290,16 +290,16 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
// the axis is the imaginary part, but scaled by sin(angle/2) // the axis is the imaginary part, but scaled by sin(angle/2)
btVector3 axis(deltaRot.getX(), deltaRot.getY(), deltaRot.getZ()); btVector3 axis(deltaRot.getX(), deltaRot.getY(), deltaRot.getZ());
axis /= sqrtf(1.0f - qDot*qDot); axis /= sqrtf(1.0f - qDot * qDot);
// compute the angle we will resolve for this dt, but don't overshoot // compute the angle we will resolve for this dt, but don't overshoot
float angle = (2.0f * acosf(qDot)); float angle = 2.0f * acosf(qDot);
if ( dt < _followTimeRemaining) { if ( dt < _followTimeRemaining) {
angle *= dt / _followTimeRemaining; angle *= dt / _followTimeRemaining;
} }
// accumulate rotation // accumulate rotation
deltaRot = btQuaternion(axis, angle); deltaRot = btQuaternion(axis, angle);
_followAngularDisplacement = (deltaRot * _followAngularDisplacement).normalize(); _followAngularDisplacement = (deltaRot * _followAngularDisplacement).normalize();
// in order to accumulate displacement of avatar position, we need to take _shapeLocalOffset into account. // in order to accumulate displacement of avatar position, we need to take _shapeLocalOffset into account.
@ -307,7 +307,7 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
endRot = deltaRot * startRot; endRot = deltaRot * startRot;
btVector3 swingDisplacement = rotateVector(endRot, -shapeLocalOffset) - rotateVector(startRot, -shapeLocalOffset); btVector3 swingDisplacement = rotateVector(endRot, -shapeLocalOffset) - rotateVector(startRot, -shapeLocalOffset);
_followLinearDisplacement += swingDisplacement; _followLinearDisplacement += swingDisplacement;
} }
_rigidBody->setWorldTransform(btTransform(endRot, endPos)); _rigidBody->setWorldTransform(btTransform(endRot, endPos));
} }