| [1971] | 1 | /*************************************************************************** | 
|---|
 | 2 |  | 
|---|
 | 3 | This source file is part of OGREBULLET | 
|---|
 | 4 | (Object-oriented Graphics Rendering Engine Bullet Wrapper) | 
|---|
 | 5 | For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 | 
|---|
 | 6 |  | 
|---|
 | 7 | Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes) | 
|---|
 | 8 |  | 
|---|
 | 9 |  | 
|---|
 | 10 |  | 
|---|
 | 11 | This program is free software; you can redistribute it and/or modify it under | 
|---|
 | 12 | the terms of the GPL General Public License with runtime exception as published by the Free Software | 
|---|
 | 13 | Foundation; either version 2 of the License, or (at your option) any later | 
|---|
 | 14 | version. | 
|---|
 | 15 |  | 
|---|
 | 16 | This program is distributed in the hope that it will be useful, but WITHOUT | 
|---|
 | 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 
|---|
 | 18 | FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details. | 
|---|
 | 19 |  | 
|---|
 | 20 | You should have received a copy of the GPL General Public License with runtime exception along with | 
|---|
 | 21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple | 
|---|
 | 22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to | 
|---|
 | 23 | http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
 | 24 | ----------------------------------------------------------------------------- | 
|---|
 | 25 | */ | 
|---|
 | 26 |  | 
|---|
 | 27 | #ifndef _OGREBULLETDYNAMICS_DynamicWorld_H | 
|---|
 | 28 | #define _OGREBULLETDYNAMICS_DynamicWorld_H | 
|---|
 | 29 |  | 
|---|
 | 30 | #include "OgreBulletDynamicsPreRequisites.h" | 
|---|
 | 31 |  | 
|---|
 | 32 | #include "OgreBulletCollisionsWorld.h" | 
|---|
 | 33 | #include "Debug/OgreBulletCollisionsDebugDrawer.h" | 
|---|
 | 34 |  | 
|---|
 | 35 | namespace OgreBulletDynamics | 
|---|
 | 36 | { | 
|---|
 | 37 |     // ------------------------------------------------------------------------- | 
|---|
 | 38 |     // basic rigid body class | 
|---|
 | 39 |     class DynamicsWorld : public OgreBulletCollisions::CollisionsWorld | 
|---|
 | 40 |     { | 
|---|
 | 41 |     public: | 
|---|
 | 42 |         DynamicsWorld(Ogre::SceneManager *mgr,  | 
|---|
 | 43 |             const Ogre::AxisAlignedBox &bounds,   | 
|---|
 | 44 |             const Ogre::Vector3 &gravity, | 
|---|
 | 45 |             bool init = true); | 
|---|
 | 46 |  | 
|---|
 | 47 |             ~DynamicsWorld(); | 
|---|
 | 48 |  | 
|---|
 | 49 |         template <class BTDNYWORLDCLASS> | 
|---|
 | 50 |             void createBtDynamicsWorld(BTDNYWORLDCLASS *&createdWorld) | 
|---|
 | 51 |             { | 
|---|
 | 52 |                                 createdWorld = new BTDNYWORLDCLASS(mDispatcher, mBroadphase, mConstraintsolver, &mDefaultCollisionConfiguration); | 
|---|
 | 53 |                 mWorld = createdWorld; | 
|---|
 | 54 |             } | 
|---|
 | 55 |  | 
|---|
 | 56 |         void stepSimulation(const Ogre::Real elapsedTime, int maxSubSteps = 1, const Ogre::Real fixedTimestep = 1./60.); | 
|---|
 | 57 |  | 
|---|
 | 58 |         void addRigidBody (RigidBody *rb, short collisionGroup, short collisionMask); | 
|---|
 | 59 |  | 
|---|
 | 60 |         void setDebugDrawer(OgreBulletCollisions::DebugDrawer *debugdrawer) | 
|---|
 | 61 |         { | 
|---|
 | 62 |             mDebugDrawer = debugdrawer; | 
|---|
 | 63 |             (static_cast <btDiscreteDynamicsWorld *> (mWorld))->setDebugDrawer(mDebugDrawer); | 
|---|
 | 64 |         }; | 
|---|
 | 65 |  | 
|---|
 | 66 |         OgreBulletCollisions::DebugDrawer *getDebugDrawer(){return mDebugDrawer;}; | 
|---|
 | 67 |  | 
|---|
 | 68 |         inline btDynamicsWorld * getBulletDynamicsWorld() const {return static_cast<btDynamicsWorld *> (mWorld);}; | 
|---|
 | 69 |  | 
|---|
 | 70 |         void removeConstraint(TypedConstraint *constraint); | 
|---|
 | 71 |         void addConstraint(TypedConstraint *constraint); | 
|---|
 | 72 |         bool isConstraintRegistered(TypedConstraint *constraint) const; | 
|---|
 | 73 |  | 
|---|
 | 74 |         void addVehicle(RaycastVehicle *v); | 
|---|
 | 75 |  | 
|---|
 | 76 |     private: | 
|---|
 | 77 |         OgreBulletCollisions::DebugDrawer                 *mDebugDrawer; | 
|---|
 | 78 |  | 
|---|
 | 79 |         btConstraintSolver                                *mConstraintsolver; | 
|---|
 | 80 |  | 
|---|
 | 81 |         std::deque <TypedConstraint *>                    mConstraints; | 
|---|
 | 82 |     }; | 
|---|
 | 83 | } | 
|---|
 | 84 | #endif //_OGREBULLETDYNAMICS_DynamicWorld_H | 
|---|
 | 85 |  | 
|---|