Adds findContact to regular physics bodies so that they can find contacting objects...
[Torque-3d.git] / Engine / source / T3D / physics / bullet / btBody.h
blob2de1215d28ba066b752aa34c56fd0dcc3f352f2b
1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2012 GarageGames, LLC
3 //
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
20 // IN THE SOFTWARE.
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"
28 #endif
29 #ifndef _REFBASE_H_
30 #include "core/util/refBase.h"
31 #endif
32 #ifndef _MMATRIX_H_
33 #include "math/mMatrix.h"
34 #endif
36 class BtWorld;
37 class btRigidBody;
38 class btCompoundShape;
39 class BtCollision;
42 class BtBody : public PhysicsBody
44 protected:
46 /// The physics world we are in.
47 BtWorld *mWorld;
49 /// The physics actor.
50 btRigidBody *mActor;
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;
59 ///
60 F32 mMass;
62 ///
63 bool mIsDynamic;
65 /// Is the body participating in the physics simulation.
66 bool mIsEnabled;
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;
75 ///
76 void _releaseActor();
78 public:
80 BtBody();
81 virtual ~BtBody();
83 // PhysicsObject
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; }
91 // PhysicsBody
92 virtual bool init( PhysicsCollision *shape,
93 F32 mass,
94 U32 bodyFlags,
95 SceneObject *obj,
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,
110 F32 friction,
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_