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:
authorErwin Coumans <blender@erwincoumans.com>2005-08-03 22:22:30 +0400
committerErwin Coumans <blender@erwincoumans.com>2005-08-03 22:22:30 +0400
commit2cc6d565cbc9da005e1c13828c6b3a3d46cd32cb (patch)
tree223668a1cc543f49419885e4dbcae40b65bd9229 /source/gameengine/Physics
parent8a58197cf3f35fe5123721f4a2d8161f1147c3f2 (diff)
moved some hardcoded constants into tweaking tresholds
exposed those tresholds to python (more 'expert' settings)
Diffstat (limited to 'source/gameengine/Physics')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp22
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h5
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp61
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h12
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h4
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h20
6 files changed, 101 insertions, 23 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 19c4632820c..8f532aafa9e 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -7,7 +7,11 @@
class BP_Proxy;
-bool gEnableSleeping = false;//false;//true;
+//'temporarily' global variables
+float gDeactivationTime = 0.f;
+float gLinearSleepingTreshold = 0.8f;
+float gAngularSleepingTreshold = 1.0f;
+
#include "Dynamics/MassProps.h"
SimdVector3 startVel(0,0,0);//-10000);
@@ -190,27 +194,19 @@ void CcdPhysicsController::setNewClientInfo(void* clientinfo)
}
-#ifdef WIN32
-float gSleepingTreshold = 0.8f;
-float gAngularSleepingTreshold = 1.f;
-
-#else
-
-float gSleepingTreshold = 0.8f;
-float gAngularSleepingTreshold = 1.0f;
-#endif
bool CcdPhysicsController::wantsSleeping()
{
- if (!gEnableSleeping)
+ //disable deactivation
+ if (gDeactivationTime == 0.f)
return false;
if ( (m_body->GetActivationState() == 3) || (m_body->GetActivationState() == 2))
return true;
- if ((m_body->getLinearVelocity().length2() < gSleepingTreshold*gSleepingTreshold) &&
+ if ((m_body->getLinearVelocity().length2() < gLinearSleepingTreshold*gLinearSleepingTreshold) &&
(m_body->getAngularVelocity().length2() < gAngularSleepingTreshold*gAngularSleepingTreshold))
{
m_sleepingCounter++;
@@ -219,7 +215,7 @@ bool CcdPhysicsController::wantsSleeping()
m_sleepingCounter=0;
}
- if (m_sleepingCounter> 150)
+ if (m_sleepingCounter> gDeactivationTime)
{
return true;
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 235931ebab4..53991e202e9 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -10,6 +10,11 @@
#include "SimdScalar.h"
class CollisionShape;
+extern float gDeactivationTime;
+extern float gLinearSleepingTreshold;
+extern float gAngularSleepingTreshold;
+
+
struct CcdConstructionInfo
{
CcdConstructionInfo()
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 94ecfe27de2..0b1878fdf67 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -33,8 +33,6 @@ bool useIslands = true;
//#include "BroadphaseCollision/QueryBox.h"
//todo: change this to allow dynamic registration of types!
-unsigned long gNumIterations = 10;
-
#ifdef WIN32
void DrawRasterizerLine(const float* from,const float* to,int color);
#endif
@@ -88,13 +86,16 @@ static void DrawAabb(IDebugDraw* debugDrawer,const SimdVector3& from,const SimdV
CcdPhysicsEnvironment::CcdPhysicsEnvironment(ToiContactDispatcher* dispatcher,BroadphaseInterface* bp)
:m_dispatcher(dispatcher),
m_broadphase(bp),
-m_scalingPropagated(false)
+m_scalingPropagated(false),
+m_numIterations(30),
+m_ccdMode(0)
{
if (!m_dispatcher)
{
OdeConstraintSolver* solver = new OdeConstraintSolver();
//SimpleConstraintSolver* solver= new SimpleConstraintSolver();
m_dispatcher = new ToiContactDispatcher(solver);
+
}
if (!m_broadphase)
{
@@ -290,7 +291,6 @@ void CcdPhysicsEnvironment::UpdateActivationState()
}
-bool gPredictCollision = false;//true;//false;
/// Perform an integration step of duration 'timeStep'.
@@ -346,7 +346,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
- int numsubstep = gNumIterations;
+ int numsubstep = m_numIterations;
DispatcherInfo dispatchInfo;
@@ -367,7 +367,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
//contacts
- m_dispatcher->SolveConstraints(timeStep, gNumIterations ,numRigidBodies,m_debugDrawer);
+ m_dispatcher->SolveConstraints(timeStep, m_numIterations ,numRigidBodies,m_debugDrawer);
for (int g=0;g<numsubstep;g++)
{
@@ -454,7 +454,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
- if (gPredictCollision)
+ if (m_ccdMode == 3)
{
DispatcherInfo dispatchInfo;
dispatchInfo.m_timeStep = timeStep;
@@ -548,7 +548,7 @@ void CcdPhysicsEnvironment::setDebugMode(int debugMode)
if (m_dispatcher)
delete m_dispatcher;
- if (debugMode == 11)
+ if (debugMode > 100)
{
SimpleConstraintSolver* solver= new SimpleConstraintSolver();
m_dispatcher = new ToiContactDispatcher(solver);
@@ -563,6 +563,51 @@ void CcdPhysicsEnvironment::setDebugMode(int debugMode)
}
}
+void CcdPhysicsEnvironment::setNumIterations(int numIter)
+{
+ m_numIterations = numIter;
+}
+void CcdPhysicsEnvironment::setDeactivationTime(float dTime)
+{
+ gDeactivationTime = dTime;
+}
+void CcdPhysicsEnvironment::setDeactivationLinearTreshold(float linTresh)
+{
+ gLinearSleepingTreshold = linTresh;
+}
+void CcdPhysicsEnvironment::setDeactivationAngularTreshold(float angTresh)
+{
+ gAngularSleepingTreshold = angTresh;
+}
+void CcdPhysicsEnvironment::setContactBreakingTreshold(float contactBreakingTreshold)
+{
+ gContactBreakingTreshold = contactBreakingTreshold;
+
+}
+
+
+void CcdPhysicsEnvironment::setCcdMode(int ccdMode)
+{
+ m_ccdMode = ccdMode;
+}
+
+
+void CcdPhysicsEnvironment::setSolverSorConstant(float sor)
+{
+ m_dispatcher->SetSor(sor);
+}
+
+void CcdPhysicsEnvironment::setTau(float tau)
+{
+ m_dispatcher->SetTau(tau);
+}
+void CcdPhysicsEnvironment::setDamping(float damping)
+{
+ m_dispatcher->SetDamping(damping);
+}
+
+
+
void CcdPhysicsEnvironment::SyncMotionStates(float timeStep)
{
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index be6f6c648c7..5e98ffd2473 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -26,6 +26,8 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
SimdVector3 m_gravity;
BroadphaseInterface* m_broadphase;
IDebugDraw* m_debugDrawer;
+ int m_numIterations;
+ int m_ccdMode;
public:
CcdPhysicsEnvironment(ToiContactDispatcher* dispatcher=0, BroadphaseInterface* broadphase=0);
@@ -43,6 +45,16 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
m_debugDrawer = debugDrawer;
}
+ virtual void setNumIterations(int numIter);
+ virtual void setDeactivationTime(float dTime);
+ virtual void setDeactivationLinearTreshold(float linTresh) ;
+ virtual void setDeactivationAngularTreshold(float angTresh) ;
+ virtual void setContactBreakingTreshold(float contactBreakingTreshold) ;
+ virtual void setCcdMode(int ccdMode);
+ virtual void setSolverSorConstant(float sor);
+ virtual void setTau(float tau);
+ virtual void setDamping(float damping);
+
virtual void beginFrame() {};
virtual void endFrame() {};
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index cdf203ac17e..931dc0e988c 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -34,12 +34,12 @@
#include "PHY_DynamicTypes.h"
+
+
/**
PHY_IPhysicsController is the abstract simplified Interface to a physical object.
It contains the IMotionState and IDeformableMesh Interfaces.
*/
-
-
class PHY_IPhysicsController
{
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index ca856598772..96b0eda326f 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -51,7 +51,27 @@ class PHY_IPhysicsEnvironment
//returns 0.f if no fixed timestep is used
virtual float getFixedTimeStep()=0;
+ ///setDebugMode is used to support several ways of debug lines, contact point visualization
virtual void setDebugMode(int debugMode) {}
+ ///setNumIterations set the number of iterations for iterative solvers
+ virtual void setNumIterations(int numIter) {}
+ ///setDeactivationTime sets the minimum time that an objects has to stay within the velocity tresholds until it gets fully deactivated
+ virtual void setDeactivationTime(float dTime) {}
+ ///setDeactivationLinearTreshold sets the linear velocity treshold, see setDeactivationTime
+ virtual void setDeactivationLinearTreshold(float linTresh) {}
+ ///setDeactivationAngularTreshold sets the angular velocity treshold, see setDeactivationTime
+ virtual void setDeactivationAngularTreshold(float angTresh) {}
+ ///setContactBreakingTreshold sets tresholds to do with contact point management
+ virtual void setContactBreakingTreshold(float contactBreakingTreshold) {}
+ ///continuous collision detection mode, very experimental for Bullet
+ virtual void setCcdMode(int ccdMode) {}
+ ///successive overrelaxation constant, in case PSOR is used, values in between 1 and 2 guarantee converging behaviour
+ virtual void setSolverSorConstant(float sor) {}
+ ///setTau sets the spring constant of a penalty based solver
+ virtual void setTau(float tau) {}
+ ///setDamping sets the damper constant of a penalty based solver
+ virtual void setDamping(float damping) {}
+
virtual void setGravity(float x,float y,float z)=0;
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,