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:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-07-03 12:13:47 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-07-25 14:09:01 +0300
commit221aee7ecdb352f87e6baae87061fbfc05e8f819 (patch)
treefc5296e9c7500997a03c0a81add05837e46e235c /source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
parent9ff869e4fb36e95dc67de162d7b3392eb08efe6d (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/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp35
1 files changed, 28 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;
}