updated testbed demo
authorErwin Coumans <blender@erwincoumans.com>
Sat, 30 Jul 2005 18:58:21 +0000 (18:58 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Sat, 30 Jul 2005 18:58:21 +0000 (18:58 +0000)
extern/bullet/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.cpp
extern/bullet/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.h
extern/bullet/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.cpp
extern/bullet/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.h

index 8b423204bec5e51ed4d831d1df3ae86a28e35429..19c4632820c6f564e198a348a1389e4152e552ed 100644 (file)
@@ -31,7 +31,7 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
 
        MassProps mp(ci.m_mass, ci.m_localInertiaTensor);
 
-       m_body = new RigidBody(mp,0,0);
+       m_body = new RigidBody(mp,0,0,ci.m_friction,ci.m_restitution);
        
        m_broadphaseHandle = ci.m_broadphaseHandle;
 
@@ -44,12 +44,10 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
        m_body->setMassProps(ci.m_mass, ci.m_localInertiaTensor);
        m_body->setGravity( ci.m_gravity);
 
-       m_friction = ci.m_friction;
-       m_restitution = ci.m_restitution;
-
+       
        m_body->setDamping(ci.m_linearDamping, ci.m_angularDamping);
 
-       
+
        m_body->setCenterOfMassTransform( trans );
 
        #ifdef WIN32
index 3a8590e261c6925ff7ff41082a243c110f9275d7..235931ebab47d2cd0c6b6adbcbc98bef2207b8b5 100644 (file)
@@ -15,7 +15,6 @@ struct CcdConstructionInfo
        CcdConstructionInfo()
                : m_gravity(0,0,0),
                m_mass(0.f),
-               m_friction(0.1f),
                m_restitution(0.1f),
                m_linearDamping(0.1f),
                m_angularDamping(0.1f),
@@ -27,9 +26,8 @@ struct CcdConstructionInfo
        SimdVector3     m_localInertiaTensor;
        SimdVector3     m_gravity;
        SimdScalar      m_mass;
-       SimdScalar      m_friction;
        SimdScalar      m_restitution;
-       
+       SimdScalar      m_friction;
        SimdScalar      m_linearDamping;
        SimdScalar      m_angularDamping;
        void*           m_broadphaseHandle;
@@ -54,8 +52,6 @@ class CcdPhysicsController : public PHY_IPhysicsController
        
                int                             m_collisionDelay;
        
-               SimdScalar      m_friction;
-               SimdScalar      m_restitution;
                void*  m_broadphaseHandle;
 
                CcdPhysicsController (const CcdConstructionInfo& ci);
index 885304983a6da7047cf326ead155079170a083fc..5b6db434f8bbf51dcbcc7a1ccda10244fabf42ed 100644 (file)
@@ -33,7 +33,7 @@ bool useIslands = true;
 //#include "BroadphaseCollision/QueryBox.h"
 //todo: change this to allow dynamic registration of types!
 
-unsigned long gNumIterations = 1;
+unsigned long gNumIterations = 10;
 
 #ifdef WIN32
 void DrawRasterizerLine(const float* from,const float* to,int color);
@@ -366,6 +366,7 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
 
        //contacts
 
+       
        m_dispatcher->SolveConstraints(timeStep, gNumIterations ,numRigidBodies,m_debugDrawer);
 
        for (int g=0;g<numsubstep;g++)
@@ -438,7 +439,7 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
                                        
 #ifdef WIN32
                                        SimdVector3 color (1,0,0);
-                                       if (0)//m_debugDrawer)
+                                       if (m_debugDrawer)
                                        {       
                                                //draw aabb
 
@@ -540,6 +541,29 @@ bool       CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
        return true;
 }
 
+void           CcdPhysicsEnvironment::setDebugMode(int debugMode)
+{
+       if (debugMode > 10)
+       {
+               if (m_dispatcher)
+                       delete m_dispatcher;
+
+               if (debugMode == 11)
+               {
+                       SimpleConstraintSolver* solver= new SimpleConstraintSolver();
+                       m_dispatcher = new ToiContactDispatcher(solver);
+               } else
+               {
+                       OdeConstraintSolver* solver = new OdeConstraintSolver();
+                       m_dispatcher = new ToiContactDispatcher(solver);
+               }
+       }
+       if (m_debugDrawer){
+               m_debugDrawer->SetDebugMode(debugMode);
+       }
+}
+
+
 void   CcdPhysicsEnvironment::SyncMotionStates(float timeStep)
 {
        std::vector<CcdPhysicsController*>::iterator i;
index fc3786885b79958f3eb4a54a9228a4e36ccc3900..be6f6c648c7edf6f6c93085718a4d8a75d515271 100644 (file)
@@ -50,8 +50,11 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
                virtual bool            proceedDeltaTime(double curTime,float timeStep);
                virtual void            setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep){};
                //returns 0.f if no fixed timestep is used
+
                virtual float           getFixedTimeStep(){ return 0.f;};
 
+               virtual void            setDebugMode(int debugMode);
+
                virtual void            setGravity(float x,float y,float z);
 
                virtual int                     createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
@@ -113,6 +116,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
 
                bool    m_scalingPropagated;
 
+
 };
 
 #endif //CCDPHYSICSENVIRONMENT