diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-10-21 18:30:35 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-10-21 18:30:35 +0300 |
commit | 0775680e4d05eda3c495a56dc0b6eafbe96dc586 (patch) | |
tree | 4f3286eef96dec6ababe43467ed2a4f50388b988 /source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | |
parent | 4ade467fc6adfc13ce9e21d7e50b366fce70ea5f (diff) | |
parent | 6bc007610263c879f6bb30b844ba9d9a0fb9433c (diff) |
Merge branch 'master' into UI-graphical-redesignUI-graphical-redesign
Conflicts:
source/blender/blenkernel/BKE_blender.h
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/resources.c
Diffstat (limited to 'source/gameengine/Physics/Bullet/CcdPhysicsController.cpp')
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 8ecb586f77e..f11d7ac017f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -81,24 +81,24 @@ void BlenderBulletCharacterController::updateAction(btCollisionWorld *collisionW m_motionState->setWorldTransform(getGhostObject()->getWorldTransform()); } -int BlenderBulletCharacterController::getMaxJumps() const +unsigned char BlenderBulletCharacterController::getMaxJumps() const { return m_maxJumps; } -void BlenderBulletCharacterController::setMaxJumps(int maxJumps) +void BlenderBulletCharacterController::setMaxJumps(unsigned char maxJumps) { m_maxJumps = maxJumps; } -int BlenderBulletCharacterController::getJumpCount() const +unsigned char BlenderBulletCharacterController::getJumpCount() const { return m_jumps; } bool BlenderBulletCharacterController::canJump() const { - return onGround() || m_jumps < m_maxJumps; + return (onGround() && m_maxJumps > 0) || m_jumps < m_maxJumps; } void BlenderBulletCharacterController::jump() @@ -533,6 +533,7 @@ bool CcdPhysicsController::CreateCharacterController() m_characterController->setJumpSpeed(m_cci.m_jumpSpeed); m_characterController->setFallSpeed(m_cci.m_fallSpeed); + m_characterController->setMaxJumps(m_cci.m_maxJumps); return true; } @@ -820,6 +821,9 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta m_registerCount = 0; m_collisionShape = NULL; + // Clear all old constraints. + m_ccdConstraintRefs.clear(); + // always create a new shape to avoid scaling bug if (m_shapeInfo) { @@ -1080,7 +1084,7 @@ void CcdPhysicsController::RefreshCollisions() void CcdPhysicsController::SuspendDynamics(bool ghost) { btRigidBody *body = GetRigidBody(); - if (body && !m_suspended && !GetConstructionInfo().m_bSensor) + if (body && !m_suspended && !GetConstructionInfo().m_bSensor && GetPhysicsEnvironment()->IsActiveCcdPhysicsController(this)) { btBroadphaseProxy* handle = body->getBroadphaseHandle(); @@ -1102,7 +1106,7 @@ void CcdPhysicsController::SuspendDynamics(bool ghost) void CcdPhysicsController::RestoreDynamics() { btRigidBody *body = GetRigidBody(); - if (body && m_suspended) + if (body && m_suspended && GetPhysicsEnvironment()->IsActiveCcdPhysicsController(this)) { // before make sure any position change that was done in this logic frame are accounted for SetTransform(); @@ -1280,7 +1284,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()) @@ -1302,9 +1312,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()) |