diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-07-03 12:13:47 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-07-25 14:09:01 +0300 |
commit | 221aee7ecdb352f87e6baae87061fbfc05e8f819 (patch) | |
tree | fc5296e9c7500997a03c0a81add05837e46e235c /source | |
parent | 9ff869e4fb36e95dc67de162d7b3392eb08efe6d (diff) |
BGE: Fix T45278 sleeping deactivation with overlay scene.
this commit fix also angular and linear threshold sleeping value update via bge.constraints.
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 35 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h | 5 |
2 files changed, 33 insertions, 7 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 9b2a83c3e67..71a603fc747 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -410,6 +410,10 @@ m_ccdMode(0), m_solverType(-1), m_profileTimings(0), m_enableSatCollisionDetection(false), +m_deactivationTime(2.0f), +m_linearDeactivationThreshold(0.8f), +m_angularDeactivationThreshold(1.0f), +m_contactBreakingThreshold(0.02f), m_solver(NULL), m_ownPairCache(NULL), m_filterCallback(NULL), @@ -472,8 +476,10 @@ void CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl) //this m_userPointer is just used for triggers, see CallbackTriggers obj->setUserPointer(ctrl); - if (body) - body->setGravity( m_gravity ); + if (body) { + body->setGravity(m_gravity); + body->setSleepingThresholds(m_linearDeactivationThreshold, m_angularDeactivationThreshold); + } if (body) { @@ -699,6 +705,10 @@ bool CcdPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float std::set<CcdPhysicsController*>::iterator it; int i; + // Update Bullet global variables. + gDeactivationTime = m_deactivationTime; + gContactBreakingThreshold = m_contactBreakingThreshold; + for (it=m_controllers.begin(); it!=m_controllers.end(); it++) { (*it)->SynchronizeMotionStates(timeStep); @@ -918,21 +928,32 @@ void CcdPhysicsEnvironment::SetNumIterations(int numIter) } void CcdPhysicsEnvironment::SetDeactivationTime(float dTime) { - gDeactivationTime = dTime; + m_deactivationTime = dTime; } void CcdPhysicsEnvironment::SetDeactivationLinearTreshold(float linTresh) { - gLinearSleepingTreshold = linTresh; + m_linearDeactivationThreshold = linTresh; + + // Update from all controllers. + for (std::set<CcdPhysicsController*>::iterator it = m_controllers.begin(); it != m_controllers.end(); it++) { + if ((*it)->GetRigidBody()) + (*it)->GetRigidBody()->setSleepingThresholds(m_linearDeactivationThreshold, m_angularDeactivationThreshold); + } } void CcdPhysicsEnvironment::SetDeactivationAngularTreshold(float angTresh) { - gAngularSleepingTreshold = angTresh; + m_angularDeactivationThreshold = angTresh; + + // Update from all controllers. + for (std::set<CcdPhysicsController*>::iterator it = m_controllers.begin(); it != m_controllers.end(); it++) { + if ((*it)->GetRigidBody()) + (*it)->GetRigidBody()->setSleepingThresholds(m_linearDeactivationThreshold, m_angularDeactivationThreshold); + } } void CcdPhysicsEnvironment::SetContactBreakingTreshold(float contactBreakingTreshold) { - gContactBreakingThreshold = contactBreakingTreshold; - + m_contactBreakingThreshold = contactBreakingTreshold; } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index d681298c195..3d7e3943f98 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -88,6 +88,11 @@ protected: int m_profileTimings; bool m_enableSatCollisionDetection; + float m_deactivationTime; + float m_linearDeactivationThreshold; + float m_angularDeactivationThreshold; + float m_contactBreakingThreshold; + void ProcessFhSprings(double curTime,float timeStep); public: |