Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2015-10-09 10:29:31 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2015-10-09 10:50:20 +0300
commit46ad2203057fbe4418120ab6dc1cb830e3d53958 (patch)
tree2ad295da3a2f5a9713bdd2a786be6e7dc41525bf /source/gameengine/Physics
parentff7effdc041cb87997960bd578a126f7f268f1b4 (diff)
BGE Fix T41943: Zeroing out angular velocity not possible
This patch makes it possible to zero out angular velocity. tiny angular velocities may cause instabilities, according to the discussion in T41943, so they are mapped to (0, 0, 0) instead. It also applies the same reasoning to the linear velocity, unifying the different approaches. Differential revision: D952
Diffstat (limited to 'source/gameengine/Physics')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index dbaa925db08..ab7097b19ca 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1283,7 +1283,13 @@ void CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local)
void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
{
btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z());
- if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
+
+ /* Refuse tiny tiny velocities, as they might cause instabilities. */
+ float vel_squared = angvel.length2();
+ if (vel_squared > 0 && vel_squared <= (SIMD_EPSILON*SIMD_EPSILON))
+ angvel = btVector3(0, 0, 0);
+
+ if (m_object)
{
m_object->activate(true);
if (m_object->isStaticObject())
@@ -1305,9 +1311,14 @@ void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool lo
}
void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
{
-
btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z());
- if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/)
+
+ /* Refuse tiny tiny velocities, as they might cause instabilities. */
+ float vel_squared = linVel.length2();
+ if (vel_squared > 0 && vel_squared <= (SIMD_EPSILON*SIMD_EPSILON))
+ linVel = btVector3(0, 0, 0);
+
+ if (m_object)
{
m_object->activate(true);
if (m_object->isStaticObject())