Upgrade Bullet to version 2.83.
[blender.git] / extern / bullet2 / src / BulletDynamics / Character / btKinematicCharacterController.cpp
index 8d940e63cd33fb376abf14f19b6c97f897534bae..31faf1df5e3baf391046dac1c4198a4bdf017dbc 100644 (file)
@@ -29,13 +29,11 @@ subject to the following restrictions:
 static btVector3
 getNormalizedVector(const btVector3& v)
 {
-    btScalar l = v.length();
-    btVector3 n = v;
-    if (l < SIMD_EPSILON) {
-        n.setValue(0,0,0);
-    } else {
-        n /= l;
-    }
+       btVector3 n(0, 0, 0);
+
+       if (v.length() > SIMD_EPSILON) {
+               n = v.normalized();
+       }
        return n;
 }
 
@@ -383,8 +381,8 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
                if (callback.hasHit())
                {       
                        // we moved only a fraction
-                       btScalar hitDistance;
-                       hitDistance = (callback.m_hitPointWorld - m_currentPosition).length();
+                       //btScalar hitDistance;
+                       //hitDistance = (callback.m_hitPointWorld - m_currentPosition).length();
 
 //                     m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);
 
@@ -638,7 +636,7 @@ void btKinematicCharacterController::playerStep (  btCollisionWorld* collisionWo
 //     printf("  dt = %f", dt);
 
        // quick check...
-       if (!m_useWalkDirection && m_velocityTimeInterval <= 0.0) {
+       if (!m_useWalkDirection && (m_velocityTimeInterval <= 0.0 || m_walkDirection.fuzzyZero())) {
 //             printf("\n");
                return;         // no motion
        }