~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/gameengine/Physics/Bullet/CcdPhysicsController.h

Tags: upstream-2.40
ImportĀ upstreamĀ versionĀ 2.40

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef BULLET2_PHYSICSCONTROLLER_H
 
3
#define BULLET2_PHYSICSCONTROLLER_H
 
4
 
 
5
#include "PHY_IPhysicsController.h"
 
6
 
 
7
///     PHY_IPhysicsController is the abstract simplified Interface to a physical object.
 
8
///     It contains the IMotionState and IDeformableMesh Interfaces.
 
9
#include "SimdVector3.h"
 
10
#include "SimdScalar.h" 
 
11
#include "SimdMatrix3x3.h"
 
12
 
 
13
class CollisionShape;
 
14
 
 
15
extern float gDeactivationTime;
 
16
extern float gLinearSleepingTreshold;
 
17
extern float gAngularSleepingTreshold;
 
18
extern bool gDisableDeactivation;
 
19
 
 
20
 
 
21
struct CcdConstructionInfo
 
22
{
 
23
        CcdConstructionInfo()
 
24
                : m_gravity(0,0,0),
 
25
                m_mass(0.f),
 
26
                m_restitution(0.1f),
 
27
                m_linearDamping(0.1f),
 
28
                m_angularDamping(0.1f),
 
29
                m_MotionState(0),
 
30
                m_collisionShape(0)
 
31
 
 
32
        {
 
33
        }
 
34
        SimdVector3     m_localInertiaTensor;
 
35
        SimdVector3     m_gravity;
 
36
        SimdScalar      m_mass;
 
37
        SimdScalar      m_restitution;
 
38
        SimdScalar      m_friction;
 
39
        SimdScalar      m_linearDamping;
 
40
        SimdScalar      m_angularDamping;
 
41
        void*           m_broadphaseHandle;
 
42
        class   PHY_IMotionState*                       m_MotionState;
 
43
 
 
44
        CollisionShape*                 m_collisionShape;
 
45
        
 
46
};
 
47
 
 
48
 
 
49
class RigidBody;
 
50
 
 
51
///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
 
52
class CcdPhysicsController : public PHY_IPhysicsController      
 
53
{
 
54
        RigidBody* m_body;
 
55
        class   PHY_IMotionState*                       m_MotionState;
 
56
        CollisionShape*                 m_collisionShape;
 
57
        void*           m_newClientInfo;
 
58
 
 
59
        void GetWorldOrientation(SimdMatrix3x3& mat);
 
60
 
 
61
        public:
 
62
        
 
63
                int                             m_collisionDelay;
 
64
        
 
65
                void*  m_broadphaseHandle;
 
66
 
 
67
                CcdPhysicsController (const CcdConstructionInfo& ci);
 
68
 
 
69
                virtual ~CcdPhysicsController();
 
70
 
 
71
 
 
72
                RigidBody* GetRigidBody() { return m_body;}
 
73
 
 
74
                CollisionShape* GetCollisionShape() { return m_collisionShape;}
 
75
                ////////////////////////////////////
 
76
                // PHY_IPhysicsController interface
 
77
                ////////////////////////////////////
 
78
 
 
79
 
 
80
                /**
 
81
                        SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
 
82
                */
 
83
                virtual bool            SynchronizeMotionStates(float time);
 
84
                /**
 
85
                        WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
 
86
                */
 
87
                
 
88
                virtual void            WriteMotionStateToDynamics(bool nondynaonly);
 
89
                virtual void            WriteDynamicsToMotionState();
 
90
                // controller replication
 
91
                virtual void            PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
 
92
 
 
93
                // kinematic methods
 
94
                virtual void            RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
 
95
                virtual void            RelativeRotate(const float drot[9],bool local);
 
96
                virtual void            getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
 
97
                virtual void            setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
 
98
                virtual void            setPosition(float posX,float posY,float posZ);
 
99
                virtual void            getPosition(PHY__Vector3&       pos) const;
 
100
 
 
101
                virtual void            setScaling(float scaleX,float scaleY,float scaleZ);
 
102
                
 
103
                // physics methods
 
104
                virtual void            ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
 
105
                virtual void            ApplyForce(float forceX,float forceY,float forceZ,bool local);
 
106
                virtual void            SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
 
107
                virtual void            SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
 
108
                virtual void            applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
 
109
                virtual void            SetActive(bool active);
 
110
 
 
111
                // reading out information from physics
 
112
                virtual void            GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
 
113
                virtual void            GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ); 
 
114
                virtual void            getReactionForce(float& forceX,float& forceY,float& forceZ);
 
115
 
 
116
                // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
 
117
                virtual void            setRigidBody(bool rigid);
 
118
 
 
119
                
 
120
                virtual void            resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
 
121
 
 
122
                // clientinfo for raycasts for example
 
123
                virtual void*                           getNewClientInfo();
 
124
                virtual void                            setNewClientInfo(void* clientinfo);
 
125
                virtual PHY_IPhysicsController* GetReplica() {return 0;}
 
126
 
 
127
                virtual void    calcXform() {} ;
 
128
                virtual void SetMargin(float margin) {};
 
129
                virtual float GetMargin() const {return 0.f;};
 
130
 
 
131
 
 
132
                bool    wantsSleeping();
 
133
 
 
134
                void    UpdateDeactivation(float timeStep);
 
135
 
 
136
                void    SetAabb(const SimdVector3& aabbMin,const SimdVector3& aabbMax);
 
137
 
 
138
 
 
139
};
 
140
 
 
141
#endif //BULLET2_PHYSICSCONTROLLER_H