btWorld.h
Engine/source/T3D/physics/bullet/btWorld.h
Classes:
class
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _BTWORLD_H_ 25#define _BTWORLD_H_ 26 27#ifndef _T3D_PHYSICS_PHYSICSWORLD_H_ 28#include "T3D/physics/physicsWorld.h" 29#endif 30#ifndef _T3D_PHYSICS_BTDEBUGDRAW_H_ 31#include "T3D/physics/bullet/btDebugDraw.h" 32#endif 33#ifndef _BULLET_H_ 34#include "T3D/physics/bullet/bt.h" 35#endif 36#ifndef _TVECTOR_H_ 37#include "core/util/tVector.h" 38#endif 39 40class ProcessList; 41class PhysicsBody; 42 43 44class BtWorld : public PhysicsWorld 45{ 46protected: 47 48 BtDebugDraw mDebugDraw; 49 50 F32 mEditorTimeScale; 51 52 btDynamicsWorld *mDynamicsWorld; 53 btBroadphaseInterface *mBroadphase; 54 btCollisionDispatcher *mDispatcher; 55 btConstraintSolver *mSolver; 56 btDefaultCollisionConfiguration *mCollisionConfiguration; 57 58 bool mErrorReport; 59 60 bool mIsEnabled; 61 62 bool mIsSimulating; 63 64 U32 mTickCount; 65 66 ProcessList *mProcessList; 67 68 void _destroy(); 69 70public: 71 72 BtWorld(); 73 virtual ~BtWorld(); 74 75 // PhysicWorld 76 virtual bool initWorld( bool isServer, ProcessList *processList ); 77 virtual void destroyWorld(); 78 virtual bool castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse ); 79 virtual PhysicsBody* castRay( const Point3F &start, const Point3F &end, U32 bodyTypes ); 80 virtual void explosion( const Point3F &pos, F32 radius, F32 forceMagnitude ); 81 virtual void onDebugDraw( const SceneRenderState *state ); 82 virtual void reset(); 83 virtual bool isEnabled() const { return mIsEnabled; } 84 85 btDynamicsWorld* getDynamicsWorld() const { return mDynamicsWorld; } 86 87 void tickPhysics( U32 elapsedMs ); 88 void getPhysicsResults(); 89 bool isWritable() const { return !mIsSimulating; } 90 91 void setEnabled( bool enabled ); 92 bool getEnabled() const { return mIsEnabled; } 93 94 void setEditorTimeScale( F32 timeScale ) { mEditorTimeScale = timeScale; } 95 const F32 getEditorTimeScale() const { return mEditorTimeScale; } 96 97}; 98 99#endif // _BTWORLD_H_ 100