1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2012 GarageGames, LLC
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 //-----------------------------------------------------------------------------
23 #ifndef _T3D_PHYSICS_BTBODY_H_
24 #define _T3D_PHYSICS_BTBODY_H_
26 #ifndef _T3D_PHYSICS_PHYSICSBODY_H_
27 #include "T3D/physics/physicsBody.h"
30 #include "core/util/refBase.h"
33 #include "math/mMatrix.h"
38 class btCompoundShape
;
42 class BtBody
: public PhysicsBody
46 /// The physics world we are in.
49 /// The physics actor.
52 /// The collision representation.
53 StrongRefPtr
<BtCollision
> mColShape
;
55 /// Our local compound if we had to adjust
56 /// the mass center on a dynamic.
57 btCompoundShape
*mCompound
;
65 /// Is the body participating in the physics simulation.
68 /// The center of mass offset used if the graphical
69 /// transform is not at the mass center.
70 MatrixF
*mCenterOfMass
;
72 /// The inverse center of mass offset.
73 MatrixF
*mInvCenterOfMass
;
84 virtual PhysicsWorld
* getWorld();
85 virtual void setTransform( const MatrixF
&xfm
);
86 virtual MatrixF
& getTransform( MatrixF
*outMatrix
);
87 virtual Box3F
getWorldBounds();
88 virtual void setSimulationEnabled( bool enabled
);
89 virtual bool isSimulationEnabled() { return mIsEnabled
; }
92 virtual bool init( PhysicsCollision
*shape
,
96 PhysicsWorld
*world
);
97 virtual bool isDynamic() const { return mIsDynamic
; }
98 virtual PhysicsCollision
* getColShape();
99 virtual void setSleepThreshold( F32 linear
, F32 angular
);
100 virtual void setDamping( F32 linear
, F32 angular
);
101 virtual void getState( PhysicsState
*outState
);
102 virtual F32
getMass() const { return mMass
; }
103 virtual Point3F
getCMassPosition() const;
104 virtual void setLinVelocity( const Point3F
&vel
);
105 virtual void setAngVelocity( const Point3F
&vel
);
106 virtual Point3F
getLinVelocity() const;
107 virtual Point3F
getAngVelocity() const;
108 virtual void setSleeping( bool sleeping
);
109 virtual void setMaterial( F32 restitution
,
111 F32 staticFriction
);
112 virtual void applyCorrection( const MatrixF
&xfm
);
113 virtual void applyImpulse( const Point3F
&origin
, const Point3F
&force
);
115 virtual void findContact(SceneObject
**contactObject
, VectorF
*contactNormal
, Vector
<SceneObject
*> *outOverlapObjects
) const;
118 #endif // _T3D_PHYSICS_BTBODY_H_