Remove an assert in Bullet for the Character physics.
authorBenoit Bolsee <benoit.bolsee@online.be>
Sat, 9 Aug 2014 22:36:32 +0000 (00:36 +0200)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sat, 9 Aug 2014 22:39:22 +0000 (00:39 +0200)
This assert happens all the time for character physics in debug mode.
In release mode, the assert is skipped but the code is still incorrect
although it does not cause any crash strangely.

extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp

index 8f1cd20..8d940e6 100644 (file)
@@ -29,10 +29,13 @@ subject to the following restrictions:
 static btVector3
 getNormalizedVector(const btVector3& v)
 {
-       btVector3 n = v.normalized();
-       if (n.length() < SIMD_EPSILON) {
-               n.setValue(0, 0, 0);
-       }
+    btScalar l = v.length();
+    btVector3 n = v;
+    if (l < SIMD_EPSILON) {
+        n.setValue(0,0,0);
+    } else {
+        n /= l;
+    }
        return n;
 }